W3C home > Mailing lists > Public > www-svg@w3.org > February 2003

RE: getScreenCTM (again)

From: Thomas E Deweese <thomas.deweese@kodak.com>
Date: Thu, 6 Feb 2003 17:42:31 -0500
Message-ID: <15938.58583.54185.568828@frog.rl.kodak.com>
To: Sigurd Lerstad <sigler@bredband.no>
Cc: www-svg@w3.org

Hello Sigurd,

    Sorry for the delay.

>>>>> "SL" == Sigurd Lerstad <sigler@bredband.no> writes:

> >  When calling getScreenCTM on an svg element, will it take into
> >  account any transformation done on the children of that svg element
> >  due to viewBox?
> >
> >  I'm asking, because a viewBox attribute doesn't transform the svg
> >  element itself (i.e the x,y,width/height of the svg element) only the
> >  children.

  The 'getScreenCTM' function on an svg element should take into
account the effects of viewBox and preserveAspectRatio.  This is taken
from the fact that 'getScreenCTM' (Section 4.3 - SVGLocatable) says:

         Returns the transformation matrix from current user units
         (i.e., after application of the transform attribute, if any)
         to the parent user agent's notice of a "pixel".

and the definition of 'The viewBox attribute' (Section 7.7):

         The value of the viewBox attribute is a list of four numbers
         <min-x>, <min-y>, <width> and <height>, separated by
         whitespace and/or a comma, which specify a rectangle in user
         space which should be mapped to the bounds of the viewport
         established by the given element,

Additionally the last paragraph in Section 7.7:

         Unlike the transform attribute (see effect of the transform
         on sibling attributes), the automatic transformation that is
         created due to a viewBox does not affect the x, y, width and
         height attributes (or in the case of the 'marker' element,
         the markerWidth and markerHeight attributes) on the element
         with the viewBox attribute. Thus, in the example above which
         shows an 'svg' element which has attributes width, height and
         viewBox, the width and height attributes represent values in
         the coordinate system that exists before the viewBox
         transformation is applied. On the other hand, like the
         transform attribute, it does establish a new coordinate
         system for all other attributes and for descendant elements.

Together these make it clear that the user space for the SVG element
is the coordinate system after accounting for 'viewBox'.  While you
are correct that x,y,width,height are not defined in this coordinate
system the last paragraph in 7.7 makes it clear that these are the odd
attributes.  Thus 'getScreenCTM' on an SVG element should include any
effects on the coordinate system from the 'viewBox' and
'preserveAspectRatio' attributes

SL> Wouldn't it be more useful if getBBox returned the bounding box
SL> BEFORE any transform, since you can always apply that afterwards
SL> to the BBox, but you can't unapply it. (or am I missing
SL> something?)

    You can generally apply the inverse of the transform.
Received on Thursday, 6 February 2003 17:42:46 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:29:19 UTC