logo

Struct rgb::RGBA

source · []
#[repr(C)]
pub struct RGBA<ComponentType, AlphaComponentType = ComponentType> { pub r: ComponentType, pub g: ComponentType, pub b: ComponentType, pub a: AlphaComponentType, }
Expand description

The RGBA pixel

The component type can be u8 (aliased as RGBA8), u16 (aliased as RGBA16), or any other type (but simple copyable types are recommended.)

You can specify a different type for alpha, but it’s only for special cases (e.g. if you use a newtype like RGBA<LinearLight<u16>, u16>).

Fields

r: ComponentType

Red

g: ComponentType

Green

b: ComponentType

Blue

a: AlphaComponentType

Alpha

Implementations

Convenience function for creating a new pixel The order of arguments is R,G,B,A

Convenience function for creating a new pixel The order of arguments is R,G,B,A

Provide a mutable view of only RGB components (leaving out alpha). Useful to change color without changing opacity.

Copy RGB components out of the RGBA struct

Note: you can use .into() to convert between other types

Iterate over all components (length=4)

Copy RGB components out of the RGBA struct

Note: you can use .into() to convert between other types

Create new RGBA with the same alpha value, but different RGB values

Create a new RGBA with the new alpha value, but same RGB values

Create a new RGBA with a new alpha value created by the callback. Allows changing of the type used for the alpha channel.

Trait Implementations

px + px

The resulting type after applying the + operator.

Performs the + operation. Read more

px + 1

The resulting type after applying the + operator.

Performs the + operation. Read more

px + px

Performs the += operation. Read more

px + 1

Performs the += operation. Read more

Converts this type into a mutable reference of the (usually inferred) input type.

Reinterpret the slice as a read-only/shared slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA). Read more

Reinterpret the slice as a mutable/exclusive slice of pixels. Multiple consecutive elements in the slice are intepreted as a single pixel (depending on format, e.g. 3 for RGB, 4 for RGBA). Read more

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Convenience function for applying the same formula to every rgb/gray component, but skipping the alpha component. Read more

Convenience function (equivalent of self.iter().map().collect()) for applying the same formula to every component. Read more

The components interpreted as an array, e.g. one RGB expands to 3 elements. Read more

The components interpreted as a mutable array, e.g. one RGB expands to 3 elements. Read more

Formats the value using the given formatter. Read more

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

Formats the value using the given formatter. Read more

px / 1

The resulting type after applying the / operator.

Performs the / operation. Read more

px * 1

Performs the /= operation. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Assumes 65535 is opaque

Converts to this type from the input type.

Assumes 255 is opaque

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Assumes 65535 is opaque

Converts to this type from the input type.

Assumes 255 is opaque

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Takes exactly 4 elements from the iterator and creates a new instance. Panics if there are fewer elements in the iterator.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

px * 1

The resulting type after applying the * operator.

Performs the * operation. Read more

px * 1

Performs the *= operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

px - px

The resulting type after applying the - operator.

Performs the - operation. Read more

px - 1

The resulting type after applying the - operator.

Performs the - operation. Read more

px - px

Performs the -= operation. Read more

px - 1

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.