- From: Francis Hemsher <fhemsher@gmail.com>
- Date: Sat, 23 Jan 2010 08:11:16 -0500
- 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--- myCurrentCenter.x=myNewCenterX myCurrentCenter.y=myNewCenterY 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 value. 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 element. 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