1 unstable release

0.0.1 Oct 10, 2020

#7 in #cmyk

MIT license

16KB
358 lines

iro — Representing Colors in Rust

crates.io crates.io crates.io

Goals

  • Representation of colors in different color spaces
  • Conversion of colors between color spaces

and nothing else.

Example

use iro::{Cmyk, CmykInt, Hsl, HslInt, Rgb};

use iro::{Cmyk, CmykInt, Hsl, HslInt, Rgb};

fn main() {
    let color = Rgb::new(85, 191, 100);
    println!("{:?}", &color);
    let color: Cmyk = color.into();
    println!("{:?}", &color);
    let color: CmykInt = color.into();
    println!("{:?}", (color.c, color.m, color.y, color.k));
    println!("{:?}", &color);
    let color = Hsl::from(Rgb::from(color));
    println!("{:?}", &color);
    let color: HslInt = color.into();
    println!("{:?}", &color);
}

// Rgb { r: 85, g: 191, b: 100 }
// Cmyk { c: 0.5549738, m: 0.0, y: 0.47643983, k: 0.25098038 }
// (55, 0, 48, 25)
// CmykInt { c: 55, m: 0, y: 48, k: 25 }
// Hsl { h: 127.42857, s: 0.45064378, l: 0.54313725 }
// HslInt { h: 127, s: 45, l: 54 }

About the name

iro (色) is the Japanese word for "color".

Dependencies

~13KB