Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Sep 23, 2024
1 parent 0cc8e2a commit fe5706b
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 10 deletions.
29 changes: 28 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["src/app"] }

[package]
name = "colorutils-rs"
version = "0.5.10"
version = "0.5.11"
edition = "2021"
description = "High performance utilities for color format handling and conversion."
readme = "README.md"
Expand Down
Binary file added assets/beach_horizon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ edition = "2021"
[dependencies]
colorutils-rs = { path = "../../" }
image = "0.25.1"

okhsl = "1.0.1"
14 changes: 7 additions & 7 deletions src/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ pub const fn shuffle(z: u32, y: u32, x: u32, w: u32) -> i32 {
}

fn main() {
let r = 42;
let g = 255;
let b = 62;
let r = 255;
let g = 0;
let b = 0;
let rgb = Rgb::<u8>::new(r, g, b);
let xyb = Xyb::from_rgb(rgb, TransferFunction::Srgb);
println!("xyb {:?}", xyb);
let restored_rgb = xyb.to_rgb(TransferFunction::Srgb);
println!("restored {:?}", restored_rgb);
// let xyb = Okhsv::from_oklab(rgb.to_oklab(TransferFunction::Srgb));
// println!("xyb {:?}", xyb);
let hsv_new = okhsl::Okhsv::from(okhsl::Rgb::new(255, 0, 0));
println!("hsv {:?}", hsv_new);
// let restored = lalphabeta.to_rgb(TransferFunction::Srgb);
// println!("Restored RGB {:?}", restored);

Expand Down
1 change: 1 addition & 0 deletions src/hsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
use crate::rgb::Rgb;

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
/// Represents *HSL* (hue, saturation, lightness) colorspace, H ∈ [0, 360f32], s ∈ [0f32, 1f32], v ∈ [0f32, 1f32]
pub struct Hsl {
Expand Down
1 change: 1 addition & 0 deletions src/hsv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
use crate::rgb::Rgb;

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
/// Represents *HSV* (hue, saturation, value) colorspace, H ∈ [0, 360f32], s ∈ [0f32, 1f32], v ∈ [0f32, 1f32]
pub struct Hsv {
Expand Down
1 change: 1 addition & 0 deletions src/jzazbz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn perceptual_quantizer_inverse(x: f32) -> f32 {
rs
}

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
/// Represents Jzazbz
pub struct Jzazbz {
Expand Down
1 change: 1 addition & 0 deletions src/jzczhz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::ops::{
};

/// Represents Jzazbz in polar coordinates as Jzczhz
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct Jzczhz {
/// Jz(lightness) generally expects to be between [0;1]
Expand Down
1 change: 1 addition & 0 deletions src/lab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::ops::{
};

/// Represents CIELAB color space.
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialOrd, PartialEq)]
pub struct Lab {
/// `l`: lightness component (0 to 100)
Expand Down
1 change: 1 addition & 0 deletions src/lalphabeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{Rgb, TransferFunction, Xyz, SRGB_TO_XYZ_D65, XYZ_TO_SRGB_D65};
use std::ops::{Index, IndexMut, Neg};

/// Represents l-alpha-beta (lαβ) colorspace
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
pub struct LAlphaBeta {
pub l: f32,
Expand Down
2 changes: 2 additions & 0 deletions src/luv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

//! # Luv
/// Struct representing a color in CIE LUV, a.k.a. L\*u\*v\*, color space
#[repr(C)]
#[derive(Debug, Copy, Clone, Default, PartialOrd)]
pub struct Luv {
/// The L\* value (achromatic luminance) of the colour in 0–100 range.
Expand All @@ -30,6 +31,7 @@ pub struct Luv {
}

/// Representing a color in cylindrical CIE LCh(uv) color space
#[repr(C)]
#[derive(Debug, Copy, Clone, Default, PartialOrd)]
pub struct LCh {
/// The L\* value (achromatic luminance) of the colour in 0–100 range.
Expand Down
1 change: 1 addition & 0 deletions src/oklab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
use num_traits::Pow;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
/// Struct that represent *Oklab* colorspace
pub struct Oklab {
Expand Down
1 change: 1 addition & 0 deletions src/oklch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use num_traits::Pow;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};

/// Represents *Oklch* colorspace
#[repr(C)]
#[derive(Copy, Clone, PartialOrd, PartialEq)]
pub struct Oklch {
/// Lightness
Expand Down
1 change: 1 addition & 0 deletions src/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use num_traits::{AsPrimitive, Bounded, Float, Num, Pow};
use std::cmp::{max, min, Ordering};
use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub};

#[repr(C)]
#[derive(Debug, PartialOrd, PartialEq, Clone, Copy)]
/// Represents any RGB values, Rgb<u8>, Rgb<u16> etc.
pub struct Rgb<T> {
Expand Down
1 change: 1 addition & 0 deletions src/rgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use num_traits::{clamp, AsPrimitive, Bounded, Float, Num, Pow};
use std::cmp::{max, min, Ordering};
use std::ops::{Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, Neg, Sub};

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
/// Represents any RGBA values, Rgba<u8>, Rgba<u16> etc.
pub struct Rgba<T> {
Expand Down
1 change: 1 addition & 0 deletions src/xyb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssi
///
/// It is an LMS-based color model inspired by the human visual system, facilitating perceptually uniform quantization.
/// It uses a gamma of 3 for computationally efficient decoding.
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialOrd, PartialEq)]
pub struct Xyb {
pub x: f32,
Expand Down
1 change: 1 addition & 0 deletions src/xyz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::ops::{
};

/// A CIE 1931 XYZ color.
#[repr(C)]
#[derive(Copy, Clone, Debug, Default)]
pub struct Xyz {
pub x: f32,
Expand Down

0 comments on commit fe5706b

Please sign in to comment.