Skip to main content

ColorRgba8

Struct ColorRgba8 

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

A packed 8-bit RGBA color, laid out in RGBA byte order. 一个打包的 8 位 RGBA 颜色,按 RGBA 字节顺序排列。

This is the storage format for textures and framebuffers. 这是纹理和帧缓冲的存储格式。

Fields§

§r: u8

Red channel. 红色通道。

§g: u8

Green channel. 绿色通道。

§b: u8

Blue channel. 蓝色通道。

§a: u8

Alpha channel. 透明通道。

Implementations§

Source§

impl ColorRgba8

Source

pub const BLACK: Self

Opaque black. 不透明黑色。

Source

pub const WHITE: Self

Opaque white. 不透明白色。

Source

pub const TRANSPARENT: Self

Fully transparent black. 完全透明的黑色。

Source

pub const MAGENTA: Self

The conventional “missing texture” color. 约定的“缺失纹理”颜色。

Source

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

Pack four components into a color. 将四个分量打包成一个颜色。

Source

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

Pack three components into an opaque color. 将三个分量打包成一个不透明颜色。

Source

pub fn to_linear(self) -> Rgb

Convert to linear-light components in [0, 1]. 转换为 [0, 1] 范围内的线性光分量。

Trait Implementations§

Source§

impl Clone for ColorRgba8

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ColorRgba8

Source§

impl Debug for ColorRgba8

Source§

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

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

impl Default for ColorRgba8

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ColorRgba8

Source§

impl Hash for ColorRgba8

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 ColorRgba8

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ColorRgba8

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.