Struct Rgba

Source
pub struct Rgba { /* private fields */ }
Expand description

Rgba represents the colors red, green, blue, alpha. Alpha represents the transparency of the image while red, green and blue represent the intensity of the colors.

Alpha is managed between 0 - 100 Red Green and Blue is managed between 0 - 255

Implementations§

Source§

impl Rgba

Source

pub fn white() -> Rgba

Create the color white

Source

pub fn black() -> Rgba

Create the color black

Source

pub fn rgb(red: u8, green: u8, blue: u8) -> Rgba

Create a color by specifying red, green and blue

Source

pub fn bgr(blue: u8, green: u8, red: u8) -> Rgba

Create a color by specifying blue, green and red

Source

pub fn bgra(blue: u8, green: u8, red: u8, alpha: u8) -> Rgba

Create a color by specifying blue, green, red and alpha

Source

pub fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Rgba

Create a color by specifying red, green, blue and alpha

Source

pub fn recolor_to(&mut self, other: &Self)

Change the current color to the other color

Source

pub fn is_transparent(&self) -> bool

Check if the alpha value is less then 100 (Visible)

Source

pub fn get_red(&self) -> u8

get the amount of red in the pixel

Source

pub fn get_green(&self) -> u8

get the amount of green in the pixel

Source

pub fn get_blue(&self) -> u8

get the amount of blue in the pixel

Source

pub fn get_alpha(&self) -> u8

get the amount of alpha in the pixel

Source§

impl Rgba

Methods used to manipulate the rgba color in a certain way

Source

pub fn color_to_gray(&mut self)

Convert pixel color to gray scale

Source

pub fn linear_interpolation( lhs: &Rgba, lhs_factor: f32, rhs: &Rgba, rhs_factor: f32, ) -> Result<Rgba, &'static str>

Blur 2 color’s together

By passing in different factors, you can effect how much one color will effect the other.

@param {&Rgba} first color to linear_interpolation @param {f32} factor how much the first color will effect the outcome @param {&Rgba} second color to linear_interpolation @param {f32} factor how much the second color will effect the outcome @return {Rgba} new color of the 2 colors blurred together

Source

pub fn cubic_interpolate( p0: &Rgba, p1: &Rgba, p2: &Rgba, p3: &Rgba, factor: f32, ) -> Rgba

Use cubic interpolation on 4 colors between range [0, 1] then find x as a factor that is between [0, 1] (ex. 0.5)

Reference: https://www.paulinternet.nl/?page=bicubic

Trait Implementations§

Source§

impl Clone for Rgba

Source§

fn clone(&self) -> Rgba

Returns a copy 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 Rgba

Source§

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

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

impl Display for Rgba

Source§

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

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

impl PartialEq for Rgba

Source§

fn eq(&self, other: &Self) -> 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 Rgba

Auto Trait Implementations§

§

impl Freeze for Rgba

§

impl RefUnwindSafe for Rgba

§

impl Send for Rgba

§

impl Sync for Rgba

§

impl Unpin for Rgba

§

impl UnwindSafe for Rgba

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.