On Mon, 02 Apr 2007 12:42:17 +0200, frevi815 <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I've been playing around with svg transformations and would like to
> know if you have any recommendations.
> I have the need to stack several transformations on top of each other
> and I've tried benchmarking SVGMatrix against my own javascript matrix
> class by running a loop several thousand times like this:
>
> for (i=0;i<maxIterations;i++){
> tmp = Math.random();
> matrix.scale(tmp*10).skewX(tmp*11).rotate(tmp*12).skewY(tmp*13);
> }
>
> For maxIterations < 5000 to 6000 SVGMatrix is faster than my
> javascript matrix class but above the javascript version pulls ahead.
Well, if you create your own custom javascript objects they would also be
garbagecollected at some point.
> I guess it's because the SVGMatrix methods returns a new matrix when
> called (and therefore triggers the carbage-collector) while my methods
> alters the current matrix. So I assume that in a somewhat normal
> use-case using SVGMatrix should be the best option?
I would recommend that yes.
> Another question I have is regarding the best way to assign a svg
> element a new SVGMatrix.
> Is something like:
> var e = document.getElementById('erect1');
> e.transform.baseVal.initialize(svg.createSVGTransformFromMatrix(matrix));
Or perhaps:
e.transform.baseVal.setMatrix(matrix);
> faster than?:
> var e = document.getElementById('erect1');
> e.setAttributeNS(null,"transformation",toStringSVGMatrix(matrix));
I would guess not, and if you're doing this in a loop many times then your
first option would probably be faster. And I predict that setMatrix is
faster than both of them.
> (where toStringSVGMatrix is a function that formats the matrix into a
> string)
>
> I would like to avoid the first one as I find it ugly…
I agree, that isn't the best way to do what you want, setMatrix should be
better.
> I've also noticed that SVGMatrix is absent from SVG Tiny 1.2. Is doing
> it yourself in javascript the only option when using SVGT 1.2?
It's not absent, see
http://www.w3.org/TR/SVGMobile12/svgudom.html#svg__SVGMatrix.
The methods available on SVGMatrix are slightly different, except for
inverse(), the mTranslate/mRotate/etc are the mutable counterparts of the
svg 1.1 methods.
Hope this helps
/Erik
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/