colori 0.1.1

A simple and basic color conversion and manipulation library
Documentation
  • Coverage
  • 0%
    0 out of 882 items documented0 out of 12 items with examples
  • Size
  • Source code size: 62.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.77 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TorbenKoehn

colori

A rust crate for simple color conversion and manipulation.

Features

  • Color Spaces + Conversion
    • RGB
    • HSL
    • HSV
    • XYZ
    • Lab
  • Color Operations
    • Basic operations on spaces (lightness, saturation, greyscale etc.)
    • Mixing and mixing modes
  • Color Parsing & Output
    • Hex & Integer (RGB)
    • Function Expressions
    • CSS Compatible output
  • Color List (over 800 named color constants)

Install

Add the following to your [dependencies] in Cargo.toml

colori = "0.1"

Usage

Data structures for different color spaces

use colori::{RgbColor, HslColor};

let rgb = RgbColor(255, 0, 80);
rgb.red()    // 255
rgb.green()  // 0
rgb.blue()   // 80


let hsl = HslColor(0.5, 0.4, 1.0);
hsl.hue();       // 0.5
hsl.hue_deg()    // 180
hsl.lightness()  // 0.4
hsl.saturation() // 1.0

Convert different color spaces into each other

use colori::{RgbColor, HslColor};

let hsl: HslColor = RgbColor(255, 0, 0).into();

let rgb: RgbColor = HslColor(0.5, 0.4, 1.0).into();

Access a list of over 800 defined color constants

use colori::{Color};

let rgb = Color::UNITED_NATIONS_BLUE;

println!("R: {}, G: {}, B: {}", rgb.red(), rgb.green(), rgb.blue());