Hi Heinz,

Heinz Doerr <[email protected]> wrote on 06/09/2009 04:42:49 PM:

> But for a doc w/o a ViewBox specified I need the "size of the
> document". 


> But I have a few questions:
> =====================
> * Overall, how far away is my "90%" solution from 100% ???
>     As I stated - I'm not sure what I'm doing here

   You are close.

> * I'm calling svgElt.getWidth() and getHeight(),
>     Are those values always defined?
>     Are those values always pixel based?

     No, and no, although the majority are pixels (well
unitless which is userspace units).

> * to get the origin of the doc I call  svgElt.getX() and getY(),
>     Is this correct?
>     Are those values always pixel based?

    No, and no, those are supposed to be ignored on the
root SVG element.

> With some help I would surely try to contribute a "98%" solution
> to the community.

   The best way to get the last 8% would be to move to
using 'getBBox()' on the root SVG Element.  This will
tell you the actual size of the geometry in the document.

> 
> [email protected] schrieb: 
> 
> Hi Heinz Doerr,
> 
> Heinz Doerr <[email protected]> wrote on 06/08/2009 06:20:46 AM:
> 
> > I'm using the JSVGCanvas , very nice, but I need to scale the 
displayed SVG
> > image to fit the window size of the canvas.
> > So no scrolling, rotation or panning needed.
> > This should work for any SVG (with or w/o a ViewBox) - changing the 
svg
> > file itself it not an option.
> > The aspect ratio should always be unchanged.
> > Nice, would be to have an option to either scale down only or to allow
> > scale up and down.
> 
>    That is quite a list of requirements. 
> 
> > Because I didn't found any 'scale-to-fit' hints, I was thinking if it
> > would be better to use
> > the BufferedImageTranscoder and convert the svg to an image. The 
transcoder
> > has the scale-to-fit build in (very nice - works with any SVG, keeps 
the
> > aspect ratio), but then I got problems loading some svg's. I'm not 
sure 
> > how to get javascript, onLoad, references to elements, and security 
under 
> > control. Having animation with the Canvas solution would also be a
> nice to have.
> 
>    There are options to run onload scripts before the rendering. 
> 
> > So I think I'm looking for something like an Action AutoFit for the
> > canvas, and this action automatically triggered (at the right time?).
> 
>    What I think will work best is for you to override 
> 'JSVGComponent.calculateViewingTransform' to implement your 
> desired scale to fit algorythem.  If you get it working you 
> might consider contributing it back so others could make use 
> of it. 

Reply via email to