appthere_color/lib.rs
1//! Document-aware color management for Rust.
2//!
3//! `appthere-color` provides pure-Rust ICC color transforms, CMYK support,
4//! soft proofing, and print-ready color policies. It is designed for document
5//! authoring applications that need accurate color management without a C
6//! toolchain dependency.
7//!
8//! # Features
9//!
10//! - **Color value types**: [`RgbColor`], [`CmykColor`], [`LabColor`],
11//! [`XyzColor`], [`GrayColor`], and [`ColorValue`]
12//! - **ICC profile loading**: [`IccProfile`] wrapping `moxcms` for pure-Rust
13//! profile parsing
14//! - **Color transforms**: [`ColorTransform`] builder for profile-to-profile
15//! conversion
16//! - **Soft proofing**: [`ProofingConfig`] with chained two-stage transforms
17//! - **Color policy**: [`ColorPolicy`] and [`OutputIntent`] for document-level
18//! color management
19//!
20//! # ICC Backend
21//!
22//! This crate uses [`moxcms`](https://crates.io/crates/moxcms) exclusively as
23//! its ICC backend. No C toolchain is required — the crate cross-compiles
24//! cleanly to Android, WASM, and musl targets.
25//!
26//! # Feature Flags
27//!
28//! - **`std`** (default): Enables file-path-based profile loading and I/O
29//! error support.
30//! - **`serde`**: Enables `Serialize`/`Deserialize` derives on color types.
31//!
32//! # Example
33//!
34//! ```rust
35//! use appthere_color::{
36//! ColorTransform, IccProfile, RenderingIntent, RgbColor,
37//! };
38//!
39//! // Load profiles
40//! let srgb = IccProfile::new_srgb();
41//! let adobe = IccProfile::new_adobe_rgb();
42//!
43//! // Build a transform
44//! let xform = ColorTransform::builder()
45//! .source(&srgb)
46//! .destination(&adobe)
47//! .intent(RenderingIntent::RelativeColorimetric)
48//! .build()
49//! .unwrap();
50//!
51//! // Transform a color
52//! let input = [1.0_f32, 0.0, 0.0]; // pure red in sRGB
53//! let mut output = [0.0_f32; 3];
54//! xform.transform(&input, &mut output).unwrap();
55//! ```
56
57#![forbid(unsafe_code)]
58#![warn(missing_docs)]
59#![cfg_attr(not(feature = "std"), no_std)]
60
61extern crate alloc;
62
63pub mod color_space;
64pub mod color_value;
65pub mod color_value_ext;
66pub mod error;
67pub mod policy;
68pub mod profile;
69pub mod proofing;
70pub mod proofing_builder;
71pub mod rendering_intent;
72pub mod transform;
73
74// Re-export primary types at crate root for ergonomic access.
75pub use color_space::ColorSpace;
76pub use color_value::{CmykColor, LabColor, RgbColor};
77pub use color_value_ext::{ColorValue, GrayColor, XyzColor};
78pub use error::{ColorError, ColorResult};
79pub use policy::{ColorPolicy, OutputIntent};
80pub use profile::IccProfile;
81pub use proofing::{GamutWarning, ProofingConfig};
82pub use rendering_intent::RenderingIntent;
83pub use transform::ColorTransform;