[][src]Struct tray_rust::film::color::Colorf

pub struct Colorf {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

Colorf is a floating point RGBA color type a is typically used to store the weight of a color eg. in the render target for multisampling we need to track the weight to normalize in the end and is always initialized to 0

Fields

r: f32g: f32b: f32a: f32

Methods

impl Colorf[src]

pub fn new(r: f32, g: f32, b: f32) -> Colorf[src]

Create an RGB color

pub fn with_alpha(r: f32, g: f32, b: f32, a: f32) -> Colorf[src]

Create an RGB color

pub fn broadcast(r: f32) -> Colorf[src]

Create an RGB color using the same value for all channels

pub fn black() -> Colorf[src]

Create a black color

pub fn clamp(&self) -> Colorf[src]

Clamp the color values between [0, 1]

pub fn luminance(&self) -> f32[src]

Compute the luminance of the color

pub fn is_black(&self) -> bool[src]

Check if the color is black

pub fn has_nans(&self) -> bool[src]

Check if any of the color channels are NaN

pub fn has_infs(&self) -> bool[src]

Check if any of the color channels are infinite

pub fn to_srgb(&self) -> Colorf[src]

Convert the linear RGB color to sRGB

pub fn exp(&self) -> Colorf[src]

Return the color with values { e^r, e^g, e^b }

Trait Implementations

impl Clone for Colorf[src]

impl Copy for Colorf[src]

impl PartialEq<Colorf> for Colorf[src]

impl Debug for Colorf[src]

impl Div<Colorf> for Colorf[src]

type Output = Colorf

The resulting type after applying the / operator.

fn div(self, rhs: Colorf) -> Colorf[src]

Divide the channels of one color by another

impl Div<f32> for Colorf[src]

type Output = Colorf

The resulting type after applying the / operator.

fn div(self, rhs: f32) -> Colorf[src]

Divide the channels of the color by the float

impl Sub<Colorf> for Colorf[src]

type Output = Colorf

The resulting type after applying the - operator.

fn sub(self, rhs: Colorf) -> Colorf[src]

Subtract the two colors

impl Add<Colorf> for Colorf[src]

type Output = Colorf

The resulting type after applying the + operator.

fn add(self, rhs: Colorf) -> Colorf[src]

Add two colors together

impl Mul<Colorf> for Colorf[src]

type Output = Colorf

The resulting type after applying the * operator.

fn mul(self, rhs: Colorf) -> Colorf[src]

Multiply the two colors

impl Mul<f32> for Colorf[src]

type Output = Colorf

The resulting type after applying the * operator.

fn mul(self, rhs: f32) -> Colorf[src]

Scale the color by the float

impl Mul<Colorf> for f32[src]

type Output = Colorf

The resulting type after applying the * operator.

fn mul(self, rhs: Colorf) -> Colorf[src]

Scale the color by the float

impl Neg for Colorf[src]

type Output = Colorf

The resulting type after applying the - operator.

fn neg(self) -> Colorf[src]

Negate the color channels

impl Index<usize> for Colorf[src]

type Output = f32

The returned type after indexing.

fn index(&self, i: usize) -> &f32[src]

Access the channels by index

  • 0 = r
  • 1 = g
  • 2 = b
  • 3 = a

impl IndexMut<usize> for Colorf[src]

fn index_mut(&mut self, i: usize) -> &mut f32[src]

Access the channels by index

  • 0 = r
  • 1 = g
  • 2 = b
  • 3 = a

impl StructuralPartialEq for Colorf[src]

Auto Trait Implementations

impl Send for Colorf

impl Sync for Colorf

impl Unpin for Colorf

impl UnwindSafe for Colorf

impl RefUnwindSafe for Colorf

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Interpolate for T where
    T: Add<T, Output = T> + Mul<f32, Output = T> + Copy
[src]

impl<T> SetParameter for T[src]