Struct colstodian::Color[][src]

#[repr(transparent)]
pub struct Color<Spc, St> { pub raw: Vec3, // some fields omitted }
Expand description

A strongly typed color, parameterized by a color space and state.

See crate-level docs as well as ColorSpace and State for more.

Fields

raw: Vec3

The raw values of the color. Be careful when modifying this directly.

Implementations

Creates a Color with the internal color elements el1, el2, el3.

Creates a Color with raw values contained in raw.

Get the maximum element of self

Get the minimum element of self

Clamp the raw element values of self in the range [0..1]

Converts self from one color space to another while retaining the same State.

Be careful when converting between nonlinear color spaces while in Scene state as the nonlinear transform functions for some color spaces are only defined within a specific dynamic range.

Converts self from one color space to another while retaining the same State.

This works the same as convert except there is only one type parameter, the “Query”.

The query is meant to be one of:

  • A ColorSpace
  • A Color (in which case it will be converted to that color’s space).

This query is slightly more generic than the ones on convert, which means that the Rust type system is usually not able to infer the query without you explicitly giving one.

This can be useful in conjunction with defined type aliases for predefined Color types.

Interprets this color as DstSpace. This assumes you have done an external computation/conversion such that this cast is valid.

Interprets this color as DstSpace and DstState. This assumes you have done an external computation/conversion such that this cast is valid.

Decode self into its decoded (working) color space, which allows many more operations to be performed.

Convert self into the closest linear color space.

If self is already in a linear color space, this is a no-op.

Converts this color from one state to another.

This conversion is usecase and even instance dependent. For example, converting a material’s emissive texture value, a Display-referred color, to a Scene-referred color might take the form of a multiplication which scales the power of said emission into Scene-referred irradiance. On the other hand, converting a final Scene-referred color to a Display-referred color should be done with some kind of tonemapping operator. For more, see the tonemap module.

Note that the conversion function gives a raw color value, as the state of the color during the intermediate steps of the conversion is not really well defined. Therefore it’s easier to just work on the raw values without type safety.

Changes this color’s State. This assumes that you have done some kind of conversion externally, or that the proper conversion is simply a noop.

Blend self’s color values with the color values from other with linear interpolation. If factor is > 1.0, results may not be sensical.

Converts self to a ColorAlpha with Separate alpha state by adding a component. This is probably what you want.

Converts self to a ColorAlpha with specified AlphaState by adding an alpha component. Make sure you choose the correct alpha state! If you’re not sure, you probably want Color::with_alpha.

Convert self to a [u8; 3]. All components of self will be clamped to range [0..1].

Decode a [u8; 4] into a Color with specified space and state.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Upcasts self into a DynamicColor

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Convert self into its canonical cint type.

Create a Self from its canonical cint type.

Formats the value using the given formatter. Read more

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Test

The resulting type after dereferencing.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

Convert the inner type into the wrapper type.

Convert a reference to the inner type into a reference to the wrapper type. Read more

Convert a mutable reference to the inner type into a mutable reference to the wrapper type. Read more

Convert a slice to the inner type into a slice to the wrapper type.

Convert a mutable slice to the inner type into a mutable slice to the wrapper type. Read more

Convert the wrapper type into the inner type.

Convert a reference to the wrapper type into a reference to the inner type. Read more

Convert a mutable reference to the wrapper type into a mutable reference to the inner type. Read more

Convert a slice to the wrapped type into a slice to the inner type.

Convert a mutable slice to the wrapped type into a mutable slice to the inner type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Attempt to convert to a typed Color. Returns an error if self’s color space and state do not match the given types.

Convert to a typed Color without checking if the color space and state types match this color’s space and state. Use only if you are sure that this color is in the correct format.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.