colorconv 0.1.1

color conversion library
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented4 out of 4 items with examples
  • Size
  • Source code size: 246.63 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.64 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kyoheiu/colorconv
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kyoheiu

colorconv

This crate provides some features to convert color code, RGB or color name(if exists) to struct Color which holds the color information.

What makes this crate (kind of) unique is that it supports the color name conversion. For example:

use colorconv::Color;
use std::str::FromStr;

match Color::from_str("yale blue") {
    Ok(color) => assert_eq!(color.hex, "0f4d92".to_string()),
    Err(e) => eprintln!("{:?}", e),
}

This conversion is based on https://github.com/jonathantneal/color-names.

Also, you can convert a color code or RGB:

use colorconv::Color;
use std::str::FromStr;

if let Ok(rusty_red) = Color::from_str("da2c43") {
    assert_eq!(Some("rusty red".to_string()), rusty_red.name);
}

let true_blue = Color::from([0, 115, 207]);
assert_eq!("0073cf".to_string(), true_blue.hex);