Skip to content

4. Color

DenisC edited this page Oct 14, 2023 · 1 revision

The Color class

import { ..., Color } from '../je/index.js'; 

Create color

const color = Color.create(r, g, b);
Color.create(r, g, b, a);

Convert color to string

Color.convert(color);

Create color and convert it.

Color.from(r, g, b);
Color.from(r, g, b, a);

Mix colors

Warning

RGBA colors cannot be mixed.

Color.mix(color1, color2);
Color.mix(color1, color2, 0.2); // 20% of color1, 80% of color2
Color.mix(color1, color2, 0.8); // 80% of color1, 20% of color2

Add alpha to RGB color

Color.alpha(color, a);

Clone this wiki locally