palette

Type-safe Rust library for correct linear color calculations and conversion across color spaces.

Library
Cargo
v0.7.7
836stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
56/100Fair
Development Activity60
Maintenance24
Community52
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture92
Code Quality90
Innovation88
Learning Curve60

Palette is a Rust color management and conversion library built around correctness, flexibility, and ease of use. It leans heavily on the type system to make invalid color operations unrepresentable, letting you convert between a wide range of color spaces such as RGB, HSL, HSV, Lab, Luma, and CAM16 while keeping track of encoding, white point, and component types at compile time.

Designed for graphics, image processing, and generative work, Palette supports linear-light calculations, blending, gradients, and user-defined color spaces. It is no_std-capable and integrates cleanly with other crates through optional feature-gated conversions and traits.

What You Get

  • A broad set of built-in color spaces including RGB, HSL, HSV, HWB, Lab, Lch, Luma, XYZ, Yxy, Oklab, and CAM16
  • Type-safe encoding and white-point tracking that prevents mixing incompatible color representations
  • Correct linear-light blending, mixing, and gradient interpolation
  • Named color constants and parsing from CSS-style names
  • no_std support and optional integration features for other libraries
  • Extensible traits for defining custom color spaces and component types

Common Use Cases

  • Converting between color spaces while preserving perceptual correctness
  • Blending and interpolating colors in linear light for gradients and animations
  • Building generative art and data visualizations with accurate color math
  • Processing image pixels with explicit control over encoding and gamma

Under The Hood

Architecture - Palette is a Cargo workspace whose core palette crate is organized by color space, with per-space modules (rgb, hsl, lab, cam16, luma, and many more) alongside cross-cutting concerns like blend, alpha, angle, bool_mask, and convert. A palette_derive proc-macro crate and a palette_math crate support code generation and numeric routines, and a codegen crate produces lookup tables. Tech Stack - Pure Rust, edition 2021, MSRV 1.71, with an extensive feature matrix (std, approx, named, phf, serde, libm, SIMD) enabling no_std and selective integrations. Code Quality - Roughly 134 source files with dedicated integration_tests and regression tests, benchmarks, and a no_std test crate; correctness is enforced structurally through the type system rather than runtime checks. API Design - Conversions are expressed through generic FromColor/IntoColor traits so pipelines read declaratively, and strongly-typed markers for encoding and white point catch mistakes at compile time at the cost of a steeper initial learning curve.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search