I’m trying to change a Graphics
object color after it has been rendered in Pixi JS and I’m struggling way more than I should be. There doesn’t seem to be any examples for this, and the examples for other functions are outdated (API changed since version 8). The only method that seems to work is the tint, but it also doesn’t seem to be a good replacement for color.
I am experienced with Canvas API, so I generally understand the process, and it seems that Pixi is trying to mimic Canvas API with version 8. I need to know the convention for dynamically making updates to Graphics objects, like changing their color and line width.
// JavaScript
import { Application, Graphics, Container } from 'pixi.js';
//
// Application() setup here and init() called
//
// Works:
const object = new Graphics();
object.setStrokeStyle({ color: "#000" });
object.moveTo(50, 50);
object.lineTo(500, 500);
object.stroke();
// Does not work:
object.setStrokeStyle({ color: "#00f" });
object.stroke();