What problem does it solve?
The Color class provides a unified way to create, convert, and manipulate colors for tints, fills, strokes, and ColorSource-compatible APIs in PixiJS v8, simplifying color handling across the engine.
Core Features & Use Cases
- Input formats: accepts hex numbers, hex strings, CSS color names, RGB/RGBA, HSL, and typed arrays, making it easy to convert colors from various sources.
- Conversion methods: supports toHex, toNumber, toArray, toRgba, and more for seamless integration with shaders, textures, and DOM.
- Manipulation and reuse: supports setAlpha, multiply, premultiply, and Color.shared for hot-path operations in real-time rendering.
- Common helpers: isColorLike() as a type guard to validate inputs before constructing Color.
Quick Start
Create a new Color("#ff6600") and use toHex() or toNumber() in your rendering code.