PhotonUI logo

PhotonUI

A javascript framework to create user interfaces

Color

photonui.Color is a class that abstracts colors. It supports two colorimetric spaces (RGB and HSL) and multiple representations (hexadecimal, CSS rgb()/rgba(),…).

To see it in action, please look at the photonui.ColorPickerDiaog documentation.

Class Reference

More examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var color = new photonui.Color("red");

console.log(color.rgbHexString);
// "#FF0000"

console.log(color.rgbaHexString);
// "#FF0000FF"

console.log(color.cssRgbString);
// "rgb(255, 0, 0)"

console.log(color.cssRgbaString);
// "rgb(255, 0, 0, 1.00)"

console.log(color.getRGB());
// Array [ 255, 0, 0 ]

console.log(color.getRGBA());
// Array [ 255, 0, 0, 255 ]

console.log(color.red, color.green, color.blue);
// 255 0 0

console.log(color.hue, color.saturation, color.brightness);
// 0 100 100

color.brightness = 50;
console.log(color.rgbHexString);
// "#7F0000"

color.hue = 204;
console.log(color.rgbHexString);
// #004C7F