# ph-color
Fixed-point `no_std` color math for embedded targets.
[](https://crates.io/crates/ph-color)
[](https://docs.rs/ph-color)
> [!NOTE]
> **Lifecycle:** Active
> **Distribution:** Version `0.1.1` on
> [crates.io](https://crates.io/crates/ph-color), with API documentation on
> [docs.rs](https://docs.rs/ph-color).
> **Model conformance:** N/A
> **Physical evidence:** N/A
This package applies baked coefficients and tables. It does not derive,
invert, adapt, or solve. Host derivation lives in `ph-color-bake`.
```toml
[dependencies]
ph-color = "0.1"
```
```rust
use ph_color::{Color, Linear, Q0_16, Srgb};
let black = Color::<Srgb, Linear>::new([Q0_16::ZERO; 3]);
let white = Color::<Srgb, Linear>::new([Q0_16::ONE; 3]);
let midpoint = black.lerp(white, Q0_16::from_raw(32_768));
assert!(midpoint.ch[0].to_raw() >= 32_768);
```
The crate currently exposes `quantize` / `quantize_round` / `expand`, `Color`
type-state, numeric `Matrix3` / `Gain` apply, `InterpLut`, `lerp`, `Gradient`,
shipped sRGB EOTF/OETF `InterpLut` constants, feature `oklab` (linear-sRGB ↔
Oklab), and optional `feature = "f32"` (`ColorF32` and `*_f32`). Oklab `f32` is
out of scope. Host `ph-color-bake` derives tables. Frozen golden vectors in
`tests/golden/` are replayed by host tests. Named-consumer host sketches are
in [`examples/`](examples/). Numeric and type-state guarantees are in the
[repository numeric policy](https://github.com/photon-circus/ph-color/blob/main/docs/NUMERICS.md).
## Compatibility and limits
- MSRV: Rust 1.94.0, edition 2024.
- Default build: `no_std`, no allocation, no unsafe code, no `f64`, and zero
dependencies.
- Optional features: `f32` and `oklab`; Oklab has no `f32` entry points.
- Fixed-point matrix and gain output uses one widening accumulation followed by
round-half-away-from-zero and saturation. It never wraps.
- Matrices and gains accept linear colors; transfer LUTs cross linear/encoded
state; encoded interpolation is limited to perceptual color spaces.
- Color processing stops at quantization. Zero-parameter round-to-nearest is
provided; firmware owns custom thresholds, masks, positional or frame state,
dithering, residual accumulation, output packing, and hardware I/O.
## License
MIT