SPHPlayground API
SPHPlayground
sphplayground sphplayground

Color manipulation

HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values [1].

RGBA colors

RGB(A) Colors: An RGB color value represents a color in the sRGB color space according to its RED, GREEN, and BLUE components. An optional alpha component represents the color's transparency [2][3][4].

Hex triplet: A hex triplet is a six-digit (or eight-digit) hexadecimal number used in HTML, CSS, SVG, and other computing applications to represent colors [5]. A hexadecimal color is specified with: #RRGGBB(AA) [6].

The RGBA class implements these colors.

Synopsis

class RGBA

HSLA colors

HSLA(A) Colors: HSLA stands for Hue, Saturation, Lightness, and Alpha. This color model extends the HSL format by incorporating transparency control through the alpha channel.[7]

Synopsis

class HSLA

rgba(255, 0, 0, 0.6)
rgba(0, 255, 255, 0.6)
rgba(140, 0, 213, 0.39)

Named colors

HTML comes with 140 named colors. These are special keyword values like black, white, and cyan.These keywords all represent plain, solid colors without transparency [8] [9]. 139 of these colors (and two aliases NamedColor::CYAN and NamedColor::MAGENTA) are implemented in NamedColor Enum.

GOLD
rgba(255, 215, 0, 0.2)

Color palette

The Palette is just an iterable container for color instances. It has an ability to create simple gradients using Palette::gradientBetween() method.

rgb(255, 0, 0)
rgba(245, 0, 21, 0.96)
rgba(236, 0, 43, 0.92)
rgba(226, 0, 64, 0.88)
rgba(217, 0, 85, 0.83)
rgba(207, 0, 106, 0.79)
rgba(198, 0, 128, 0.75)
rgba(188, 0, 149, 0.71)
rgba(178, 0, 170, 0.67)
rgba(169, 0, 191, 0.63)
rgba(159, 0, 213, 0.58)
rgba(140, 0, 255, 0.5)