#[repr(C)]pub struct Rgb<T, const LINEAR: bool = false> {
pub c: [T; 3],
}
color
only.Expand description
RGB color with 3 components.
Fields§
§c: [T; 3]
Color channels in order: [red, green, blue].
- Red/Green/Blue: Gamma-encoded luminosity (0..=255).
Implementations§
Source§impl Rgb<u8>
impl Rgb<u8>
Source§impl Rgb<u8>
§General conversions
impl Rgb<u8>
§General conversions
Sourcepub const fn from_array(c: [u8; 3]) -> Rgb8
pub const fn from_array(c: [u8; 3]) -> Rgb8
Create from an array.
Sourcepub const fn from_rgba8(c: Rgba8) -> Rgb8
pub const fn from_rgba8(c: Rgba8) -> Rgb8
Create from Rgba<u8>
.
Loses the alpha channel.
Sourcepub const fn to_rgba8(self, alpha: u8) -> Rgba8
pub const fn to_rgba8(self, alpha: u8) -> Rgba8
Convert to Rgba<u8>
.
Adds the given alpha
channel.
Sourcepub const fn from_rgb8_packed(packed: u32) -> Rgb8
pub const fn from_rgb8_packed(packed: u32) -> Rgb8
Create from a packed u32
in 0xRRGGBB
format.
Any bits above 0x00FF_FFFF
are ignored.
Sourcepub const fn to_rgb8_packed(self) -> u32 ⓘ
pub const fn to_rgb8_packed(self) -> u32 ⓘ
Convert to a packed u32
in 0xRRGGBB
format.
Sourcepub const fn from_rgba8_packed(packed: u32) -> Rgb8
pub const fn from_rgba8_packed(packed: u32) -> Rgb8
Create from a packed u32
in 0xRRGGBBAA
format, discarding alpha.
Sourcepub const fn to_rgba8_packed(self, alpha: u8) -> u32 ⓘ
pub const fn to_rgba8_packed(self, alpha: u8) -> u32 ⓘ
Convert to a packed u32
in 0xRRGGBBAA
format, with the given alpha
.
Sourcepub fn from_rgb16(from: Rgb16) -> Rgb8
pub fn from_rgb16(from: Rgb16) -> Rgb8
Convert to Rgba<u8>
by scaling each component proportionally.
Source§impl Rgb<u8>
§f64
conversions
impl Rgb<u8>
§f64
conversions
Sourcepub const fn from_rgb_f64(c: RgbF64) -> Rgb8
Available on crate feature _float_f64
only.
pub const fn from_rgb_f64(c: RgbF64) -> Rgb8
_float_f64
only.Create from Rgb<f64>
.
Sourcepub const fn to_rgb_f64(self) -> RgbF64
Available on crate feature _float_f64
only.
pub const fn to_rgb_f64(self) -> RgbF64
_float_f64
only.Convert to Rgb<f64>
.
Sourcepub const fn from_rgba_f64(c: RgbaF64) -> Rgb8
Available on crate feature _float_f64
only.
pub const fn from_rgba_f64(c: RgbaF64) -> Rgb8
_float_f64
only.Create from Rgba<f64>
.
Loses the alpha channel.
Sourcepub const fn to_rgba_f64(self, alpha: u8) -> RgbaF64
Available on crate feature _float_f64
only.
pub const fn to_rgba_f64(self, alpha: u8) -> RgbaF64
_float_f64
only.Convert to Rgba<f64>
.
Adds the given alpha
channel.
Source§impl Rgb<u16>
impl Rgb<u16>
Source§impl Rgb<u16>
§General conversions
impl Rgb<u16>
§General conversions
Sourcepub const fn from_array(c: [u16; 3]) -> Rgb16
pub const fn from_array(c: [u16; 3]) -> Rgb16
Create from an array.
Sourcepub const fn from_rgba16(c: Rgba16) -> Rgb16
pub const fn from_rgba16(c: Rgba16) -> Rgb16
Create from Rgba<u16>
.
Loses the alpha channel.
Sourcepub const fn to_rgba16(self, alpha: u16) -> Rgba16
pub const fn to_rgba16(self, alpha: u16) -> Rgba16
Convert to Rgba<u16>
.
Adds the given alpha
channel.
Sourcepub const fn from_rgb16_packed(packed: u64) -> Rgb16
pub const fn from_rgb16_packed(packed: u64) -> Rgb16
Create from a packed u64
in 0xRRRRGGGGBBBB
format.
Any bits above 0x0000_FFFF_FFFF_FFFF
are ignored.
Sourcepub const fn to_rgb16_packed(self) -> u64
pub const fn to_rgb16_packed(self) -> u64
Convert to a packed u64
in 0xRRRRGGGGBBBB
format.
Sourcepub const fn from_rgba16_packed(packed: u64) -> Rgb16
pub const fn from_rgba16_packed(packed: u64) -> Rgb16
Create from a packed u64
in 0xRRRRGGGGBBBBAAAA
format, discarding alpha.
Sourcepub const fn to_rgba16_packed(self, alpha: u16) -> u64
pub const fn to_rgba16_packed(self, alpha: u16) -> u64
Convert to a packed u64
in 0xRRRRGGGGBBBBAAAA
format, with the given alpha
.
Source§impl Rgb<u16>
§f64
conversions
impl Rgb<u16>
§f64
conversions
Sourcepub const fn from_rgb_f64(c: RgbF64) -> Rgb16
Available on crate feature _float_f64
only.
pub const fn from_rgb_f64(c: RgbF64) -> Rgb16
_float_f64
only.Create from Rgb<f64>
.
Sourcepub const fn to_rgb_f64(self) -> RgbF64
Available on crate feature _float_f64
only.
pub const fn to_rgb_f64(self) -> RgbF64
_float_f64
only.Convert to Rgb<f64>
.
Sourcepub const fn from_rgba_f64(c: RgbaF64) -> Rgb16
Available on crate feature _float_f64
only.
pub const fn from_rgba_f64(c: RgbaF64) -> Rgb16
_float_f64
only.Create from Rgba<f64>
.
Loses the alpha channel.
Sourcepub const fn to_rgba_f64(self, alpha: u16) -> RgbaF64
Available on crate feature _float_f64
only.
pub const fn to_rgba_f64(self, alpha: u16) -> RgbaF64
_float_f64
only.Convert to Rgba<f64>
.
Adds the given alpha
channel.
Trait Implementations§
Source§impl<T: Ord, const LINEAR: bool> Ord for Rgb<T, LINEAR>
impl<T: Ord, const LINEAR: bool> Ord for Rgb<T, LINEAR>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd, const LINEAR: bool> PartialOrd for Rgb<T, LINEAR>
impl<T: PartialOrd, const LINEAR: bool> PartialOrd for Rgb<T, LINEAR>
impl<T: Copy, const LINEAR: bool> Copy for Rgb<T, LINEAR>
impl<T: Eq, const LINEAR: bool> Eq for Rgb<T, LINEAR>
impl<T, const LINEAR: bool> StructuralPartialEq for Rgb<T, LINEAR>
Auto Trait Implementations§
impl<T, const LINEAR: bool> Freeze for Rgb<T, LINEAR>where
T: Freeze,
impl<T, const LINEAR: bool> RefUnwindSafe for Rgb<T, LINEAR>where
T: RefUnwindSafe,
impl<T, const LINEAR: bool> Send for Rgb<T, LINEAR>where
T: Send,
impl<T, const LINEAR: bool> Sync for Rgb<T, LINEAR>where
T: Sync,
impl<T, const LINEAR: bool> Unpin for Rgb<T, LINEAR>where
T: Unpin,
impl<T, const LINEAR: bool> UnwindSafe for Rgb<T, LINEAR>where
T: UnwindSafe,
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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId
of Self
using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Source§fn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Source§fn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Source§fn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
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> ⓘ
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> ⓘ
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 more