Problem
In PixiJS V8, I get an error when trying to animate the fill color of a PIXI.Graphics using the PixiPlugin.
Example
https://codepen.io/matt-bp/pen/XWQYgVK
Uncomment the second gsap.to to see the error.
My workaround (also for anyone else experiencing this issue)
I'm currently working around this error by creating a color object with three properties (r, g, b), using gsap to animate each color channel individually. I'm then using the onUpdate property in the gsap.to options to update the graphic's fill color and call graphics.fill() to update the color.
// ... Other pixijs setup
const color = {r: 0, g: 0, b: 255};
const target = {r: 100, g: 10, b: 255};
const graphics = new PIXI.Graphics();
graphics.rect(0, 0, 100, 100);
graphics.fillStyle.color = rgbToHex(color.r, color.g, color.b);
graphics.fill();
app.stage.addChild(graphics);
const updateFill = () => {
color.r = Math.floor(color.r);
color.g = Math.floor(color.g);
color.b = Math.floor(color.b);
graphics.fillStyle.color = rgbToHex(color.r, color.g, color.b);
graphics.fill();
};
gsap.to(color, {r: target.r, g: target.g, b: target.b, duration: 2, onUpdate: updateFill, yoyo: true, repeat: -1});
Problem
In PixiJS V8, I get an error when trying to animate the fill color of a
PIXI.Graphicsusing the PixiPlugin.Example
https://codepen.io/matt-bp/pen/XWQYgVK
Uncomment the second
gsap.toto see the error.My workaround (also for anyone else experiencing this issue)
I'm currently working around this error by creating a color object with three properties (r, g, b), using gsap to animate each color channel individually. I'm then using the
onUpdateproperty in thegsap.tooptions to update the graphic's fill color and callgraphics.fill()to update the color.