Color¶
This page contains classes defined in hakowan.common.color module.
ColorLike = float | int | str | tuple | list
module-attribute
¶
Color-like type alias is types that can be converted to a color.
Color
¶
A minimal representation of color.
Source code in hakowan/common/color.py
red
property
¶
Red channel.
green
property
¶
Green channel.
blue
property
¶
Blue channel.
data
property
¶
Raw RGB data as a numpy array.
from_hex(hex_color)
classmethod
¶
Construct color from hex.
__init__(red=0.0, green=0.0, blue=0.0)
¶
__getitem__(i)
¶
__add__(other)
¶
__mul__(scale)
¶
__rmul__(scale)
¶
__eq__(other)
¶
__ne__(other)
¶
__iter__()
¶
srgb_to_linear(c)
¶
Convert a single sRGB-encoded channel value in [0, 1] to linear RGB.
Color names, hex strings, and user-specified floats follow the sRGB
convention, while renderers shade in linear space (Mitsuba's rgb
spectrum and three.js both interpret their inputs as linear). Decode at the
backend boundary so colors render consistently and physically correctly.
Source code in hakowan/common/color.py
linear_to_srgb(c)
¶
Convert a single linear RGB channel value in [0, 1] to sRGB-encoded.
Inverse of :func:srgb_to_linear.
srgb_to_linear_array(c)
¶
Vectorised :func:srgb_to_linear over an arbitrary-shape float array.
Values are clipped to [0, 1]; the output preserves the input dtype.