pub struct Rg8U(/* private fields */);Expand description
A two-channel 8-bit unsigned color (red, green).
Implementations§
Source§impl Rg8U
impl Rg8U
Sourcepub const fn new(r: u8, g: u8) -> Self
pub const fn new(r: u8, g: u8) -> Self
Creates a new two-channel color from u8 red and green values.
Sourcepub const fn from_bytes(bytes: [u8; 2]) -> Self
pub const fn from_bytes(bytes: [u8; 2]) -> Self
Return color from raw bytes.
Sourcepub const fn from_bits(bits: u16) -> Self
pub const fn from_bits(bits: u16) -> Self
Constructs from a raw u16 bit pattern (little-endian).
Sourcepub const fn bits_interleaved(&self) -> u16
pub const fn bits_interleaved(&self) -> u16
Returns the channels as an interleaved u16 bit pattern.
Sourcepub const fn from_bits_interleaved(bits: u16) -> Self
pub const fn from_bits_interleaved(bits: u16) -> Self
Constructs from an interleaved u16 bit pattern.
Sourcepub const fn from_f32(rg: Rg32F) -> Rg8U
pub const fn from_f32(rg: Rg32F) -> Rg8U
Converts from a 32-bit float representation, clamping each channel to [0, 255].
Sourcepub fn wrapping_add(self, other: Self) -> Self
pub fn wrapping_add(self, other: Self) -> Self
Wrapping unsigned addition per channel.
Sourcepub fn wrapping_sub(self, other: Self) -> Self
pub fn wrapping_sub(self, other: Self) -> Self
Wrapping unsigned subtraction per channel.
Sourcepub const fn distance_squared(a: Self, b: Self) -> f32
pub const fn distance_squared(a: Self, b: Self) -> f32
Returns the squared Euclidean distance.
Trait Implementations§
Source§impl FixedCode for Rg8U
impl FixedCode for Rg8U
const SIZE: usize
type Array = [u8; 2]
type Error = Infallible
fn fix_encode(&self) -> Self::Array
fn fix_decode(input: &Self::Array) -> Result<Self, Self::Error>
impl Copy for Rg8U
impl Eq for Rg8U
impl StructuralPartialEq for Rg8U
Auto Trait Implementations§
impl Freeze for Rg8U
impl RefUnwindSafe for Rg8U
impl Send for Rg8U
impl Sync for Rg8U
impl Unpin for Rg8U
impl UnsafeUnpin for Rg8U
impl UnwindSafe for Rg8U
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.