pub struct CielabColor {
pub l: f32,
pub a: f32,
pub b: f32,
}Expand description
CIELAB color for perceptually uniform gradients.
CIELAB (Lab*) is designed so that equal distances in the color space correspond to equal perceived color differences.
§Example
ⓘ
use probar::brick::tui::CielabColor;
// Create gradient from green (0%) to red (100%)
let green = CielabColor::percent_gradient(0.0);
let red = CielabColor::percent_gradient(1.0);
// Interpolate for 50%
let yellow = green.lerp(&red, 0.5);Fields§
§l: f32Lightness (0-100)
a: f32Green-red axis (approx -128 to 127)
b: f32Blue-yellow axis (approx -128 to 127)
Implementations§
Source§impl CielabColor
impl CielabColor
Sourcepub fn to_rgb(&self) -> (u8, u8, u8)
pub fn to_rgb(&self) -> (u8, u8, u8)
Convert to approximate sRGB (0-255).
Note: This is a simplified conversion. For accurate results, use a proper color management library.
Sourcepub fn percent_gradient(percent: f32) -> Self
pub fn percent_gradient(percent: f32) -> Self
Create perceptually uniform gradient from green to red.
Uses green -> yellow -> red transition in CIELAB space.
Sourcepub fn meter_gradient(level: f32) -> Self
pub fn meter_gradient(level: f32) -> Self
Create gradient for meter display (blue -> green -> yellow -> red).
Trait Implementations§
Source§impl Clone for CielabColor
impl Clone for CielabColor
Source§fn clone(&self) -> CielabColor
fn clone(&self) -> CielabColor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CielabColor
Source§impl Debug for CielabColor
impl Debug for CielabColor
Source§impl Default for CielabColor
impl Default for CielabColor
Source§impl PartialEq for CielabColor
impl PartialEq for CielabColor
Source§fn eq(&self, other: &CielabColor) -> bool
fn eq(&self, other: &CielabColor) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CielabColor
Auto Trait Implementations§
impl Freeze for CielabColor
impl RefUnwindSafe for CielabColor
impl Send for CielabColor
impl Sync for CielabColor
impl Unpin for CielabColor
impl UnsafeUnpin for CielabColor
impl UnwindSafe for CielabColor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().