javascript - Resize polygon maintaining position - jQuery -


so have svg has multiple polygons inside, want accomplish animate 1 polygon inside (resize easing) such doesn't move place. considering polygon position set points="..." (i guess..).

i want preferably in jquery or css plain javascript works or other libraries..

here example:

shapes.svg:

<?xml version="1.0" encoding="utf-8"?> <!-- generator: adobe illustrator 19.0.0, svg export plug-in . svg version: 6.00 build 0)  --> <svg version="1.1" id="layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"      viewbox="-47 49 404 404" style="enable-background:new -47 49 404 404;" xml:space="preserve"> <style type="text/css">     .st0{fill:#154e78;}     .st1{fill:#006496;}     .st2{fill:#047ebe;}     .st3{fill:#cd99b2;}     .st4{fill:#d464a4;}     .st5{fill:#cc78b1;} </style> <polygon id="xmlid_14_" class="st0" points="213.4,177 241.1,129 268.9,177 "/> <polygon id="xmlid_13_" class="st1" points="240.2,129 212.4,177 184.7,129 "/> <polygon id="xmlid_15_" class="st2" points="156,177 183.7,129 211.4,177 "/> <polygon id="xmlid_20_" class="st3" points="98.6,177 126.3,129 154,177 "/> <polygon id="xmlid_22_" class="st4" points="41.1,177 68.9,129 96.6,177 "/> <polygon id="xmlid_29_" class="st5" points="125.3,129 97.6,177 69.8,129 "/> </svg> 

preview:
shapes.svg

what want accomplish is:
resized.svg

by resizing 2nd polygon inside svg

i dont have enough reputation show happens if scale 1.3 example, happens polygon moves along artboard.

a simple scale transform (e.g. <polygon id="xmlid_29_" class="st5" points="125.3,129 97.6,177 69.8,129 " transform="scale(1.5)"/>) scale polygon points away origin. want scale polygon points away center of polygon. can accomplish using transform translates polygon center origin, scales, , translates polygon center initial location (e.g. <polygon id="xmlid_29_" class="st5" points="125.3,129 97.6,177 69.8,129 " transform="translate(97.55,153) scale(1.5) translate(-97.55,-153)"/>). in example, using center of polygon's bounding rectangle center of polygon (i.e.(125.3+69.8)/2=97.55, (129+177)/2=153).


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo