Units in Inkscape

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

mathog
On 12-Sep-2014 09:32, Tavmjong Bah wrote:

> http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape

The example:

<svg width="100mm" height="100mm" viewBox="0 0 100 100">

Is insufficient.  Must the numbers in the viewBox match those in the
width? In other
graphics formats that isn't the case (see below).  Can't tell from
this svg example.  The example could be more like this (for A4 paper):

<svg width="210mm" height="297mm" viewBox="0 0 2100 2970">
   <g  style="fill:#ff0000;stroke:none" >
      <g transform="scale(2)">
         <rect x="10" y="20" width="50" height="100" />
         <rect x="250" y="350" width="25" height="50" />
      </g>
      <rect x="200" y="300" width="250" height="500" />
   </g>
</svg>

NOW, what happens if the user changes units from mm to in?  If this was
Microsoft's EMF format
after that change the equivalent would be:

<svg width="8.267in" height="11.692mm" viewBox="0 0 2100 2970">
(no other change)

See for instance the description of the metafile header here:

   
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162607%28v=vs.85%29.aspx

where the drawing resolution is set by szlDevice and its physical size
by szlMillimeters.  They later added szlMicrometers for better precision
on the latter, although in most files one encounters they differ by only
a perfect factor of 1000.  (Further on in the file it is commmon to run
into other transforms including some mapping viewports onto
windowextents.)  The EMF format does not worry about what happens if a
program chooses to show the physical units in inches instead of mm, that
isn't anything it cares about.  All it cares about is the internal
precision and the physical size, with the latter always being in metric
units.  That said,
there is a "SETMAPMODE" record in which the internals of the drawing can
be in inches or "twips".  However, documents that actually use these
other modes are exceedingly rare.

Back to SVG.  If the numbers in the viewBox need not match the numbers
in the width/height, there is an implicit transform at the top of the
SVG document, which converts from arbitrary internal
units to defined external physical dimensions.  If they must match then
there is no such transform - and the reader needs to see how that plays
out too.  Explicitly.

Regards,

David Mathog
[hidden email]
Manager, Sequence Analysis Facility, Biology Division, Caltech

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

mathog
On 12-Sep-2014 15:52, mathog wrote:
> Back to SVG.  If the numbers in the viewBox need not match the numbers
> in the width/height,

The need not match, as shown in this example:

    http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute

Regards,

David Mathog
[hidden email]
Manager, Sequence Analysis Facility, Biology Division, Caltech

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

Johan Engelen-4
In reply to this post by LucaDC
On 12-9-2014 15:11, LucaDC wrote:
> Johan Engelen-4 wrote
>> Inkscape is behaving exactly as you write in your email. If it is not,
>> it is a bug, and we are aware of some of them.
> Could you please elaborate this on the example I posted?
> Thanks.

Going on a trip for few days, so just a quick answer.

    width=&quot;744.09448&quot;    (? not mm and 90 DPI)
    height=&quot;1052.3622&quot;    (? not mm and 90 DPI)
    inkscape:version=&quot;0.91pre2 r13550&quot;
    viewBox=&quot;0 0 210 297&quot;

That is already bad. The default template does not contain units. If you open a document, go to document props and click around a bit, then units should show up in width/height. Then try again what you did and see if it works better.
The fix is easy: fix default templates + fix setting units on documents without units set. I believe, currently, changing document units ("Default units" should be renamed to "Document units") does not add units if they were not there.

regards,
  Johan



------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

Johan Engelen-4
In reply to this post by Tavmjong Bah
Very quick reply, sorry.

On 12-9-2014 18:32, Tavmjong Bah wrote:

> On Thu, 2014-09-11 at 22:47 +0200, Johan Engelen wrote:
>> On 11-9-2014 14:58, Tavmjong Bah wrote:
>>>                          Units in Inkscape
>>>                          =================
>>>
>>> Introduction
>>> -----------
>>>
>>> The recent debate about units in Inkscape highlights the fact that we do not have a clearly defined approach on how to handle units in Inkscape. Units are not as straight-forward as one should think they are. This essay attempts to resolve this problem.
>> This is not true, from my point of view.
>> We had and have a very clearly defined approach to units. This was
>> implemented as part of a GSoC project last year, and has not changed.
>> The approach has been communicated several times on the mailing list.
>> Inkscape is behaving exactly as you write in your email. If it is not,
>> it is a bug, and we are aware of some of them.
> I've just looked back at the mail archives. I can find parts of the
> approach described in the emails but it is hard to pick out the overall
> philosophy. I have started a wiki page for future reference. Please
> review:
>
> http://wiki.inkscape.org/wiki/index.php/Units_In_Inkscape

Thanks.

>> Some issues that we are aware of for a long time now (you touch upon
>> some of them in your mail):
>> - explicit units in certain areas (font size, stroke width, ...)
>> - "px" should be renamed
> I don't think renaming 'px' is a good idea. While it perhaps was not the
> best choice for 'user unit' it is what web developers are use to seeing.

We just have to make sure people don't mistake it for "pixel". (or, make
sure the ratios are such that it *is* pixel)
Somehow I remembered vaguely something that "px" actually means "user
unit" in the SVG spec, but I see that this is not true.

>> - bugs related to toplevel width/height specs without units (e.g. in our
>> default document template) or it going out-of-sync with
>> inkscape:document-units.
> I don't really understand the need for 'inkscape:document-units'. Can't
> this be determined by looking at the 'width' and/or 'height'? Then there
> is no problem with keeping things in sync.

Not always. Set the page size to A4 in mm, then change doc units to
something else. The width of the page is still expressed in mm, but the
viewbox is such that document units become whatever you chose. It's hard
to infer from width/height and viewbox what unit was chosen.

>> On 11-9-2014 14:58, Tavmjong Bah wrote:
>>> Changing the "Inkscape GUI unit" should not introduce any 'transforms'
>>> on elements (as seems to being done now)
>> Inkscape is not doing the transforms thing. David Mathog added code that
>> did so, and subsequently removed that code.
> I've just run a test on r12558, which should predate David's code
> changes. If one creates a rectangle inside a document with
>
> inkscape:document-units="mm"
>
> and with the preference setting "Store Transformation" set to
> "Preserve", a scaling transform is added. This is not what I would
> expect.

Just tried it and indeed saw a transform added to the rectangle, but it
was a translate (1.2323e-5, 0). Strange rounding error thingie that
should not be there: bug.

>> On 11-9-2014 14:58, Tavmjong Bah wrote:
>>> <svg width="100mm" height="100mm" viewBox="0 0 100 100">
>>>
>>> describes a drawing 100mm x 100mm where one 'user-unit' is equivalent to
>>> one mm.
>>>
>>> If the Inkscape property inkscape:document-units="mm" then the GUI would show a width of '25.4' for a rectangle 25.4 'user-units' wide. If inkscape:document-units="in", the GUI would show '1.0'.
>> inkscape:document-units is exactly that: *document* units. Not UI
>> units.  Although in practice, the default unit in the UI is taken from
>> inkscape:document-units. If document-units is different from the unit
>> defined by
>>
>> <svg width="..." height="..." viewBox="...">
>>
>> then that is the start of a disaster; it is a bug to allow that to happen.
> It can happen with the XML editor...

Yes. Bug.

>> I do not know why it seems that there is no clear view about how we want
>> units to behave.
>> (sorry, I'm pissed off about again a unit discussion where we have to
>> reiterate the basics)
> Relying on collective memory of long email threads from the past is not the best way to preserve a clear view. Hopefully, the Wiki page I started will help.

Thanks again.

-Johan



------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

Johan Engelen-4
In reply to this post by LucaDC
On 12-9-2014 18:49, LucaDC wrote:

> Tav, I'm a bit confused.
>
>> Changing the Inkscape Document unit should not introduce any transforms
>> on elements nor should changing the SVG root width/height or the viewBox.
> So what should happen to
>
>     <svg width="100mm" height="100mm" viewBox="0 0 100 100">
>
> when the "Inkscape Document unit" is changed to inches?
> Is it going to become
>
>     <svg width="100in" height="100in" viewBox="0 0 100 100">
>
> and hence 1 mm becomes 1 in? If so a 3,937% scaling must be applied to the whole document to get a unit change while preserving the original physical dimensions.

No, the page size should stay the same. One way to do that is to
maintain width=100mm, and recalculate the viewbox (this is what Inkscape
does now). Then indeed all the values in the document should be changed
into inches.

-Johan


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

LucaDC
Johan Engelen-4 wrote
> Tav wrote:
>> Changing the Inkscape Document unit should not introduce any transforms
>> on elements nor should changing the SVG root width/height or the viewBox.

No, the page size should stay the same. One way to do that is to
maintain width=100mm, and recalculate the viewbox (this is what Inkscape
does now). Then indeed all the values in the document should be changed
into inches.
Johan, your reply seems in contradiction with what Tav wrote and that was exactly the point for my question: he is saying that the viewBox should not change.
I still don't understand what he really meant.

About what you wrote, personally I can't see any reason to keep document's width and height specified in a unit different than the document unit and I'd convert them too. I find convenient to have the viewBox always kept in sync with the page width and height so there is a direct link between the document "user unit" and the physical "document unit". If your document has to speak in inches, also the page size should be specified so; and if one specifies an A4 page then wants to draw in inches, I think he should make a choice about where to live... :) I'm probably missing some good examples where this distinction is really needed.

Regards
Luca
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

Johan Engelen-4
On 15-9-2014 11:08, LucaDC wrote:

> Johan Engelen-4 wrote
>>> Tav wrote:
>>>> Changing the Inkscape Document unit should not introduce any transforms
>>>> on elements nor should changing the SVG root width/height or the
>>>> viewBox.
>> No, the page size should stay the same. One way to do that is to maintain width=100mm, and recalculate the viewbox (this is what Inkscape
>> does now). Then indeed all the values in the document should be changed
>> into inches.
> Johan, your reply seems in contradiction with what Tav wrote and that was exactly the point for my question: he is saying that the viewBox should not change.
> I still don't understand what he really meant.

I think Tav meant that no svg::transform things should be added when
a) changing doc units, and also not when b) changing SVG root
width/height/viewbox
With this, I agree.


> About what you wrote, personally I can't see any reason to keep document's width and height specified in a unit different than the document unit and I'd convert them too. I find convenient to have the viewBox always kept in sync with the page width and height so there is a direct link between the document "user unit" and the physical "document unit". If your document has to speak in inches, also the page size should be specified so; and if one specifies an A4 page then wants to draw in inches, I think he should make a choice about where to live... :) I'm probably missing some good examples where this distinction is really needed.

Frankly, I also do not know (or I forgot) why one would not describe the
page size in the chosen document units. Matthew thought things through
pretty thoroughly, so there may be a deeper reason behind why he
implemented it this way. This may be related to 'malformed' documents
put into Inkscape, where user-units and width/height units are already
defined different.

-Johan


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

LucaDC
In reply to this post by Johan Engelen-4
I had the page size specified in px. Changed to mm and width and height become 210mm and 297mm as expected:

   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"

But all the remaining problems in the file are still there (guides in px, rect coords upside-down) so to me Inkscape is not behaving as described.

Luca
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

LucaDC
In reply to this post by Johan Engelen-4
Oh, that's clear now. I missed the "changing" and took it for "change".
Thanks.

Luca
Reply | Threaded
Open this post in threaded view
|

Re: Units in Inkscape

Johan Engelen-4
In reply to this post by LucaDC
On 15-9-2014 11:31, LucaDC wrote:
> I had the page size specified in px. Changed to mm and width and height
> become 210mm and 297mm as expected:
>
>     width="210mm"
>     height="297mm"
>     viewBox="0 0 210 297"
>
> But all the remaining problems in the file are still there (guides in px, rect coords upside-down) so to me Inkscape is not behaving as described.

I'm afraid these fall in the "bugs" category. :(
I meant to say that Inkscape is trying to behave as described.

-Johan


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Inkscape-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-devel
12