Expand description
Color conversions and types.
This crate is built for the wants and needs of egui.
If you want an actual good color crate, use color instead.
If you want a compact color representation, use Color32.
If you want to manipulate RGBA colors in linear space use Rgba.
If you want to manipulate colors in a way closer to how humans think about colors, use HsvaGamma.
§Conventions
The word “gamma” or “srgb” is used to refer to values in the non-linear space defined by
the sRGB transfer function.
We use u8 for anything in the “gamma” space.
We use f32 in 0-1 range for anything in the linear space.
§Feature flags
Modules§
- color32 🔒
- hex_
color_ 🔒runtime - Convert colors to and from the hex-color string format at runtime
- hsva 🔒
- hsva_
gamma 🔒 - rgba 🔒
Structs§
- Color32
- This format is used for space-efficient color representation (32 bits).
- Hsva
- Hue, saturation, value, alpha. All in the range [0, 1]. No premultiplied alpha.
- Hsva
Gamma - Like Hsva but with the
vvalue (brightness) being gamma corrected so that it is somewhat perceptually even. - Rgba
- 0-1 linear space
RGBAcolor with premultiplied alpha.
Enums§
- HexColor
- A wrapper around Color32 that converts to and from a hex-color string
- Parse
HexColor Error
Functions§
- fast_
round 🔒 - gamma_
from_ linear - linear [0, 1] -> gamma [0, 1] (not clamped). Works for numbers outside this range (e.g. negative numbers).
- gamma_
u8_ from_ linear_ f32 - linear [0, 1] -> gamma [0, 255] (clamped). Values outside this range will be clamped to the range.
- hsv_
from_ rgb - All ranges in 0-1, rgb is linear.
- linear_
f32_ from_ gamma_ u8 - gamma [0, 255] -> linear [0, 1].
- linear_
f32_ from_ linear_ u8 - linear [0, 255] -> linear [0, 1]. Useful for alpha-channel.
- linear_
from_ gamma - gamma [0, 1] -> linear [0, 1] (not clamped). Works for numbers outside this range (e.g. negative numbers).
- linear_
u8_ from_ linear_ f32 - linear [0, 1] -> linear [0, 255] (clamped). Useful for alpha-channel.
- rgb_
from_ hsv - All ranges in 0-1, rgb is linear.
- tint_
color_ towards - Cheap and ugly.
Made for graying out disabled
Uis.