From 6a8eabf9f2119ed5664e6deec037969cc0945685 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Sun, 28 Dec 2025 18:27:27 +0100 Subject: [PATCH] show the oklab color space --- Cargo.lock | 23 +++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 24 +++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 728ba9e..c9cf3d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,6 +204,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fast-srgb8" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1" + [[package]] name = "find-msvc-tools" version = "0.1.6" @@ -285,6 +291,16 @@ dependencies = [ "libc", ] +[[package]] +name = "oklab" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1e35ab3c8efa6bc97d651abe7fb051aebb30c925a450ff6722cf9c797a938cc" +dependencies = [ + "fast-srgb8", + "rgb", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -394,6 +410,12 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +[[package]] +name = "rgb" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" + [[package]] name = "rustix" version = "1.1.3" @@ -542,6 +564,7 @@ dependencies = [ "env_logger", "eyre", "log", + "oklab", "smithay-client-toolkit", "wayland-client", ] diff --git a/Cargo.toml b/Cargo.toml index 123a76c..503f24f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,5 +7,6 @@ edition = "2024" env_logger = "0.11.8" eyre = "0.6.12" log = "0.4.29" +oklab = "1.1.2" smithay-client-toolkit = "0.20.0" wayland-client = "0.31.11" diff --git a/src/main.rs b/src/main.rs index 6cf9649..665cc76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,6 +130,15 @@ impl OutputHandler for App { _qh: &QueueHandle, output: wayland_client::protocol::wl_output::WlOutput, ) { + match self.output_state.info(&output) { + None => warn!("Output disconnected, unknown information"), + Some(info) => { + info!( + "Output disconnected ({})", + info.description.unwrap_or_else(|| "".into()), + ); + } + } if let Some(suface_idx) = self .layer_surfaces .iter() @@ -215,10 +224,19 @@ impl LayerShellHandler for App { let x = (index % width as usize) as u32; let y = (index / width as usize) as u32; + let xf = x as f32 / width as f32; + let yf = y as f32 / height as f32; + + let srgb = oklab::oklab_to_srgb(oklab::Oklab { + l: 0.7, + a: xf * 0.8 - 0.4, + b: yf * 0.8 - 0.4, + }); + let a = 0xFF; - let r = u32::min(((width - x) * 0xFF) / width, ((height - y) * 0xFF) / height); - let g = u32::min((x * 0xFF) / width, ((height - y) * 0xFF) / height); - let b = u32::min(((width - x) * 0xFF) / width, (y * 0xFF) / height); + let r = srgb.r as u32; + let g = srgb.g as u32; + let b = srgb.b as u32; let color = (a << 24) + (r << 16) + (g << 8) + b; let array: &mut [u8; 4] = chunk.try_into().unwrap();