简体   繁体   中英

Get the new points in a Snap.svg after a scale and transform

I have declared an SVG group like so:

<g id="group-test">
    <polygon id="polygon-test" fill="#00ff00" points=" 249.60000610351562,90 197.50000762939453,90 171.4000072479248,45 197.4000072479248,0 249.5000057220459,0 275.6000061035156,45 275.5000061020255,45.30000001192093 249.60000610351562,90" />
    <text x="200" y="50" fill="#000000" font-size="14">Xx</text>
</g>

I then set up the group selection with Snap using the parent svg as sn and then animate:

var back = sn.select('#group-test');

setTimeout(function ()
{
    back.animate(
    {
        transform: 's4.06 4.06 t-0.5,34.5'
    },
    1000,
    mina.linear);
},
3000);

But when I do alert($('#polygon-test').attr('points')); I get the original points before the scale. How do I get the new points? Firebug shows the old ones too.

You won't be able to see the transformed points like that, as the points themselves remain untransformed on the element as an attribute.

You would need to pass the points into something to return the transformed points. Snap has such a function..

Snap.path.map( path, matrix );

You can get the matrix, from element.transform().localMatrix

http://snapsvg.io/docs/#Snap.path.map

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM