Skip to main content

Color

Struct Color 

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

An sRGB color with 8-bit channels.

Ordering is lexicographic by (r, g, b) – red-major.

Fields§

§r: u8

Red channel (0-255).

§g: u8

Green channel (0-255).

§b: u8

Blue channel (0-255).

Implementations§

Source§

impl Color

Source

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

Create a new color from RGB components.

§Examples
use prismatica::Color;
let orange = Color::new(255, 165, 0);
assert_eq!(orange.r, 255);
Source

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

Create a color from a 24-bit hex value (e.g., 0xFF8800).

Only the lower 24 bits are used; higher bits are ignored.

§Examples
use prismatica::Color;
let orange = Color::from_hex(0xFF8800);
assert_eq!(orange, Color::new(255, 136, 0));
Source

pub const fn to_hex(self) -> u32

Serialize the color as a 24-bit hex value (e.g., 0xFF8800).

§Examples
use prismatica::Color;
let c = Color::new(255, 136, 0);
assert_eq!(c.to_hex(), 0xFF8800);
assert_eq!(Color::from_hex(c.to_hex()), c);
Source

pub fn to_css_hex(self) -> String

Available on crate features alloc or std only.

Format the color as a CSS hex string (e.g., "#ff8800").

§Examples
use prismatica::Color;
let c = Color::new(255, 136, 0);
assert_eq!(c.to_css_hex(), "#ff8800");
Source

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

Parse a CSS hex color string.

Accepts 6-digit ("#ff8800", "ff8800") 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 prismatica::Color;
assert_eq!(Color::from_css_hex("#ff8800"), Some(Color::new(255, 136, 0)));
assert_eq!(Color::from_css_hex("ff8800"), Some(Color::new(255, 136, 0)));
assert_eq!(Color::from_css_hex("#FFF"), Some(Color::new(255, 255, 255)));
assert_eq!(Color::from_css_hex("invalid"), None);
Source

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

Convert to floating-point RGB in [0.0, 1.0].

§Examples
use prismatica::Color;
let (r, g, b) = Color::new(255, 0, 128).to_f32();
assert!((r - 1.0).abs() < 0.01);
assert!(g < 0.01);
Source

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

Create a color from floating-point RGB in [0.0, 1.0].

Values outside [0.0, 1.0] are clamped. NaN produces 0 for the affected channel. This is the inverse of to_f32.

§Examples
use prismatica::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 in [0.0, 1.0] where 0 is black and 1 is white.

§Examples
use prismatica::Color;
let white = Color::new(255, 255, 255);
assert!((white.luminance() - 1.0).abs() < 0.01);
Source

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

WCAG contrast ratio between two colors.

Returns a value in [1.0, 21.0]. A ratio of 4.5+ meets WCAG AA for normal text; 7.0+ meets AAA.

§Examples
use prismatica::Color;
let ratio = Color::new(0, 0, 0).contrast_ratio(Color::new(255, 255, 255));
assert!((ratio - 21.0).abs() < 0.1);
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, matching the behavior of matplotlib, ParaView, and most scientific visualization tools.

§Examples
use prismatica::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 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Color

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

Source§

fn default() -> Self

Returns black (Color::new(0, 0, 0)).

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 color as a CSS hex string (e.g., #ff8800).

Source§

impl Eq for Color

Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<Color32> for Color

Available on crate feature egui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert an egui::Color32 to a prismatica Color.

The alpha channel is discarded.

§Examples

let c32 = egui::Color32::from_rgb(128, 64, 32);
let color: prismatica::Color = c32.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Color32) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for [u8; 3]

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color32

Available on crate feature egui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to an egui::Color32.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let c32: egui::Color32 = color.into();
assert_eq!(c32.r(), 255);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for RGBColor

Available on crate feature plotters-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a plotters::style::RGBColor.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let rgb: plotters::style::RGBColor = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Rgb<u8>

Available on crate feature image-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to an image::Rgb<u8> pixel.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let pixel: image::Rgb<u8> = color.into();
assert_eq!(pixel.0, [255, 128, 0]);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Srgb<u8>

Available on crate feature palette-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a palette::Srgb<u8>.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let srgb: palette::Srgb<u8> = color.into();
assert_eq!(srgb.red, 128);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Rgb

Available on crate feature owo-colors-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to an owo_colors::Rgb.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let rgb: owo_colors::Rgb = color.into();
assert_eq!(rgb.0, 255);
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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a termion::color::Rgb.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let rgb: termion::color::Rgb = color.into();
assert_eq!(rgb.0, 255);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature syntect-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a syntect::highlighting::Color.

The alpha channel is set to 255 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let sc: syntect::highlighting::Color = color.into();
assert_eq!(sc.r, 255);
assert_eq!(sc.a, 255);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature syntect-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a syntect::highlighting::Color to a prismatica Color.

The alpha channel is discarded.

§Examples

let sc = syntect::highlighting::Color { r: 128, g: 64, b: 32, a: 200 };
let color: prismatica::Color = sc.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature ratatui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a ratatui::style::Color::Rgb.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let rat: ratatui::style::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature crossterm-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a crossterm::style::Color::Rgb.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let ct: crossterm::style::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature colored-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a colored::Color::TrueColor.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let col: colored::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature cursive-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a cursive_core::theme::Color::Rgb.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let cur: cursive_core::theme::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature comfy-table-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a comfy_table::Color::Rgb.

§Examples

let color = prismatica::Color::new(128, 64, 32);
let ct: comfy_table::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Srgba

Available on crate feature bevy-color-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a bevy_color::Srgba.

The alpha channel is set to 1.0 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let srgba: bevy_color::Srgba = color.into();
assert_eq!(srgba.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 feature iced-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to an iced_core::Color.

The alpha channel is set to 1.0 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let ic: iced_core::Color = color.into();
assert_eq!(ic.a, 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 feature iced-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert an iced_core::Color to a prismatica Color.

The alpha channel is discarded.

§Examples

let ic = iced_core::Color { r: 0.5, g: 0.25, b: 0.125, a: 0.8 };
let color: prismatica::Color = ic.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature macroquad-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a macroquad::color::Color.

The alpha channel is set to 1.0 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let mc: macroquad::color::Color = color.into();
assert_eq!(mc.a, 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 feature macroquad-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a macroquad::color::Color to a prismatica Color.

The alpha channel is discarded.

§Examples

let mc = macroquad::color::Color::new(0.5, 0.25, 0.125, 0.8);
let color: prismatica::Color = mc.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature tiny-skia-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a tiny_skia::Color.

The alpha channel is set to 255 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let tc: tiny_skia::Color = color.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature tiny-skia-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a tiny_skia::Color to a prismatica Color.

The alpha channel is discarded.

§Examples

let tc = tiny_skia::Color::from_rgba8(128, 64, 32, 200);
let color: prismatica::Color = tc.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature wgpu-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a wgpu_types::Color.

The alpha channel is set to 1.0 (fully opaque).

§Examples

let color = prismatica::Color::new(255, 128, 0);
let wc: wgpu_types::Color = color.into();
assert_eq!(wc.a, 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 feature wgpu-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a wgpu_types::Color to a prismatica Color.

The alpha channel is discarded.

§Examples

let wc = wgpu_types::Color { r: 0.5, g: 0.25, b: 0.125, a: 0.8 };
let color: prismatica::Color = wc.into();
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature slint-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a prismatica Color to a slint::Color.

§Examples

let color = prismatica::Color::new(255, 128, 0);
let sc: slint::Color = color.into();
assert_eq!(sc.red(), 255);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Color

Available on crate feature slint-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a slint::Color to a prismatica Color.

§Examples

let sc = slint::Color::from_rgb_u8(128, 64, 32);
let color: prismatica::Color = sc.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<RGBColor> for Color

Available on crate feature plotters-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a plotters::style::RGBColor to a prismatica Color.

§Examples

let rgb = plotters::style::RGBColor(128, 64, 32);
let color: prismatica::Color = rgb.into();
assert_eq!(color.r, 128);
Source§

fn from(c: RGBColor) -> Self

Converts to this type from the input type.
Source§

impl From<Rgb<Srgb, u8>> for Color

Available on crate feature palette-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a palette::Srgb<u8> to a prismatica Color.

§Examples

let srgb = palette::Srgb::new(128u8, 64, 32);
let color: prismatica::Color = srgb.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Srgb<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<Rgb<u8>> for Color

Available on crate feature image-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert an image::Rgb<u8> pixel to a prismatica Color.

§Examples

let pixel = image::Rgb([128, 64, 32]);
let color: prismatica::Color = pixel.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Rgb<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<Rgb> for Color

Available on crate feature owo-colors-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert an owo_colors::Rgb to a prismatica Color.

§Examples

let rgb = owo_colors::Rgb(128, 64, 32);
let color: prismatica::Color = rgb.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Rgb) -> Self

Converts to this type from the input type.
Source§

impl From<Rgb> for Color

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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a termion::color::Rgb to a prismatica Color.

§Examples

let rgb = termion::color::Rgb(128, 64, 32);
let color: prismatica::Color = rgb.into();
assert_eq!(color.r, 128);
Source§

fn from(c: Rgb) -> Self

Converts to this type from the input type.
Source§

impl From<Srgba> for Color

Available on crate feature bevy-color-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Convert a bevy_color::Srgba to a prismatica Color.

The alpha channel is discarded.

§Examples

let srgba = bevy_color::Srgba::new(0.5, 0.25, 0.125, 0.8);
let color: prismatica::Color = srgba.into();
Source§

fn from(c: Srgba) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 3]> for Color

Source§

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

Converts to this type from the input type.
Source§

impl From<u32> for Color

Source§

fn from(hex: u32) -> Self

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

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

Source§

impl FromStr for Color

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

§Examples

use prismatica::Color;

let c: Color = "#ff8800".parse().unwrap();
assert_eq!(c, Color::from_hex(0xFF8800));
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 IntoFrameworkColor<Color32> for Color

Available on crate feature egui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color32

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature syntect-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature ratatui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature crossterm-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature colored-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature cursive-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature comfy-table-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature iced-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature macroquad-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature tiny-skia-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature wgpu-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Color> for Color

Available on crate feature slint-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Color

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<RGBColor> for Color

Available on crate feature plotters-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> RGBColor

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Rgb<Srgb, u8>> for Color

Available on crate feature palette-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Srgb<u8>

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Rgb<u8>> for Color

Available on crate feature image-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Rgb<u8>

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Rgb> for Color

Available on crate feature owo-colors-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Rgb

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Rgb> for Color

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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Rgb

Convert this color into the framework’s color type.
Source§

impl IntoFrameworkColor<Srgba> for Color

Available on crate feature bevy-color-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.
Source§

fn into_framework_color(self) -> Srgba

Convert this color into the framework’s color type.
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 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 StructuralPartialEq for Color

Source§

impl TryFrom<Color> for Color

Available on crate feature ratatui-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Try to convert a ratatui::style::Color to a prismatica Color.

Only the Rgb variant can be converted. Named colors (e.g., Red, Blue) and other variants return an error.

§Errors

Returns ConversionError if the color is not a Color::Rgb variant.

§Examples

use prismatica::Color;

let rgb = ratatui::style::Color::Rgb(128, 64, 32);
assert!(Color::try_from(rgb).is_ok());

let named = ratatui::style::Color::Red;
assert!(Color::try_from(named).is_err());
Source§

type Error = ConversionError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Color> for Color

Available on crate feature crossterm-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Try to convert a crossterm::style::Color to a prismatica Color.

Only the Rgb variant can be converted. Named colors (e.g., Red, Blue) and other variants return an error.

§Errors

Returns ConversionError if the color is not a Color::Rgb variant.

§Examples

use prismatica::Color;

let rgb = crossterm::style::Color::Rgb { r: 128, g: 64, b: 32 };
assert!(Color::try_from(rgb).is_ok());

let named = crossterm::style::Color::Red;
assert!(Color::try_from(named).is_err());
Source§

type Error = ConversionError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Color> for Color

Available on crate feature colored-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Try to convert a colored::Color to a prismatica Color.

Only the TrueColor variant can be converted. Named colors (e.g., Red, Blue) and other variants return an error.

§Errors

Returns ConversionError if the color is not a Color::TrueColor variant.

§Examples

use prismatica::Color;

let rgb = colored::Color::TrueColor { r: 128, g: 64, b: 32 };
assert!(Color::try_from(rgb).is_ok());

let named = colored::Color::Red;
assert!(Color::try_from(named).is_err());
Source§

type Error = ConversionError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Color> for Color

Available on crate feature cursive-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Try to convert a cursive_core::theme::Color to a prismatica Color.

Only the Rgb variant can be converted. Named colors (e.g., Dark, Light) and other variants return an error.

§Errors

Returns ConversionError if the color is not a Color::Rgb variant.

§Examples

use prismatica::Color;

let rgb = cursive_core::theme::Color::Rgb(128, 64, 32);
assert!(Color::try_from(rgb).is_ok());

let named = cursive_core::theme::Color::Dark(cursive_core::theme::BaseColor::Red);
assert!(Color::try_from(named).is_err());
Source§

type Error = ConversionError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Color> for Color

Available on crate feature comfy-table-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 serde-support or slint-integration or syntect-integration or termion-integration or tiny-skia-integration or wgpu-integration) only.

Try to convert a comfy_table::Color to a prismatica Color.

Only the Rgb variant can be converted. Named colors (e.g., Red, Blue) and other variants return an error.

§Errors

Returns ConversionError if the color is not a Color::Rgb variant.

§Examples

use prismatica::Color;

let rgb = comfy_table::Color::Rgb { r: 128, g: 64, b: 32 };
assert!(Color::try_from(rgb).is_ok());

let named = comfy_table::Color::Red;
assert!(Color::try_from(named).is_err());
Source§

type Error = ConversionError

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

fn try_from(c: Color) -> Result<Self, Self::Error>

Performs the conversion.

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<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 + Send + Sync>

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

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<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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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

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