| Crates.io | color-code |
| lib.rs | color-code |
| version | 0.1.0 |
| created_at | 2021-01-16 20:23:41.667538+00 |
| updated_at | 2021-01-16 20:23:41.667538+00 |
| description | A library to work with color |
| homepage | |
| repository | https://github.com/nurmohammed840/color_code.rs |
| max_upload_size | |
| id | 342926 |
| size | 4,992 |
This is a module for rust programing language,To work with color.
// Importing module
extern crate Color;
// Get luminance from RGB
let lum = Color::luminance([255, 255, 255]);
assert_eq!(1.0, lum);
// Create RGB instance from hex value
let rgb = Color::RGB::from_hex("#00ff00").unwrap();
// Get RGB value.
assert_eq!([0, 255, 0], rgb.value());
// Create RGB instance
let mut rgb = Color::RGB([0, 0, 0]);
// Inverted rgb value
rgb.inverted();
assert_eq!([255, 255, 255], rgb.value());
// Convart rgb to hex value
let color_hex = rgb.to_hex();
assert_eq!("ffffff", color_hex);
// Get contrast ratio between two colors.
let contrast = rgb.contrast_ratio([0, 0, 0]);
assert_eq!(21.0, contrast);