Jump to content
Search Community

HSL tween

benoit test
Moderator Tag

Recommended Posts

Hi Benoit,

 

GSAP's PixiPlugin can actually animate HSL without the need of a helper function:

gsap.to(graphics, {duration: 2, pixi: {tint: "hsl(0, 100%, 50%)"}});

And also you can tween the fill color like this:

const rect = new PIXI.Graphics();
rect.beginFill(0xff00ff);
rect.drawRect(0, 0, 200, 100);
rect.endFill();

const colors = [0xff0000, 0x0000ff];

gsap.timeline({
  defaults: {
    duration: 1,
    ease: "none",
  },
  repeat: -1,
  yoyo: true,
})
  .to(rect, {
  pixi: {
    fillColor: colors[0]
  }
})
  .to(rect, {
  pixi: {
    fillColor: colors[1]
  }
});

app.stage.addChild(rect);

Be sure to take a peak at the PixiPlugin docs:

https://greensock.com/docs/v3/Plugins/PixiPlugin

 

And the examples in PIXIJS for GSAP:

https://pixijs.io/examples/#/gsap3-interaction/gsap3-tint.js

 

Hopefully this helps.

 

Happy Tweening!

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