Skip to main content

color_convert_rs/
lib.rs

1//! A behavior-faithful Rust port of the npm [`color-convert`](https://github.com/Qix-/color-convert)
2//! library — CPU-SIMD accelerated with optional GPU (CubeCL) and npm drop-in
3//! replacement (wasm-pack) paths.
4//!
5//! # Quick start
6//!
7//! ```
8//! use color_convert_rs::{Color, Model, convert_rounded};
9//!
10//! let orange = Color::Rgb([255.0, 128.0, 0.0]);
11//! let lab = convert_rounded(Model::Rgb, Model::Lab, orange).unwrap();
12//! assert_eq!(lab, Color::Lab([67.0, 43.0, 74.0]));
13//! ```
14//!
15//! # Features
16//!
17//! - **`gpu`** *(optional)*: CubeCL/wgpu GPU compute kernels with runtime
18//!   capability probe. Without this feature, `probe()` always returns
19//!   [`Backend::CpuSimd`].
20//! - **`wasm`** *(optional)*: wasm-bindgen exports for building the npm
21//!   drop-in replacement via `wasm-pack build --target nodejs --features wasm`.
22//!
23//! # Public API
24//!
25//! - [`convert`] / [`convert_rounded`]: single-color any-to-any conversion
26//! - [`Model`]: the 17 supported color models
27//! - [`Color`]: the color value type (array or string depending on model)
28//! - [`Error`]: the library error type
29//! - `simd::*_batch`: vectorized f32x8 SIMD batch functions for hot routes
30//! - [`probe`] / [`gpu_present`] / [`Backend`]: runtime GPU capability probe
31
32pub mod ansi16;
33pub mod ansi256;
34pub mod apple;
35pub mod batch;
36pub mod cmyk;
37mod color_name;
38pub mod convert;
39mod error;
40#[cfg(feature = "gpu")]
41pub mod gpu;
42pub mod gray;
43pub mod hcg;
44pub mod hex;
45pub mod hsl;
46pub mod hsv;
47pub mod hwb;
48pub mod keyword;
49pub mod lab;
50pub mod lch;
51#[cfg(feature = "napi")]
52pub mod napi;
53pub mod oklab;
54pub mod oklch;
55pub mod probe;
56pub mod rgb;
57pub mod simd;
58pub mod simd_apple;
59pub mod simd_cmyk;
60pub mod simd_hcg;
61pub mod simd_hsl;
62pub mod simd_hsv;
63pub mod simd_hsv_rgb;
64pub mod simd_hwb;
65pub mod simd_lab_xyz;
66pub mod simd_oklab;
67pub mod simd_oklab_rgb;
68pub mod simd_parallel;
69pub mod simd_xyz;
70pub mod xyz;
71
72pub use convert::{Color, Model, convert, convert_rounded};
73pub use error::Error;
74pub use probe::{Backend, gpu_present, probe};