Skip to main content

Crate wassily_color

Crate wassily_color 

Source
Expand description

§Wassily Color

Color utilities and palette management for the wassily generative art library. This crate provides comprehensive color manipulation tools including color space conversions, palette extraction from images, procedural color generation, and advanced color operations specifically designed for generative art applications.

§Key Features

  • Rich Color Spaces: Support for RGB, HSL, HSV, Okhsl, Lab, and many more
  • Palette Management: Create, manipulate, and extract color palettes
  • Named Colors: Complete set of HTML/CSS color names
  • Procedural Generation: Generate random colors in perceptually uniform spaces
  • Image Extraction: Extract dominant colors from images
  • Advanced Operations: Color blending, scaling, and fourier-based palettes

§Modules

  • color_names: Pre-defined HTML/CSS color constants
  • color_palette: Palette management and color scaling functions
  • color: Core color utilities, conversions, and generation functions

§Quick Start

use wassily_color::*;
use tiny_skia::Color;

// Use named colors
let blue = *CORNFLOWERBLUE;
let red = *CRIMSON;

// Create random colors in perceptually uniform space
let mut rng = rand::thread_rng();
let random_color = rand_okhsl(&mut rng);

// Create a color palette
let palette = Palette::new(vec![blue, red, random_color]);

// Create a color scale for smooth transitions
let scale = ColorScale::new(blue, red, *WHITE, *BLACK, random_color);
let interpolated = scale.get_color(0.5);

§Color Spaces

This crate emphasizes modern, perceptually uniform color spaces:

  • Okhsl/Okhsv: Perceptually uniform HSL/HSV variants
  • Lab/Lch: Perceptually uniform lightness and chroma
  • Traditional: RGB, HSL, HSV for compatibility

§Advanced Features

  • Fourier Color Scales: Mathematically smooth color transitions
  • Image Color Extraction: Dominant color extraction from images
  • Procedural Color Generation: Noise-based and algorithmic color creation
  • Color Harmony: Tools for creating harmonious color relationships

Re-exports§

pub use color_names::*;
pub use color_palette::*;
pub use color::*;

Modules§

color
Color Utilities
color_names
HTML Color Names
color_palette
Color Palettes and Scaling

Structs§

Hsl
HSL color space.
Hsluv
HSLuv color space.
Hsv
HSV color space.
Hwb
HWB color space.
Lab
The CIE L*a*b* (CIELAB) color space.
Lch
CIE L*C*h°, a polar version of CIE L*a*b*.
Okhsl
A Hue/Saturation/Lightness representation of Oklab in the sRGB color space.
Okhsv
A Hue/Saturation/Value representation of Oklab in the sRGB color space.
Okhwb
A Hue/Whiteness/Blackness representation of Oklab in the sRGB color space, similar to Hwb.
Oklab
The Oklab color space.
Oklch
Oklch, a polar version of Oklab.
Xyz
The CIE 1931 XYZ color space.

Traits§

Lighten
Operators for lightening a color.
ShiftHue
Operator for increasing or decreasing the hue by an amount.

Type Aliases§

Hsla
Linear HSL with an alpha component. See the Hsla implementation in Alpha.
Hsluva
HSLuv with an alpha component. See the Hsluva implementation in Alpha.
Hsva
Linear HSV with an alpha component. See the Hsva implementation in Alpha.
Hwba
Linear HWB with an alpha component. See the Hwba implementation in Alpha.
Laba
CIE L*a*b* (CIELAB) with an alpha component. See the Laba implementation in Alpha.
Lcha
CIE L*C*h° with an alpha component. See the Lcha implementation in Alpha.
Okhsla
Okhsl with an alpha component.
Okhsva
Okhsv with an alpha component. See the Okhsva implementation in Alpha.
Okhwba
Okhwb with an alpha component. See the Okhwba implementation in Alpha.
Oklaba
Oklab with an alpha component.
Oklcha
Oklch with an alpha component. See the Oklcha implementation in Alpha.
Srgb
Non-linear sRGB, the most common RGB input/output format.
Srgba
Non-linear sRGB with an alpha component.
Xyza
CIE 1931 XYZ with an alpha component. See the Xyza implementation in Alpha.