Struct rerun::external::eframe::egui::Color32

source ·
#[repr(C)]
pub struct Color32(/* private fields */);
Expand description

This format is used for space-efficient color representation (32 bits).

Instead of manipulating this directly it is often better to first convert it to either Rgba or crate::Hsva.

Internally this uses 0-255 gamma space sRGBA color with premultiplied alpha. Alpha channel is in linear space.

The special value of alpha=0 means the color is to be treated as an additive color.

Implementations§

source§

impl Color32

source

pub const TRANSPARENT: Color32 = _

source

pub const BLACK: Color32 = _

source

pub const DARK_GRAY: Color32 = _

source

pub const GRAY: Color32 = _

source

pub const LIGHT_GRAY: Color32 = _

source

pub const WHITE: Color32 = _

source

pub const BROWN: Color32 = _

source

pub const DARK_RED: Color32 = _

source

pub const RED: Color32 = _

source

pub const LIGHT_RED: Color32 = _

source

pub const YELLOW: Color32 = _

source

pub const LIGHT_YELLOW: Color32 = _

source

pub const KHAKI: Color32 = _

source

pub const DARK_GREEN: Color32 = _

source

pub const GREEN: Color32 = _

source

pub const LIGHT_GREEN: Color32 = _

source

pub const DARK_BLUE: Color32 = _

source

pub const BLUE: Color32 = _

source

pub const LIGHT_BLUE: Color32 = _

source

pub const GOLD: Color32 = _

source

pub const DEBUG_COLOR: Color32 = _

source

pub const PLACEHOLDER: Color32 = _

An ugly color that is planned to be replaced before making it to the screen.

This is an invalid color, in that it does not correspond to a valid multiplied color, nor to an additive color.

This is used as a special color key, i.e. often taken to mean “no color”.

source

pub const TEMPORARY_COLOR: Color32 = Self::PLACEHOLDER

👎Deprecated: Renamed to PLACEHOLDER
source

pub const fn from_rgb(r: u8, g: u8, b: u8) -> Color32

source

pub const fn from_rgb_additive(r: u8, g: u8, b: u8) -> Color32

source

pub const fn from_rgba_premultiplied(r: u8, g: u8, b: u8, a: u8) -> Color32

From sRGBA with premultiplied alpha.

source

pub fn from_rgba_unmultiplied(r: u8, g: u8, b: u8, a: u8) -> Color32

From sRGBA WITHOUT premultiplied alpha.

source

pub const fn from_gray(l: u8) -> Color32

source

pub const fn from_black_alpha(a: u8) -> Color32

source

pub fn from_white_alpha(a: u8) -> Color32

source

pub const fn from_additive_luminance(l: u8) -> Color32

source

pub const fn is_opaque(&self) -> bool

source

pub const fn r(&self) -> u8

source

pub const fn g(&self) -> u8

source

pub const fn b(&self) -> u8

source

pub const fn a(&self) -> u8

source

pub fn to_opaque(self) -> Color32

Returns an opaque version of self

source

pub const fn additive(self) -> Color32

Returns an additive version of self

source

pub fn is_additive(self) -> bool

Is the alpha=0 ?

source

pub const fn to_array(&self) -> [u8; 4]

Premultiplied RGBA

source

pub const fn to_tuple(&self) -> (u8, u8, u8, u8)

Premultiplied RGBA

source

pub fn to_srgba_unmultiplied(&self) -> [u8; 4]

source

pub fn gamma_multiply(self, factor: f32) -> Color32

Multiply with 0.5 to make color half as opaque, perceptually.

Fast multiplication in gamma-space.

This is perceptually even, and faster that Self::linear_multiply.

source

pub fn linear_multiply(self, factor: f32) -> Color32

Multiply with 0.5 to make color half as opaque in linear space.

This is using linear space, which is not perceptually even. You may want to use Self::gamma_multiply instead.

source

pub fn to_normalized_gamma_f32(self) -> [f32; 4]

Converts to floating point values in the range 0-1 without any gamma space conversion.

Use this with great care! In almost all cases, you want to convert to crate::Rgba instead in order to obtain linear space color values.

source§

impl Color32

source

pub fn from_hex(hex: &str) -> Result<Color32, ParseHexColorError>

Parses a color from a hex string.

Supports the 3, 4, 6, and 8-digit formats, according to the specification in https://drafts.csswg.org/css-color-4/#hex-color

To parse hex colors at compile-time (e.g. for use in const contexts) use the macro [crate::hex_color!] instead.

§Example
use ecolor::Color32;
assert_eq!(Ok(Color32::RED), Color32::from_hex("#ff0000"));
assert_eq!(Ok(Color32::GREEN), Color32::from_hex("#00ff00ff"));
assert_eq!(Ok(Color32::BLUE), Color32::from_hex("#00f"));
assert_eq!(Ok(Color32::TRANSPARENT), Color32::from_hex("#0000"));
§Errors

Returns an error if the string doesn’t start with the hash # character, if the remaining length does not correspond to one of the standard formats (3, 4, 6, or 8), if it contains non-hex characters.

source

pub fn to_hex(&self) -> String

Formats the color as a hex string.

§Example
use ecolor::Color32;
assert_eq!(Color32::RED.to_hex(), "#ff0000ff");
assert_eq!(Color32::GREEN.to_hex(), "#00ff00ff");
assert_eq!(Color32::BLUE.to_hex(), "#0000ffff");
assert_eq!(Color32::TRANSPARENT.to_hex(), "#00000000");

Uses the 8-digit format described in https://drafts.csswg.org/css-color-4/#hex-color, as that is the only format that is lossless. For other formats, see HexColor.

Trait Implementations§

source§

impl Clone for Color32

source§

fn clone(&self) -> Color32

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Color32

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Color32

source§

fn default() -> Color32

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

impl<'de> Deserialize<'de> for Color32

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<Color32, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Color> for Color32

source§

fn from(color: Color) -> Color32

Converts to this type from the input type.
source§

impl From<Color32> for Hsva

source§

fn from(srgba: Color32) -> Hsva

Converts to this type from the input type.
source§

impl From<Color32> for HsvaGamma

source§

fn from(srgba: Color32) -> HsvaGamma

Converts to this type from the input type.
source§

impl From<Color32> for Rgba

source§

fn from(srgba: Color32) -> Rgba

Converts to this type from the input type.
source§

impl From<Color32> for Rgba32

source§

fn from(val: Color32) -> Rgba32

Converts to this type from the input type.
source§

impl From<Hsva> for Color32

source§

fn from(hsva: Hsva) -> Color32

Converts to this type from the input type.
source§

impl From<HsvaGamma> for Color32

source§

fn from(hsvag: HsvaGamma) -> Color32

Converts to this type from the input type.
source§

impl From<Rgba> for Color32

source§

fn from(rgba: Rgba) -> Color32

Converts to this type from the input type.
source§

impl From<Rgba32> for Color32

source§

fn from(color: Rgba32) -> Color32

Converts to this type from the input type.
source§

impl Hash for Color32

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl Index<usize> for Color32

§

type Output = u8

The returned type after indexing.
source§

fn index(&self, index: usize) -> &u8

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Color32

source§

fn index_mut(&mut self, index: usize) -> &mut u8

Performs the mutable indexing (container[index]) operation. Read more
source§

impl PartialEq for Color32

source§

fn eq(&self, other: &Color32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Color32

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Zeroable for Color32

source§

fn zeroed() -> Self

source§

impl Copy for Color32

source§

impl Eq for Color32

source§

impl Pod for Color32

source§

impl StructuralPartialEq for Color32

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

source§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> AnyBitPattern for T
where T: Pod,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> NoUninit for T
where T: Pod,

source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> + Send + Sync,

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,