Hi, achio-
achio_84 wrote:
|
| Hi all...
| I would like to ask whether it is possible to combine
| transform (scale)
| and transform (translate) in 1 javascript statement?
| For example:
|
| shape1.setAttributeNS(null,"transform","scale("+scaleLevel+")");
| shape1.setAttributeNS(null,"transform","translate
| ("+positionx+","+positiony+")");
|
| Is there a way to combine both statement stated above to become 1
| statement? Coz after I scale the shape, and translate it, the scale
| change to it default value again... I don't know why....
An attribute value is a string, not a function. Thus, in order to have both
transformations active, you must concatenate them.
shape1.setAttributeNS(null, "transform","scale("+scaleLevel+")
translate("+positionx+","+positiony+")");
or, to make it a little more managable
var transformStr = "scale("+scaleLevel+")
translate("+positionx+","+positiony+")";
shape1.setAttributeNS(null, "transform", transformStr);
These will both end up as e.g.:
<circle cx="5" cy="55" r="20" transform="scale(2) translate(100,30)" />
Note that you will get different results depending on the order of these
transform commands. If translate is after scale, you will multiply the
parameters of translate by the parameters of the scale (e.g. in the above
example, it would be the equivalent of doubling the translate parameters, or
the same as saying transform="translate(200,60) scale(2)").
Regards-
Doug
-----
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/
<*> 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/