Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG Coordinate System - points vs. pixels

Tags:

xml

svg

Reading through the SVG 1.1 specification, I'm trying to understand the relationship between the units used to define the initial viewport, and the units used throughout the rest of the document.

If a viewport is initially defined using points
<svg width="800pt" height="1002pt" viewBox="0 0 800 1002" version="1.1">
and the rest of the document has no unit identifiers, is it assumed points as well, or does it default to something? As per this part of the spec:

When a coordinate or length value is a number without a unit identifier (e.g., "25"), then the given coordinate or length is assumed to be in user units (i.e., a value in the current user coordinate system).

The SVG document in question has a path with a d value of M 50.91 9.82 L 51.98 10.04 C 53.51 12.71 52.60 16.03 52.75 18.97. I read that as move to (50.91pt, 9.82pt), draw a line to (51.98pt, 10.04pt), and then draw a cubic bezier curve to (52.60pt, 16.03pt).

Is any of this correct?

like image 596
Whymarrh Avatar asked Oct 08 '12 19:10

Whymarrh


1 Answers

You are correct. If the initial width/height is defined in points, and matches the viewbox declaration (which establishes ratio between user units and real sizes), then the default unit for the rest of the doc will be 1pt.

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

(However, I should point out that your interpretation of the cubic bezier curve is not correct - the destination point is 52.75, 18.97 (aka the first two sets of coordinates specify control points, not destination point. Also note that the capital "C" denotes absolute coordinates (vs. small "c" being relative)).

(Also, just being curious - but why are you picking points vs. pixels? That seems a little unusual unless you're planning to do interesting things with text.)

like image 157
Michael Mullany Avatar answered Sep 28 '22 23:09

Michael Mullany