Skip to main content

Module utils

Module utils 

Source
Expand description

Math and color-space conversions shared by the dynamic color port.

Constants§

WHITE_POINT_D65
The D65 white point in XYZ: white on a sunny day.

Functions§

argb_from_linrgb
Opaque ARGB from linear RGB channels in 0.0..=100.0.
argb_from_lstar
The gray with lightness lstar.
argb_from_rgb
Opaque ARGB from 8-bit channels.
argb_from_xyz
Opaque ARGB from XYZ.
blue_from_argb
The blue channel of an ARGB color.
clamp_double
input limited to min..=max. Unlike f64::clamp this accepts min > max (returning min for anything below it), which the 2025 color spec relies on and which must not panic.
delinearized
A linear RGB channel in 0.0..=100.0 as 8-bit sRGB, clamped.
difference_degrees
The distance of two angles on a circle, in degrees.
green_from_argb
The green channel of an ARGB color.
lab_from_argb
Lab* of an ARGB color.
lerp
start at amount 0 and stop at amount 1.
linearized
An 8-bit sRGB channel as linear RGB in 0.0..=100.0.
lstar_from_argb
L* of an ARGB color.
lstar_from_y
L* of a Y value.
red_from_argb
The red channel of an ARGB color.
rotation_direction
The sign of the shortest rotation from one angle to another; 1 when they are exactly opposite.
sanitize_degrees_double
An angle in 0.0..360.0.
sanitize_degrees_int
An integer angle in 0..360.
signum
-1 below zero, 0 at zero, 1 above zero.
xyz_from_argb
XYZ of an ARGB color.
y_from_lstar
Y in XYZ (relative luminance) of an L* value.