Jump to content
Search Community

SVG Polygon attributes - how to get them faster

wellygirl test
Moderator Tag

Go to solution Solved by PointC,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello, I'm new to GSAP and exploring some animation with an svg low-poly image. I have a LOT of polygons in this image, and wonder if there is a fast way of getting all of the polygon fill colours and points? Am keen to make something like the exploding fox in the attached codepen, BUT don't want to have to manually type in each polygon info.



See the Pen epRVwW by hafizxfattah (@hafizxfattah) on CodePen

Link to comment
Share on other sites

  • Solution

Hi wellygirl :)


Welcome to the GreenSock forum.


Loops, loops, loops.


If you have a lot of paths to go through, that's where loops make your life a lot easier. You'll notice in that pen that they're using jQuery's each() method. That simply loops through all the paths and does something to each of them. You can also use you own for loop to make the same thing happen. In either case, it's pretty easy to perform the same or similar action on a whole lot of paths.


If you have trouble, please put together a demo and we can take a look for you. Here's some more info about that.




Happy tweening.


  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...