xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G. Wade Johnson" <gwa...@anomaly.org>
Subject Re: Image flipping/mirror
Date Wed, 18 Apr 2007 03:43:52 GMT
On Tue, 17 Apr 2007 09:51:37 -0700 (PDT)
vyang <vyang@apt-cafm.com> wrote:

> 
> Hello,
> 
> Well, I grab the x and y coordinates from the Image element in the
> svg file before and after the transform.  Now that I think about it,
> the x and y coordinates in the svg file doesn't get change during a
> transform.  I've tried your suggestion, for vertical flip I take the
> opposite of y and horizontal the opposite of x.  I'm able to see it
> when its flipped the first time, but its not in its
> orginial(preflipped) position, which I want it to be.  Then when I do
> the same flip it disappears again.  Any thoughts on how to fix this
> problem?

Okay. Now I believe I can help. The "problem" is that scaling changes
both the "size" and the coordinates. The approach I've used in the past
is to decouple these.

Let's say you have an image with a width of 100 and a height of 50 at
10,20 that you want to flip around a vertical axis.

<image x="10" y="20" width="100" height="50" xlink:href="image.png"/>

If you try to scale it with scale(-1,1), you get the equivalent of

<image x="-10" y="20" width="100" height="50" xlink:href="image.png"/>

with the image reversed.

Instead, convert the snippet above to:


<g transform="translate(60,45)">
   <image x="-50" y="-25" width="100" height="50"
          xlink:href="image.png"/>
</g>

Now, you can add a transform="scale(-1,1)" to reverse the image in
place without moving it.

There are probably other ways to do this, but I have found the
technique effective for both scaling and rotations.

G. Wade
-- 
You should never hand someone a gun unless you're sure where they'll
point it.             -- Jeffrey Sinclair in "By Any Means Necessary"

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message