1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Color representations and conversions.
//!
//! `gem` is organized into two complementary layers:
//!
//! - **Pixel formats** (`rgb`, `gray`, `alpha`): zero-cost, memory-layout-accurate types
//! for GPU buffers, PNG encoding, and hardware interop. These are `no_std`-compatible
//! and work without any math at all.
//!
//! - **Color spaces** (`space`, `named`, `blend`): perceptual and working-space types
//! for manipulation, interpolation, and compositing. These are also `no_std`-compatible
//! but see the [`space`] module documentation for accuracy notes.
//!
//! ## Quick start
//!
//! ```rust
//! use gem::prelude::*;
//! use gem::space::{Hsl, Srgb};
//! use gem::rgb::Rgb888;
//!
//! // Start with a pixel format color
//! let pixel = Rgb888::from_rgb(200, 50, 100);
//!
//! // Convert to a color space, manipulate, convert back
//! let hsl = Hsl::from(Srgb::from(pixel));
//! let lighter: Rgb888 = Srgb::from(hsl.lighten(0.15)).into();
//! assert!(lighter.red() >= pixel.red() || lighter.green() >= pixel.green());
//! ```
//!
//! ## Features
//!
//! | Feature | Description |
//! |---------|-------------|
//! | `bytemuck` | Derives `Pod`/`Zeroable` for all pixel format types, enabling zero-copy buffer casting |
//! | `std` | Enables accurate gamma correction (`x^2.4`) and Oklch trig conversions |
extern crate std;