Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
wellygirl

SVG Polygon attributes - how to get them faster

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.

 

Thanks!

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

Link to comment
Share on other sites

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.

 

https://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

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.
×