Struct imgui::color::ImColor32[][src]

#[repr(transparent)]
pub struct ImColor32(_);
Expand description

Wraps u32 that represents a packed RGBA color. Mostly used by types in the low level custom drawing API, such as DrawListMut.

The bits of a color are in “0xAABBGGRR” format (e.g. RGBA as little endian bytes). For clarity: we don’t support an equivalent to the IMGUI_USE_BGRA_PACKED_COLOR define.

This used to be named ImColor32, but was renamed to avoid confusion with the type with that name in the C++ API (which uses 32 bits per channel).

While it doesn’t provide methods to access the fields, they can be accessed via the Deref/DerefMut impls it provides targeting imgui::color::ImColor32Fields, which has no other meaningful uses.

Example

let mut c = imgui::ImColor32::from_rgba(0x80, 0xc0, 0x40, 0xff);
assert_eq!(c.to_bits(), 0xff_40_c0_80); // Note: 0xAA_BB_GG_RR
// Field access
assert_eq!(c.r, 0x80);
assert_eq!(c.g, 0xc0);
assert_eq!(c.b, 0x40);
assert_eq!(c.a, 0xff);
c.b = 0xbb;
assert_eq!(c.to_bits(), 0xff_bb_c0_80);

Implementations

Convenience constant for solid black.

Convenience constant for solid white.

Convenience constant for full transparency.

Construct a color from 4 single-byte u8 channel values, which should be between 0 and 255.

Construct a fully opaque color from 3 single-byte u8 channel values. Same as Self::from_rgba with a == 255

Construct a fully opaque color from 4 f32 channel values in the range 0.0 ..= 1.0 (values outside this range are clamped to it, with NaN mapped to 0.0).

Note: No alpha premultiplication is done, so your input should be have premultiplied alpha if needed.

Return the channels as an array of f32 in [r, g, b, a] order.

Return the channels as an array of u8 in [r, g, b, a] order.

Equivalent to Self::from_rgba_f32s, but with an alpha of 1.0 (e.g. opaque).

Construct a color from the u32 that makes up the bits in 0xAABBGGRR format.

Specifically, this takes the RGBA values as a little-endian u32 with 8 bits per channel.

Note that ImColor32::from_rgba may be a bit easier to use.

Return the bits of the color as a u32. These are in “0xAABBGGRR” format, that is, little-endian RGBA with 8 bits per channel.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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

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

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

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.