It sounds like you're trying to scale around a certain center point:
 
Given a center point (x,y) and scale values sx, sy, you derive translate values 
tx and ty:
 
tx = -x * (sx - 1.0);
ty = -y * (sy - 1.0);
 
translate(tx, ty);
scale(sx, sy);
 
Michael Bishop 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tue 4/17/2007 4:10 PM
To: [email protected]
Subject: JSVGCanvas.setRenderingTransform()



I hope somebody can shed some light on this. 

Basically, I want to do in software what could be done with a 
control-drag-mousebutton1. Seems like there could be a simple interface to call 
to do this, but I haven't found it yet. 

I'm trying to implement what I call a "pre-zoomed" SVG file. In my SVG file, I 
have added an element <x:defaultpicturesize viewBox="x y w h"/>. 

Since I haven't found a call to "zoom it to this box", I tried using 
setRenderingTransform(). After loading the SVG file (and after 
gvtRenderingCompleted() is called), I look for this element.  If I find one, I 
create an AffineTransform and call setRenderingTransform() 

The problem is that this thing does not do what I expect it to. 

It is easy enough to center up the picture (if that's all I wanted to do). I 
simply calculate the difference between the center of the <svg:svg 
viewbox="..."> and the center of my desired viewbox. This is straightforward 
and produces a view that looks close to centered (but clearly is not exactly 
centered). 

When I apply a scaling transformation things go very off. First of all, scaling 
appears to happen based on the upper left-hand corner of the picture. For 
example, if I only scale (say 2x) what previously was in the upper left-hand 
corner now fills the entire display. 

So I think, translate the upper left-hand corner of the desired viewbox to the 
x and y of the <svg:svg> viewbox and then scale. Still not right. Then I think, 
okay, it's scaling first so my translation values actually need to be 
multiplied by the scale factor - better but still not right. 

What am I missing here? Seems like this should be an easy thing to do. 

Regards, 
Randy

<<winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to