Struct smol_rgb::EncodedRgb [−][src]
A color used in linear applications. On a technical level, this color is in sRGB; however, this name is not very clear.
In code, we will say that this Color is encoded
. This is generally the same
colorspace that texels in a texture are in. This color space is not valid
to perform mixing operations between colors in, so we must convert this
color space into a different color, LinearRgb, with to_linear
before we do such operations.
Fields
r: u8
The red component of the color.
g: u8
The green component of the color.
b: u8
The blue component of the color.
a: u8
The alpha component of the color, normally the opacity in blending operations.
Implementations
impl EncodedRgb
[src]
pub const WHITE: EncodedRgb
[src]
A basic white (255, 255, 255, 255) with full opacity.
pub const BLACK: EncodedRgb
[src]
A basic black (0, 0, 0, 255) with full opacity.
pub const CLEAR: EncodedRgb
[src]
A black (0, 0, 0, 0) with zero opacity.
pub const FUCHSIA: EncodedRgb
[src]
God’s color (255, 0, 255, 255). The color of choice for graphics testing.
pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Self
[src]
Creates a new encoded 32bit color.
pub fn to_linear(self) -> LinearRgb
[src]
Transforms this color into the Linear color space.
pub fn to_encoded_f32s(self) -> [f32; 4]
[src]
Converts this color to an [f32; 4] array. This is still in encoded space but they are converted to an f32. This is mostly for compatability with other libraries which sometimes need to f32s even while in encoded sRGB.
We use this dedicated function, rather than a From
or Into
because
this is an unusual use of f32s, and in general, this module acts as if
f32 == Linear and u8 == Encoded, though this is not technically true.
pub fn from_encoded_f32s(input: [f32; 4]) -> Self
[src]
Converts this color to an [f32; 4] array. This is still in encoded space but they are converted to an f32. This is mostly for compatability with other libraries which sometimes need to f32s even while in encoded sRGB.
We use this dedicated function, rather than a From
or Into
because
this is an unusual use of f32s, and in general, this module acts as if
f32 == Linear and u8 == Encoded, though this is not technically true.
pub const fn from_rgba_u32(input: u32) -> Self
[src]
Converts a packed u32 to an encoded rgba struct.
Note, your colors must be in order of red, green, blue, alpha
. For bgra
support,
use from_bgra_u32
.
This function might also has issues on non-little endian platforms, but look, you’re not on one of those.
pub const fn to_rgba_u32(self) -> u32
[src]
Converts the encoded rgba struct to a packed u32 in rgba
encoding.
This will output your colors in order of red, green, blue, alpha
. For bgra
support,
use to_bgra_u32
.
This function might also have issues on non-little endian platforms, but look, you’re not on one of those.
pub const fn from_bgra_u32(input: u32) -> Self
[src]
Converts a packed u32 to an encoded rgba struct. On little endian platforms, this is a no-op.
Note, your colors must be in order of blue
, green
, red
, alpha
.
This function might also has issues on non-little endian platforms, but look, you’re not on one of those probably.
pub const fn to_bgra_u32(self) -> u32
[src]
Converts the encoded rgba struct to a packed u32 in bgra
encoding.
This will output your colors in order of red, green, blue, alpha
. For bgra
support,
use to_bgra_u32
.
This function might also have issues on non-little endian platforms, but look, you’re not on one of those.
Trait Implementations
impl Clone for EncodedRgb
[src]
fn clone(&self) -> EncodedRgb
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for EncodedRgb
[src]
impl Debug for EncodedRgb
[src]
impl Default for EncodedRgb
[src]
fn default() -> EncodedRgb
[src]
impl Display for EncodedRgb
[src]
impl Eq for EncodedRgb
[src]
impl From<(u8, u8, u8, u8)> for EncodedRgb
[src]
impl From<EncodedRgb> for LinearRgb
[src]
fn from(o: EncodedRgb) -> Self
[src]
impl From<LinearRgb> for EncodedRgb
[src]
impl Hash for EncodedRgb
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Into<(u8, u8, u8, u8)> for EncodedRgb
[src]
impl LowerHex for EncodedRgb
[src]
impl Ord for EncodedRgb
[src]
fn cmp(&self, other: &EncodedRgb) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<EncodedRgb> for EncodedRgb
[src]
fn eq(&self, other: &EncodedRgb) -> bool
[src]
fn ne(&self, other: &EncodedRgb) -> bool
[src]
impl PartialOrd<EncodedRgb> for EncodedRgb
[src]
fn partial_cmp(&self, other: &EncodedRgb) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for EncodedRgb
[src]
impl StructuralPartialEq for EncodedRgb
[src]
impl UpperHex for EncodedRgb
[src]
Auto Trait Implementations
impl RefUnwindSafe for EncodedRgb
impl Send for EncodedRgb
impl Sync for EncodedRgb
impl Unpin for EncodedRgb
impl UnwindSafe for EncodedRgb
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,