W3C home > Mailing lists > Public > www-svg@w3.org > January 2010

Re: DOM APIs - Get & Set Element Center Point

From: Francis Hemsher <fhemsher@gmail.com>
Date: Sat, 23 Jan 2010 08:11:16 -0500
Message-ID: <c41bcc9d1001230511p20d30531uc6a5e8b0e65ed82@mail.gmail.com>
To: www-svg@w3.org
A developer who dynamically positions the location of elements is
continually computing the center point of the element: Generally via
the bounding box location and size. That center point is then used to
re-compute the element's  new x,y values based on the offset values
from a previous center point location. This transcends a typical
translate(x,y) request, because it maintains true x,y values of the
element. Which can then be used with impunity when requesting further
changes of the element's x,y values.

Therefore I'm suggesting the following:

var myCurrentCenter=mySVGelement.getCCP() //---get current center point---
var myCenterX=myCurrentCenter.x
var myCenterY=myCurrentCenter.y
//----change mySVGelement location---

By requesting the above, the element is rebuilt with new x,y values
causing it to be natively placed with a new center point at the set

This feature becomes most meaningful when building symbol elements,
and elements that will be used in other applications. By requesting an
element to have its current center at the origin(0,0) we can build
symbols with elements centered at the origin. Therefore any x,y
location or transformation request of <use> elements, based on that
symbol, will always be the center of the use.
Also, If we have an element in one application that has been
'centered' at the origin, then we can position it in another
application by setting its center point as needed.

This also makes transforms of skew, rotation, and scale simpler
because they can be focused, intuitively, at the  center of the

Ideally, this would also apply to all children of an element, such as
the elements within a <g> element.
Received on Saturday, 23 January 2010 13:11:48 UTC

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