Crates.io | irospace |
lib.rs | irospace |
version | 0.0.1 |
source | src |
created_at | 2021-06-27 05:39:44.369359 |
updated_at | 2021-06-27 05:39:44.369359 |
description | color space and conversion method |
homepage | |
repository | |
max_upload_size | |
id | 415368 |
size | 51,101 |
irospaceは、単純な色空間や色空間変換処理を提供するライブラリです。
CSS22 カラーキーワードと同等の色を定義しています。
extern crate irospace;
use irospace::{colors::Colors,
RgbColor,HsvColor,HslColor,
converter::*,
ColorConverterBuilder};
fn from_rgb_to_hsv()
{
let rgb = RgbColor::new(255,0,0);
let converter = ColorConverterBuilder::new().from_rgb().to_hsv().build();
let hsv = converter.convert(&rgb).unwrap();
// HsvColor H = 0 S = 100 V = 100 A = 255
}
fn from_rgb_to_hsl()
{
let rgb = RgbColor::new(255,0,0);
let converter = ColorConverterBuilder::new().from_rgb().to_hsl().build();
let hsl = converter.convert(&rgb).unwrap();
// HslColor H = 0 S = 100 L = 50 A = 255
}
extern crate irospace;
use irospace::{colors::Colors,
RgbColor,HsvColor,HslColor,
converter::*,
ColorConverterBuilder};
fn from_html_to_rgb()
{
let color_code = HtmlColorCode::new("#ff0000");
let converter = ColorConverterBuilder::new().from_html().to_rgb().build();
let rgb = converter.convert(&color_code).unwrap();
println!("{}",rgb);
// RgbColor R = 255 G = 0 B = 0 A = 255
}
fn from_rgb_to_html()
{
let rgb = RgbColor::new(255,0,0);
let converter = ColorConverterBuilder::new().from_rgb().to_html().build();
let html = converter.convert(&rgb).unwrap();
println!("{}",html.value_ref());
// #ff0000
}