jjPALCOLOR class by value JJ2+

A single color of a palette or a 32-bit image

Red, green and blue components, plus alpha used only by 32-bit images. Also provides conversions to and from hue, saturation and lightness.

Constructors

jjPALCOLOR() C++
Creates a black color with all components 0
jjPALCOLOR(uint8 red, uint8 green, uint8 blue) C++
Creates a color from red, green and blue components, alpha is 0
jjPALCOLOR(uint8 red, uint8 green, uint8 blue, uint8 alpha) C++
Creates a color from red, green, blue and alpha components

Functions

uint8 getHue() const C++
Returns the hue of the color, 0 to 255 for a full circle
uint8 getLight() const C++
Returns the lightness of the color, from 0 (black) to 255 (white)
uint8 getSat() const C++
Returns the saturation of the color, from 0 (gray) to 255
void setHSL(int hue, uint8 sat, uint8 light)
Sets the color from hue, saturation and lightness
void swizzle(COLOR::Component red, COLOR::Component green, COLOR::Component blue)
Rearranges the color components

Operators

jjPALCOLOR& opAssign(const jjPALCOLOR&in other) = C++
Copies all four components of another color
bool opEquals(const jjPALCOLOR&in other) const == C++
Returns whether two colors have the same red, green and blue components, alpha isn't compared

Properties

uint8 alpha
Alpha component, 0 to 255
uint8 blue C++
Blue component, 0 to 255
uint8 green C++
Green component, 0 to 255
uint8 red C++
Red component, 0 to 255

Function documentation

void jjPALCOLOR::setHSL(int hue, uint8 sat, uint8 light)

Sets the color from hue, saturation and lightness

All three are on a 0 to 255 scale. The hue wraps around, so values outside that range are valid, e.g. 258 and -254 equal 2.

void jjPALCOLOR::swizzle(COLOR::Component red, COLOR::Component green, COLOR::Component blue)

Rearranges the color components

Each parameter names the COLOR::Component whose current value goes into red, green and blue respectively, e.g. swizzle(COLOR::BLUE, COLOR::GREEN, COLOR::RED) swaps red and blue. Alpha isn't changed, and COLOR::ALPHA as a source leaves that component as it is.

Property documentation

uint8 jjPALCOLOR::alpha

Alpha component, 0 to 255

Only colors of 32-bit images (jjCOLORMAP) use it; palettes ignore it and usually leave it at 0.