Skip to main content

Color

Struct Color 

Source
pub struct Color {
    pub r: u8,
    pub g: u8,
    pub b: u8,
}
Expand description

A color represented as RGB components. All values are compile-time constants with zero runtime cost.

Ordering is lexicographic by (r, g, b).

Fields§

§r: u8

Red component (0–255).

§g: u8

Green component (0–255).

§b: u8

Blue component (0–255).

Implementations§

Source§

impl Color

Source

pub const fn new(r: u8, g: u8, b: u8) -> Self

Construct a Color from RGB components.

§Examples
use chromata::Color;

let red = Color::new(255, 0, 0);
assert_eq!(red.r, 255);
assert_eq!(red.g, 0);
Source

pub const fn from_hex(hex: u32) -> Self

Construct a Color from a 24-bit hex value (0xRRGGBB).

§Examples
use chromata::Color;

let c = Color::from_hex(0x1d2021);
assert_eq!(c.r, 0x1d);
assert_eq!(c.g, 0x20);
assert_eq!(c.b, 0x21);
Source

pub const fn from_css_hex(s: &str) -> Option<Color>

Construct a Color by parsing a CSS hex string.

Accepts 6-digit ("#1d2021", "1d2021") and 3-digit shorthand ("#FFF", "FFF") formats. The 3-digit form expands each digit (e.g., #ABC becomes #AABBCC).

Returns None if the string is not a valid hex color.

§Examples
use chromata::Color;

let c = Color::from_css_hex("#1d2021").unwrap();
assert_eq!(c, Color::from_hex(0x1d2021));

let c = Color::from_css_hex("1d2021").unwrap();
assert_eq!(c, Color::from_hex(0x1d2021));

let c = Color::from_css_hex("#FFF").unwrap();
assert_eq!(c, Color::new(255, 255, 255));

assert!(Color::from_css_hex("nope").is_none());
Source

pub const fn to_hex(self) -> u32

Return the color as a 24-bit hex value.

§Examples
use chromata::Color;

let c = Color::new(0x1d, 0x20, 0x21);
assert_eq!(c.to_hex(), 0x1d2021);
Source

pub fn to_css_hex(self) -> String

Return the color as a CSS hex string like “#1d2021”.

§Examples
use chromata::Color;

let c = Color::from_hex(0x1d2021);
assert_eq!(c.to_css_hex(), "#1d2021");
Source

pub const fn to_f32(self) -> (f32, f32, f32)

Convert to an (f32, f32, f32) tuple in [0.0, 1.0] range.

§Examples
use chromata::Color;

let white = Color::new(255, 255, 255);
let (r, g, b) = white.to_f32();
assert!((r - 1.0).abs() < f32::EPSILON);
Source

pub fn from_f32(r: f32, g: f32, b: f32) -> Self

Construct a Color from normalized [0.0, 1.0] RGB components.

Values are clamped to [0.0, 1.0] and rounded to the nearest u8. NaN is treated as 0.0.

§Examples
use chromata::Color;

let c = Color::from_f32(1.0, 0.5, 0.0);
assert_eq!(c, Color::new(255, 128, 0));
Source

pub fn luminance(self) -> f64

Relative luminance per WCAG 2.0.

Returns a value between 0.0 (black) and 1.0 (white).

§Examples
use chromata::Color;

let black = Color::new(0, 0, 0);
let white = Color::new(255, 255, 255);
assert!((black.luminance()).abs() < 0.001);
assert!((white.luminance() - 1.0).abs() < 0.001);
Source

pub fn contrast_ratio(self, other: Color) -> f64

WCAG contrast ratio between two colors.

Returns a value between 1.0 (identical) and 21.0 (black vs white).

§Examples
use chromata::Color;

let black = Color::new(0, 0, 0);
let white = Color::new(255, 255, 255);
let ratio = black.contrast_ratio(white);
assert!(ratio > 20.0); // ~21:1 for black/white
Source

pub fn lerp(self, other: Color, t: f32) -> Color

Linear interpolation between two colors.

t is clamped to [0.0, 1.0]. Interpolation is performed in sRGB space.

§Examples
use chromata::Color;

let black = Color::new(0, 0, 0);
let white = Color::new(255, 255, 255);
let mid = black.lerp(white, 0.5);
assert_eq!(mid, Color::new(127, 127, 127));

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate 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 Color

Source§

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

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

impl Default for Color

Default Color is black (0, 0, 0).

§Examples

use chromata::Color;

assert_eq!(Color::default(), Color::new(0, 0, 0));
Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Color

Source§

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

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

impl Display for Color

Source§

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

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

impl From<[u8; 3]> for Color

Construct a Color from an [r, g, b] array.

§Examples

use chromata::Color;

let c: Color = [29, 32, 33].into();
assert_eq!(c, Color::new(29, 32, 33));
Source§

fn from([r, g, b]: [u8; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8)> for Color

Construct a Color from an (r, g, b) tuple.

§Examples

use chromata::Color;

let c: Color = (29, 32, 33).into();
assert_eq!(c, Color::new(29, 32, 33));
Source§

fn from((r, g, b): (u8, u8, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for [u8; 3]

Extract the [r, g, b] components from a Color.

§Examples

use chromata::Color;

let arr: [u8; 3] = Color::new(29, 32, 33).into();
assert_eq!(arr, [29, 32, 33]);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for (u8, u8, u8)

Extract the (r, g, b) components from a Color.

§Examples

use chromata::Color;

let (r, g, b): (u8, u8, u8) = Color::new(29, 32, 33).into();
assert_eq!((r, g, b), (29, 32, 33));
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature colored-integration only.

Convert a chromata Color to a colored TrueColor.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature comfy-table-integration only.

Convert a chromata Color to a comfy-table RGB color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature crossterm-integration only.

Convert a chromata Color to a crossterm RGB color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature cursive-integration only.

Convert a chromata Color to a cursive RGB color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature iced-integration only.

Convert a chromata Color to an iced RGBA color (alpha = 1.0).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature macroquad-integration only.

Convert a chromata Color to a macroquad RGBA color (alpha = 1.0).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature ratatui-integration only.

Convert a chromata Color to a ratatui RGB color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature slint-integration only.

Convert a chromata Color to a Slint RGB color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature syntect-integration only.

Convert a chromata Color to a syntect RGBA color (alpha = 255).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature wgpu-integration only.

Convert a chromata Color to a wgpu RGBA color (alpha = 1.0).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color32

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature egui-integration only.

Convert a chromata Color to an egui Color32.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for PremultipliedColorU8

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature tiny-skia-integration only.

Convert a chromata Color to a tiny-skia premultiplied RGBA color (alpha = 255).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for RGBColor

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature plotters-integration only.

Convert a chromata Color to a plotters RGBColor.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Rgb

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature owo-colors-integration only.

Convert a chromata Color to an owo-colors Rgb.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Srgb<u8>

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature palette-integration only.

Convert a chromata Color to a palette sRGB color with u8 components.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Rgb<u8>

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature image-integration only.

Convert a chromata Color to an image Rgb pixel.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Rgb

Available on Unix and crate feature termion-integration and (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a chromata Color to a termion Rgb color.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Srgba

Available on (crate features bevy-color-integration or colored-integration or comfy-table-integration or crossterm-integration or cursive-integration or egui-integration or iced-integration or image-integration or macroquad-integration or owo-colors-integration or palette-integration or plotters-integration or ratatui-integration or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) and crate feature bevy-color-integration only.

Convert a chromata Color to a Bevy sRGBA color (alpha = 1.0).

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for u32

Extract the 24-bit hex value from a Color.

§Examples

use chromata::Color;

let v: u32 = Color::from_hex(0x1d2021).into();
assert_eq!(v, 0x1d2021);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Color

Construct a Color from a 24-bit hex value (0xRRGGBB).

Only the lower 24 bits are used; upper bits are silently ignored.

§Examples

use chromata::Color;

let c: Color = 0x1d2021u32.into();
assert_eq!(c, Color::from_hex(0x1d2021));
Source§

fn from(hex: u32) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Color

Parse a CSS hex color string like "#1d2021", "1d2021", "#FFF", or "FFF".

§Examples

use chromata::Color;

let c: Color = "#1d2021".parse().unwrap();
assert_eq!(c, Color::from_hex(0x1d2021));
Source§

type Err = ParseColorError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Color

Source§

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

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 Ord for Color

Source§

fn cmp(&self, other: &Color) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Color

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Color

Source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

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

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Color

Source§

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

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

impl Copy for Color

Source§

impl Eq for Color

Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnsafeUnpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

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

Source§

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

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts &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)

Converts &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> 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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
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<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> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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<T, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

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

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

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

Source§

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> ToSharedString for T
where T: Display + ?Sized,

Source§

fn to_shared_string(&self) -> SharedString

Converts the given value to a SharedString.
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

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

Source§

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>,

Source§

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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'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,