ColorSpace
Mojo struct 🡭
ColorSpace
@memory_only
struct ColorSpaceThe space colors are mixed in: where a blend or a gradient interpolation does its arithmetic.
SRGB, the default, mixes the stored 8-bit channel values directly,
as browsers, Cairo and most raster libraries do; LINEAR converts
each channel through the sRGB transfer function to linear light
first and back afterward, so that a 50% blend of black and white
is the gray that reflects half the light (sRGB 188) rather than
the one halfway up the byte scale (128), and a red-to-green
gradient does not sag through a dark middle. Canvas.set_color_space
and GradientStops.set_color_space choose it; see each for what
it covers.
Aliases
SRGB = ColorSpace(Int(0))LINEAR = ColorSpace(Int(1))
Implemented traits
AnyType, Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, Writable
Methods
__init__
fn def __init__(out self, value: Int)Prefer the comptime constants over constructing one directly.
Args:
- value (
Int): 0 SRGB, 1 LINEAR. - self (
Self)
Returns:
Self
__eq__
fn def __eq__(self, other: Self) -> BoolArgs:
- self (
Self) - other (
Self)
Returns:
Bool
is_linear
fn def is_linear(self) -> BoolWhether this is LINEAR.
Args:
- self (
Self)
Returns:
Bool
write_to
fn def write_to[W: Writer](self, mut writer: W)Parameters:
- W (
Writer)
Args:
- self (
Self) - writer (
W)