color-code

Crates.iocolor-code
lib.rscolor-code
version0.1.0
created_at2021-01-16 20:23:41.667538+00
updated_at2021-01-16 20:23:41.667538+00
descriptionA library to work with color
homepage
repositoryhttps://github.com/nurmohammed840/color_code.rs
max_upload_size
id342926
size4,992
Nur (nurmohammed840)

documentation

README

This is a module for rust programing language,To work with color.

API

// 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);
Commit count: 0

cargo fmt