Crates.io | okhsl |
lib.rs | okhsl |
version | 1.0.1 |
source | src |
created_at | 2024-08-29 13:58:18.948129 |
updated_at | 2024-08-30 22:11:59.848389 |
description | Oklab extension for HSL (Okhsl) and HSV (Okhsv) color spaces |
homepage | https://bottosson.github.io/posts/colorpicker/ |
repository | https://gitlab.com/kornelski/oklab |
max_upload_size | |
id | 1356220 |
size | 32,123 |
A simple Rust implementation of Okhsl and Okhsv color conversion routines based on the reference implementation in the blog post.
Okhsl and Okhsv color spaces are meant to have more orhogonal hue, saturation, and lightness than the basic HSL/HSV colors.
use okhsl::*;
let lab = Oklab::from(Rgb {r: 1, g: 127, b: 255});
let Oklab {l, a, b} = lab;
let hsv = Okhsv::from(lab);
let Okhsv {h, s, v} = hsv;
let lab = hsv.to_oklab();
let rgb = hsv.to_srgb();
Oklab components are floats. l
is in range 0 to 1, and a
/b
are small numbers that can be negative.
Okhsv/Okhsl components are floats. HSL values are approximately in range 0 to 1 (inclusive). You can expect to roundtrip Okhsl
⇔Oklab
and Okhsv
⇔Oklab
with little loss of precision.
cargo run -r --example invert -- some_image.jpeg