Import std.math.color
std.math.color
Color and Color32. A Color is four Floats, linear RGB and alpha, for lighting and blending, where math on light is right; a Color32 is four bytes, sRGB and alpha, as images and screens keep them. They convert with sRGB's gamma both ways, so a Color32 made a Color and back is the bytes it was. Hex, HSV, and HSL colors are sRGB's, as CSS's are, with a hue from 0 to 1 around, and OKLab's are from linear RGB. Alpha is linear in both, and 1 or 255 unless it's given.
std/math/color.fb
Types
Color32
struct
Public Struct Color32 Implements Hashable, Printable
Four bytes: sRGB red, green, and blue, and alpha, from 0 to 255.
-
Its red, from 0 to 255.
-
Its green, from 0 to 255.
-
Its blue, from 0 to 255.
-
Its alpha, from 0, transparent, to 255, opaque.
-
No color at all: transparent black.
-
Black.
-
White.
-
Gray, half way between black and white.
-
Red.
-
CSS's green, #008000, half as bright as a screen's green, which is Lime.
-
Lime, green at full strength.
-
Blue.
-
Yellow.
-
Cyan.
-
Magenta.
-
Orange.
-
The color hex
textgives, as CSS writes one: "#rgb", "#rgba", "#rrggbb", or "#rrggbbaa", with or without the "#", in either case. Any other text panics; TryHex takestextfrom outside the program. -
The color hex
textgives, as Hex takes it, or Null fortextthat isn't one. -
The color in linear Floats, through sRGB's gamma.
-
The color as "#rrggbb", lowercase, or "#rrggbbaa" when it isn't opaque.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Color
struct
Public Struct Color Implements Hashable, Printable
Four Floats: linear red, green, and blue, from 0 to 1 for what a screen shows and above for light brighter than white, and alpha, from 0 to 1.
-
Its linear red.
-
Its linear green.
-
Its linear blue.
-
Its alpha, from 0, transparent, to 1, opaque.
-
No color at all: transparent black.
-
Black.
-
White.
-
sRGB's #808080, half gray as a screen shows it, which is less than half the light.
-
Red.
-
CSS's green, #008000, half as bright as a screen's green, which is Lime.
-
Lime, green at full strength.
-
Blue.
-
Yellow.
-
Cyan.
-
Magenta.
-
sRGB's #ffa500, as CSS's orange.
-
The color hex
textgives, as CSS writes one: "#rgb", "#rgba", "#rrggbb", or "#rrggbbaa", with or without the "#", in either case, in sRGB. Any other text panics; TryHex takestextfrom outside the program. -
The color hex
textgives, as Hex takes it, or Null fortextthat isn't one. -
The color whose sRGB red, green, and blue, from 0 to 1, these are, as a screen shows them.
-
Public Static Method Hsv(hue: Float, saturation: Float, value: Float, a: Float = 1): Colorstatic method #The color of an sRGB
hue,saturation, andvalue, each from 0 to 1, as a color picker gives them: a hue outside 0 to 1 goes around. -
Public Static Method Hsl(hue: Float, saturation: Float, lightness: Float, a: Float = 1): Colorstatic method #The color of an sRGB
hue,saturation, andlightness, each from 0 to 1, as CSS's hsl(): ahueoutside 0 to 1 goes around. -
Public Static Method OkLab(lightness: Float, a: Float, b: Float, alpha: Float = 1): Colorstatic method #The color of an OKLab
lightnessandaandb, its green to red and blue to yellow, as Björn Ottosson defined it: a space where equal steps look equal, for blending and ramps. -
The color in sRGB bytes, through sRGB's gamma, each kept from 0 to 255 and NaN taken as 0.
-
The color as "#rrggbb", or "#rrggbbaa" when it isn't opaque, in sRGB, as ToColor32 gives it.
-
The color's sRGB hue, saturation, and value, each from 0 to 1, as Hsv takes them.
-
The color's sRGB hue, saturation, and lightness, each from 0 to 1, as Hsl takes them.
-
The color's OKLab lightness, a, and b, as OkLab takes them.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString. -
cplusd. -
cminusd. -
Each channel times the other's, as light through a filter.
-
ctimesscale. -
scaletimesc.
Functions
Lerp
function
Public Function Lerp(a: Color, b: Color, t: Float): Color
The color t of the way from a to b, each channel in linear light, alpha too.
IsClose
function
Public Function IsClose(a: Color, b: Color): Bool
Whether each channel is close to b's, as IsClose tells for Floats.
Report an issue with this page or with FutureBlitz on GitHub.