xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bishop, Michael W. CONTR J9C880" <Michael.Bis...@je.jfcom.mil>
Subject RE: Scaling around a center point...
Date Wed, 07 Dec 2005 18:14:43 GMT
...nevermind, that's not how you get center X/Y.  Now it stays put for
the most part; I'm getting random incorrect translations that I haven't
been able to solve yet.

 

Michael Bishop

 

________________________________

From: Bishop, Michael W. CONTR J9C880
[mailto:Michael.Bishop@je.jfcom.mil] 
Sent: Wednesday, December 07, 2005 12:44 PM
To: batik-users@xmlgraphics.apache.org
Subject: Scaling around a center point...

 

More transform issues!  As you may recall, I add a translate value to
move objects around the canvas.  Now I'm working on scaling and I like
the scale to be uniform around the center of element.  I get the center
point by asking the Element for its bounding box:

 

centerX = boundingBox.getWidth() - boundingBox.getX();

centerY = boundingBox.getHeight() - boundingBox.getY();

 

In the SVG Essentials book I have, it says to scale around a center
point, the translate should be set to:

 

translate(-centerX * (factor - 1), -centerY * (factor - 1))

 

Instead of setting the above, I ADD the above to the existing translate
if one exists.  However, when I scale, the element stays nowhere near
the center point.  I tried simply SETTING the translate values, losing
the previous ones and it's still wrong.  Is there a better technique for
scaling around the center of an element, or is my math just wrong
somewhere?

 

Michael Bishop


Mime
View raw message