Skip to main content

Rg8U

Struct Rg8U 

Source
pub struct Rg8U(/* private fields */);
Expand description

A two-channel 8-bit unsigned color (red, green).

Implementations§

Source§

impl Rg8U

Source

pub const WHITE: Rg8U

Full white (all channels maximum).

Source

pub const BLACK: Rg8U

Full black (all channels zero).

Source

pub const fn new(r: u8, g: u8) -> Self

Creates a new two-channel color from u8 red and green values.

Source

pub const fn bytes(&self) -> [u8; 2]

Return color from raw bytes.

Source

pub const fn from_bytes(bytes: [u8; 2]) -> Self

Return color from raw bytes.

Source

pub const fn bits(&self) -> u16

Returns the raw u16 bit pattern (little-endian).

Source

pub const fn from_bits(bits: u16) -> Self

Constructs from a raw u16 bit pattern (little-endian).

Source

pub const fn bits_interleaved(&self) -> u16

Returns the channels as an interleaved u16 bit pattern.

Source

pub const fn from_bits_interleaved(bits: u16) -> Self

Constructs from an interleaved u16 bit pattern.

Source

pub const fn r(&self) -> u8

Returns the red channel value.

Source

pub const fn g(&self) -> u8

Returns the green channel value.

Source

pub const fn into_f32(self) -> Rg32F

Converts this color to its 32-bit float representation.

Source

pub const fn from_f32(rg: Rg32F) -> Rg8U

Converts from a 32-bit float representation, clamping each channel to [0, 255].

Source

pub fn wrapping_add(self, other: Self) -> Self

Wrapping unsigned addition per channel.

Source

pub fn wrapping_sub(self, other: Self) -> Self

Wrapping unsigned subtraction per channel.

Source

pub const fn diff(a: Self, b: Self) -> Vec2

Returns the per-channel difference as a Vec2.

Source

pub const fn distance_squared(a: Self, b: Self) -> f32

Returns the squared Euclidean distance.

Source

pub fn distance(a: Self, b: Self) -> f32

Returns the Euclidean distance.

Trait Implementations§

Source§

impl Clone for Rg8U

Source§

fn clone(&self) -> Rg8U

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rg8U

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FixedCode for Rg8U

Source§

const SIZE: usize

Source§

type Array = [u8; 2]

Source§

type Error = Infallible

Source§

fn fix_encode(&self) -> Self::Array

Source§

fn fix_decode(input: &Self::Array) -> Result<Self, Self::Error>

Source§

fn fix_write(&self, write: &mut impl Write) -> Result<()>

Encodes self and writes the resulting bytes to write.
Source§

fn fix_read(read: &mut impl Read) -> Result<Self>

Reads exactly SIZE bytes from read and decodes them.
Source§

impl Hash for Rg8U

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Rg8U

Source§

fn eq(&self, other: &Rg8U) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Rg8U

Source§

impl Eq for Rg8U

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> VarCode for T
where T: FixedCode,

Source§

fn var_bit_len(&self) -> usize

Source§

fn var_write(&self, write: &mut WriteBits<impl Write>) -> Result<(), Error>

Source§

fn var_read(read: &mut ReadBits<impl Read>) -> Result<T, Error>