Struct imgui::color::ImColor32 [−][src]
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
impl ImColor32
[src]
pub const BLACK: Self
[src]
Convenience constant for solid black.
pub const WHITE: Self
[src]
Convenience constant for solid white.
pub const TRANSPARENT: Self
[src]
Convenience constant for full transparency.
pub const fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self
[src]
Construct a color from 4 single-byte u8
channel values, which should
be between 0 and 255.
pub const fn from_rgb(r: u8, g: u8, b: u8) -> Self
[src]
Construct a fully opaque color from 3 single-byte u8
channel values.
Same as Self::from_rgba
with a == 255
pub fn from_rgba_f32s(r: f32, g: f32, b: f32, a: f32) -> Self
[src]
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.
pub fn to_rgba_f32s(self) -> [f32; 4]
[src]
Return the channels as an array of f32 in [r, g, b, a]
order.
pub fn to_rgba(self) -> [u8; 4]
[src]
Return the channels as an array of u8 in [r, g, b, a]
order.
pub fn from_rgb_f32s(r: f32, g: f32, b: f32) -> Self
[src]
Equivalent to Self::from_rgba_f32s
, but with an alpha of 1.0 (e.g.
opaque).
pub const fn from_bits(u: u32) -> Self
[src]
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.
pub const fn to_bits(self) -> u32
[src]
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
impl Clone for ImColor32
[src]
impl Copy for ImColor32
[src]
impl Debug for ImColor32
[src]
impl Default for ImColor32
[src]
impl Deref for ImColor32
[src]
type Target = ImColor32Fields
The resulting type after dereferencing.
fn deref(&self) -> &ImColor32Fields
[src]
impl DerefMut for ImColor32
[src]
fn deref_mut(&mut self) -> &mut ImColor32Fields
[src]
impl Eq for ImColor32
[src]
impl From<[f32; 3]> for ImColor32
[src]
impl From<[f32; 4]> for ImColor32
[src]
impl From<(f32, f32, f32, f32)> for ImColor32
[src]
impl From<(f32, f32, f32)> for ImColor32
[src]
impl From<u32> for ImColor32
[src]
impl Hash for ImColor32
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for ImColor32
[src]
fn cmp(&self, other: &ImColor32) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<ImColor32> for ImColor32
[src]
impl PartialOrd<ImColor32> for ImColor32
[src]
fn partial_cmp(&self, other: &ImColor32) -> Option<Ordering>
[src]
fn lt(&self, other: &ImColor32) -> bool
[src]
fn le(&self, other: &ImColor32) -> bool
[src]
fn gt(&self, other: &ImColor32) -> bool
[src]
fn ge(&self, other: &ImColor32) -> bool
[src]
impl StructuralEq for ImColor32
[src]
impl StructuralPartialEq for ImColor32
[src]
Auto Trait Implementations
impl RefUnwindSafe for ImColor32
[src]
impl Send for ImColor32
[src]
impl Sync for ImColor32
[src]
impl Unpin for ImColor32
[src]
impl UnwindSafe for ImColor32
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,