Struct rust_raylib::color::Color

source ·
#[repr(C)]
pub struct Color { pub r: u8, pub g: u8, pub b: u8, pub a: u8, }
Expand description

Color, 4 components, R8G8B8A8 (32bit)

Fields§

§r: u8

Color red value

§g: u8

Color green value

§b: u8

Color blue value

§a: u8

Color alpha value

Implementations§

source§

impl Color

source

pub const LIGHTGRAY: Color = _

Light gray color

source

pub const GRAY: Color = _

Gray color

source

pub const DARKGRAY: Color = _

Dark gray color

source

pub const YELLOW: Color = _

Yellow color

source

pub const GOLD: Color = _

Gold color

source

pub const ORANGE: Color = _

Orange color

source

pub const PINK: Color = _

Pink color

source

pub const RED: Color = _

Red color

source

pub const MAROON: Color = _

Maroon color

source

pub const GREEN: Color = _

Green color

source

pub const LIME: Color = _

Lime color

source

pub const DARKGREEN: Color = _

Dark green color

source

pub const SKYBLUE: Color = _

Sky blue color

source

pub const BLUE: Color = _

Blue color

source

pub const DARKBLUE: Color = _

Dark blue color

source

pub const PURPLE: Color = _

Purple color

source

pub const VIOLET: Color = _

Violet color

source

pub const DARKPURPLE: Color = _

Dark purple color

source

pub const BEIGE: Color = _

Beige color

source

pub const BROWN: Color = _

Brown color

source

pub const DARKBROWN: Color = _

Dark brown color

source

pub const WHITE: Color = _

White color

source

pub const BLACK: Color = _

Black color

source

pub const BLANK: Color = _

Blank color (alpha = 0)

source

pub const MAGENTA: Color = _

Magenta color

source

pub const RAYWHITE: Color = _

Raylib white color

source

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

Convenience function for creating a new color

source

pub fn fade(self, alpha: f32) -> Self

Get color with alpha applied, alpha goes from 0.0f to 1.0f

source

pub fn to_hex(self) -> u32

Get hexadecimal value for a Color

source

pub fn from_hex(val: u32) -> Self

Get Color structure from hexadecimal value

source

pub fn normalize(self) -> Vector4

Get Color normalized as float [0..1]

source

pub fn from_normalized(normalized: Vector4) -> Self

Get Color from normalized values [0..1]

source

pub fn to_hsv(self) -> Vector3

Get HSV values for a Color, hue [0..360], saturation/value [0..1]

source

pub fn from_hsv(hue: f32, saturation: f32, value: f32) -> Self

Get a Color from HSV values, hue [0..360], saturation/value [0..1]

source

pub fn tint(self, tint: Self) -> Self

Get color multiplied with another color

source

pub fn brightness(self, factor: f32) -> Self

Get color with brightness correction, brightness factor goes from -1.0f to 1.0f

source

pub fn contrast(self, contrast: f32) -> Self

Get color with contrast correction, contrast values between -1.0f and 1.0f

source

pub fn alpha(self, alpha: f32) -> Self

Get color with alpha applied, alpha goes from 0.0f to 1.0f

source

pub fn alpha_blend(self, src: Self, tint: Self) -> Self

Get src alpha-blended into dst color with tint

source

pub fn get_pixel_color(source: &[u8], format: PixelFormat) -> Option<Self>

Get Color from a source pixel pointer of certain format (uncompressed formats only)

Returns None if buffer isn’t large enough

source

pub fn set_pixel_color(self, dest: &mut [u8], format: PixelFormat) -> bool

Set color formatted into destination pixel pointer (uncompressed formats only)

Returns true on success, false if buffer isn’t large enough

Trait Implementations§

source§

impl Clone for Color

source§

fn clone(&self) -> Color

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 Color

source§

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

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

impl From<Color> for Color

source§

fn from(val: Color) -> Self

Converts to this type from the input type.
source§

impl From<Color> for Color

source§

fn from(value: Color) -> Self

Converts to this type from the input type.
source§

impl Hash for Color

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 Color

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Color

source§

impl Eq for Color

source§

impl StructuralEq for Color

source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.