W3C home > Mailing lists > Public > www-svg@w3.org > September 2004

WG clarification on getCTM

From: Jonathan Watt <jonathan.watt@strath.ac.uk>
Date: Thu, 9 Sep 2004 16:12:35 +0100 (BST)
To: www-svg@w3.org
Message-ID: <Pine.GSO.4.10.10409091611320.10936-100000@shetland>


I'm doing some work on SVG for Mozilla and I'm looking for clarification
on how getCTM() is supposed to behave, and when the function is useful.
Take the following code for example. 

<svg width="..." height="...">
  <svg x="..." y="..." width="..." height="..." viewBox="..."
    <g transform="...">
      <circle cx="..." cy="..." r="..." transform="..."/>

Initially I thought that if I wanted to move the circle out of the <g>
element and make it a direct child of the inner <svg> element, I could
call getCTM on the circle to obtain the transformation matrix that I would
need to apply to the circle to get the same visual result as I had before
moving its location in the DOM tree. (I.e. in this case the combination of
the transform attributes on the <g> and the <circle> elements.) However,
the spec says that getCTM returns the transformation matrix "from current
user units (i.e., after application of the transform attribute, if any) to
the *viewport* coordinate system for the nearestViewportElement", not the
*user* coordinate system for the nearestViewportElement. When the spec
says "viewport" does it really mean "user"? Otherwise how is getCTM
useful? What use is a transform to the coordinate system that that exists
after the translation caused by the x and y attributes on the inner <svg>
element have been applied, but before the coordinate system is turned into
the user coordinate system by application of the viewBox and
preserveAspectRatio attributes? 

The above was in the context of a graphic element, but I'm also unclear
about things in the context of SVGSVGElement. I would like to be able to
use getCTM and nearestViewportElement to drill up through the parent chain
combining CTMs to obtain a transformation matrix from one <svg> element to
its Nth parent <svg> element. However, again because the spec says that
getCTM returns the transformation matrix from current user space to the
nearest viewport element's *viewport* space, getCTM doesn't seem to be
able to be used for this. It would need to get the transform from one user
space to the other user space. 

Furthermore, should getCTM on an inner <svg> give you the transform from
the nearest outer viewport to the userspace that the inner svg element is
located *in*, or the userspace that is created by its viewBox attribute?
I.e. do the x, y, width, and height attributes of the inner <svg> element
affect the matrix returned when getCTM is called on it? I'm not sure if by
saying "after application of the transform attribute, if any" also means
"after application of the viewbox attribute, if any" since 'viewBox' is to
elements that establish a new viewport what 'transform' is to graphic

Comments on any part of this would be most welcome. 

Received on Thursday, 9 September 2004 15:12:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:02 UTC