pub enum Color {
Default,
Indexed(u8),
Rgb(u8, u8, u8),
}Expand description
A terminal foreground or background color.
Variants§
Default
The terminal’s configured default color.
Indexed(u8)
An indexed color from the terminal’s 256-color palette.
Rgb(u8, u8, u8)
A 24-bit RGB color.
Implementations§
Source§impl Color
impl Color
Sourcepub fn parse(value: &str) -> Option<Self>
pub fn parse(value: &str) -> Option<Self>
Parses any CSS color and lowers it to a cell color without
context: fully transparent values and currentcolor become
Color::Default (the terminal’s pass-through color),
translucent values keep their color unblended, and system
colors — which need a theme — return None. Parse a
CssColor instead when alpha, currentcolor,
or system colors must survive to a context-aware lowering.
§Example
use omp_tui::Color;
assert_eq!(Color::parse("rebeccapurple"), Some(Color::Rgb(0x66, 0x33, 0x99)));
assert_eq!(Color::parse("hsl(120 100% 50%)"), Some(Color::Rgb(0, 255, 0)));
assert_eq!(Color::parse("transparent"), Some(Color::Default));
assert_eq!(Color::parse("rgb(255 0 0 / 0)"), Some(Color::Default));
assert_eq!(Color::parse("Canvas"), None);Trait Implementations§
impl Copy for Color
impl Eq for Color
Source§impl Lerp for Color
RGB endpoints blend per channel; palette and default endpoints have no
interpolable space, so they snap at the halfway point.
impl Lerp for Color
RGB endpoints blend per channel; palette and default endpoints have no interpolable space, so they snap at the halfway point.
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<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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