Re: Coordinates with units

Daniel Holbert <[email protected]> Tue, 4 Apr 2017 09:22:55 -0700
Newsgroups gmane.comp.mozilla.devel.svg
Message-ID <[email protected]>
On 4/4/17 1:30 AM, Christophe DANG NGOC CHAN wrote:
>> The values in the path data are not normal SVG 'length' values --
>> they're more restricted. The syntax is given here, for path data:
>> https://www.w3.org/TR/SVG2/paths.html#TheDProperty
>>
>> In particular, that spec section says: "All coordinates and lengths
>> specified within path data must be treated as being in user units in the
>> current user coordinate system." ("user units" = unitless values)
> 
> OK, but this is SVG2.
> I declared SVG1.1

(SVG2 is just the latest version of the SVG spec, at least from a
browser's perspective. Browsers [Firefox at least, and I think others]
don't change SVG behavior based on the doctype.)

> and I did not see anything like this in the SVG1.1 recommendations,
> but maybe it's hidden in a place where I didn't look at.

It's a bit more buried in that version of the spec -- there's a
definition of the grammar of the afterthought:
https://www.w3.org/TR/SVG11/paths.html#PathDataBNF

> Additionally, I also noticed that the cm -> px conversion ratio was 
> 1 cm = 37.81 px
> whereas it should be 35.43 in SVG1.1, see https://www.w3.org/TR/SVG11/coords.html#Units

The spec says no such thing. You're skipping over some key spec text there.

The conversion ratio depends on many factors (e.g. depends on your
screen size & resolution).  SVG does not define a specific conversion
factor -- the section you're quoting *begins with a hypothetical*:

  # suppose that the user agent can determine
  # from its environment that "1px" corresponds
  # to "0.2822222mm" [...]  Then, for all
  # processing of SVG content:
  # [...]
  #  * "1cm" equals "35.43307px"

So -- this spec text is *just an example*. The "suppose" at the
beginning is very important.

> I tried again and you're right.
> I probably made an error during my trials.
> 
>> Could you link to an actual testcase hosted somewhere on the internet,
>> or post a demo on http://jsfiddle.net/ ? (Note: you can just directly
>> write ... in the HTML box there and it should just work.)
> 
> I don't know that tool, but here it is:
> https://jsfiddle.net/psao0fm4/

OK, it sounds like there's no issue here then.  Thanks for the heads-up
about a potential issue, in any case!