KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D SVG and the "user coordinate system"
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: August 27, 2009

The 4D SVG Component documentation repeatedly mentions the user coordinate system. This term is not defined within those documentations as it is a reference to the general SVG specification.

When SVG is rendered, the SVG user agent determines a viewport (which can be set with the Viewbox attribute or with the initial height and width attibutes of the outermost SVG element). Based on that viewport, an initial viewport coordinate system and an initial user coordinate system are created and they are identical. Initially, one unit in the coordinate system equals one pixel in the viewport.

There is much more detail on this topic in the Coordinate Systems chapter of the w3 SVG Specification. As a 4D developer using 4D SVG it can be important to know how to adjust this user coordinate system. The SVG_SET_VIEWBOX command can be used with the SVG_SET_DIMENSIONS command to acheive this. The following example comes from the documentation for SVG_SET_VIEWBOX:

  `Create an SVG document of 4x8cm
$svg:=SVG_New
SVG_SET_DIMENSIONS($svg;4;8;"cm")
  `Declare the user coordinate system here as 1cm = 50 user points
SVG_SET_VIEWBOX ($svg; 0; 0; 1000; 2000; "true")