[−]Struct rltk::RGBA
Represents an R/G/B triplet, in the range 0..1 (32-bit float)
Fields
r: f32
g: f32
b: f32
a: f32
Methods
impl RGBA
#[must_use]pub fn new() -> RGBA
Constructs a new, zeroed (black) RGB triplet.
#[must_use]pub fn from_f32(r: f32, g: f32, b: f32, a: f32) -> RGBA
Constructs a new RGB color, from 3 32-bit floats in the range 0..1
#[must_use]pub fn from_u8(r: u8, g: u8, b: u8, a: u8) -> RGBA
Constructs a new RGB color, from 3 bytes in the range 0..255
#[must_use]pub fn named(col: (u8, u8, u8)) -> RGBA
Construct an RGB color from a tuple of u8, or a named constant
pub fn from_hex<S>(code: S) -> Result<RGBA, HtmlColorConversionError> where
S: AsRef<str>,
S: AsRef<str>,
Constructs from an HTML color code (e.g. "#eeffeeff")
Errors
#[must_use]pub fn to_rgb(&self) -> RGB
Converts to an RGB, dropping the alpha component
#[must_use]pub fn to_greyscale(&self) -> RGBA
Applies a quick grayscale conversion to the color
#[must_use]pub fn desaturate(&self) -> RGBA
Applies a lengthier desaturate (via HSV) to the color
#[must_use]pub fn lerp(&self, color: RGBA, percent: f32) -> RGBA
Lerps by a specified percentage (from 0 to 1) between this color and another
#[must_use]pub fn lerp_alpha(&self, color: RGBA, percent: f32) -> RGBA
Lerps only the alpha channel, by a specified percentage (from 0 to 1) between this color and another
#[must_use]pub fn to_xp(&self) -> XpColor
Converts an RGB to an xp file color component
Trait Implementations
impl Add<RGBA> for RGBA
Support adding an RGB to a color. The result is clamped via the constructor.
type Output = RGBA
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: RGBA) -> RGBA
impl Add<f32> for RGBA
Support adding a float to a color. The result is clamped via the constructor.
type Output = RGBA
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: f32) -> RGBA
impl Clone for RGBA
fn clone(&self) -> RGBA
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for RGBA
impl Debug for RGBA
impl Default for RGBA
impl From<(u8, u8, u8, u8)> for RGBA
Support conversion from a color tuple
impl From<(u8, u8, u8)> for RGBA
Support conversion from a color tuple
impl From<HSV> for RGBA
Support conversion from HSV
impl From<RGB> for RGBA
Support conversion from RGB
impl From<RGBA> for HSV
Support conversion from RGBA
impl From<RGBA> for RGB
Support conversion from RGBA
impl Mul<RGBA> for RGBA
Support multiplying a color by another color. The result is clamped via the constructor.
type Output = RGBA
The resulting type after applying the *
operator.
#[must_use]fn mul(self, rhs: RGBA) -> RGBA
impl Mul<f32> for RGBA
Support multiplying a color by a float. The result is clamped via the constructor.
type Output = RGBA
The resulting type after applying the *
operator.
#[must_use]fn mul(self, rhs: f32) -> RGBA
impl PartialEq<RGBA> for RGBA
impl StructuralPartialEq for RGBA
impl Sub<RGBA> for RGBA
Support subtracting an RGB from a color. The result is clamped via the constructor.
type Output = RGBA
The resulting type after applying the -
operator.
#[must_use]fn sub(self, rhs: RGBA) -> RGBA
impl Sub<f32> for RGBA
Support subtracting a float from a color. The result is clamped via the constructor.
Auto Trait Implementations
impl RefUnwindSafe for RGBA
impl Send for RGBA
impl Sync for RGBA
impl Unpin for RGBA
impl UnwindSafe for RGBA
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,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,