Jump to content


Animated SVG stroke to reveal an image?

Moderator Tag

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

I've spent the day testing various methods to get an SVG stroke animation to reveal an image but i've come up with nothing. I've used GSAP to animate SVG's as masks, but i've never attempted to do a stroke animation to act as a mask. I've done this millions of times in After Effects, but just can't seem to wrap my head around this - if its even possible. 


In this basic pen i've placed a random image below an SVG stroke animation. Anyone know if this is even possible?

See the Pen mGqLVZ by djmatix (@djmatix) on CodePen

Link to comment
Share on other sites

Hi @digableinc :)


Welcome to the forum and thanks for joining Club GreenSock.


I'm a fellow AE user too. Masking an image is no problem. The easiest way would be to add the image to your SVG (so it scales nicely) and then create a mask for it. Mask color is important. White will show everything. Black will hide everything. You can use gradients in masks too. Here's a fork of your pen:



See the Pen PdOeaN by PointC (@PointC) on CodePen


We had another question recently about showing a full screen background image and this was my mask solution for that thread:


See the Pen xJNWez by PointC (@PointC) on CodePen


Here's a good resource for some additional learning about masks and clip-paths.



Hopefully that helps. Happy tweening and welcome aboard.



  • Like 4
Link to comment
Share on other sites

Wow that is exactly what I was looking to do! Your note about being able to use gradients in masks is interesting. Applying a gradient to the path would allow for a softer path reveal instead of a hard edge. Going to have to look into that. Thanks for the quick response!

  • Like 2
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.