ph-color 0.1.1

Fixed-point no_std color math for embedded targets: conversion, transfer functions, matrices, gain, and interpolation
Documentation
//! Fixed-point `no_std` color math for embedded targets.
//!
//! This crate applies baked coefficients and tables to typed [`Color`]
//! values: [`Matrix3`] and [`Gain`] apply, [`InterpLut`]/[`Gradient`]
//! interpolation, and [`quantize()`]/[`quantize_round()`]/[`expand`] at the
//! dither seam. It does not derive, invert, adapt, or solve; host derivation
//! lives in `ph-color-bake`. Shipped [`SrgbEotf`]/[`SrgbOetf`] tables cover
//! the sRGB transfer function.
//!
//! `feature = "oklab"` adds linear-sRGB ↔ Oklab conversion via [`Oklab`].
//! `feature = "f32"` adds [`ColorF32`] and `*_f32` apply/lookup/lerp
//! alongside the fixed-point path; Oklab has no `f32` entry points.
//!
//! [`Matrix3`] and [`Gain`] coefficients are [`Q4_28`], not a bare `i32`.
//! [`Color`] channels and interpolation parameters are [`Q0_16`], not a bare
//! `u16`.

#![no_std]
#![forbid(unsafe_code)]
#![deny(missing_docs)]

pub(crate) mod arith;
pub mod chromaticities;
pub mod color;
#[cfg(feature = "f32")]
pub(crate) mod color_f32;
pub mod encoding;
pub mod fixed;
pub mod gain;
pub mod interp;
pub mod matrix;
#[cfg(feature = "oklab")]
pub mod oklab;
pub mod quantize;
pub mod space;
pub mod srgb;

pub use chromaticities::Chromaticities;
pub use color::Color;
#[cfg(feature = "f32")]
pub use color_f32::{ColorF32, F32_MAX_ERR_LSB};
pub use encoding::{Encoded, Encoding, Linear};
pub use fixed::{Q0_16, Q4_28};
pub use gain::Gain;
pub use interp::{Gradient, InterpLut};
pub use matrix::Matrix3;
#[cfg(feature = "oklab")]
pub use oklab::{
    A_B_BIAS_Q428, CBRT, CBRT_MAX_ERR_LSB, OKLAB_FORWARD_MAX_LSB, OKLAB_M1, OKLAB_M1_INV, OKLAB_M2,
    OKLAB_M2_INV, OKLAB_M2_INV_OFFSET, OKLAB_ROUNDTRIP_MAX_LSB, Oklab, oklab_to_srgb,
    srgb_to_oklab,
};
pub use quantize::{expand, quantize, quantize_round};
pub use space::{ColorSpace, Perceptual, Srgb};
pub use srgb::{
    SRGB_EOTF, SRGB_EOTF_MAX_ERR_LSB, SRGB_OETF, SRGB_OETF_MAX_ERR_LSB, SrgbEotf, SrgbOetf,
};