Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG 1.1 : What is "user unit" and how to convert user unit into absolute unit(eg: millimeter)?

I am implementing SVG Tiny 1.1 and I am having trouble understanding the "user unit" concept.

SVG 1.1 specification defines every <length> with no specified unit (such as "mm", "cm", "pt", etc) to be in "user unit".

While implementing interface "SVGLength", I encountered 4 attributes related to the value of the length; value, unityType, valueInSpecifiedUnit, valueAsString. The last 3 attributes are clear enough for me.

  1. valueInSpecifiedUnit is in unit type unitType.
  2. valueAsString equals valueInSpecifiedUnit+unitType's string value. Eg: "10mm"

However, the attribute value is said to be in user unit. So my questions are:

  1. What is "user unit"?
  2. how to convert from "user unit" to an "absolute unit" such as millimeter (mm) ?

Regards,

like image 684
David Andreoletti Avatar asked Aug 17 '11 03:08

David Andreoletti


People also ask

What is user units in SVG?

So the "user unit" is defined in outmost svg element's width and heigth attributes. Examples: <svg width="20cm" heigth="10cm"> then user unit is "cm". <svg width="200px" heigth="100px"> then user unit is "px".

What is user unit?

Unit User means an individual user of a Licensed Unit who is an officer, director, employee, contractor, representative, or agent of User or User's Affiliate. Sample 1.


1 Answers

The spec says:

user units

A coordinate value or length expressed in user units represents a coordinate value or length in the current user coordinate system. Thus, 10 user units represents a length of 10 units in the current user coordinate system.

Also:

if the ‘width’ or ‘height’ attributes on the outermost svg element are in user units (i.e., no unit identifier has been provided), then the value is assumed to be equivalent to the same number of "px" units

which means that user units are the units specified in the outermost svg element's width and height attributes, and if they are not specified, then user units are pixels.

Read the section on units in SVG.

like image 106
Spadar Shut Avatar answered Sep 27 '22 21:09

Spadar Shut