Struct GradientDisplay

Source
pub struct GradientDisplay<'a, I> { /* private fields */ }
Expand description

A gradient string representation.

Implementations§

Source§

impl<'a, I> GradientDisplay<'a, I>

Source

pub const fn background(self) -> Self

Colorize background.

Default is foreground.

Examples found in repository?
examples/list.rs (line 50)
14fn main() {
15    let logo = LOGO
16        .lines()
17        .map(|l| format!("\t\t{}", l))
18        .collect::<Vec<_>>()
19        .join("\n");
20    let raibow = [
21        RGB::new(255, 0, 0),
22        RGB::new(0, 255, 0),
23        RGB::new(0, 0, 255),
24    ];
25
26    println!("{}", logo.gradient(raibow));
27
28    println!();
29
30    let gradients = [
31        Gradient::Atlast,
32        Gradient::Cristal,
33        Gradient::Fruit,
34        Gradient::Instagram,
35        Gradient::Mind,
36        Gradient::Morning,
37        Gradient::Passion,
38        Gradient::Pastel,
39        Gradient::Rainbow,
40        Gradient::Retro,
41        Gradient::Summer,
42        Gradient::Teen,
43        Gradient::Vice,
44        Gradient::Monsoon,
45        Gradient::Forest,
46    ];
47
48    gradients.into_iter().for_each(|gradient| {
49        let short = " ".repeat(10);
50        let short = short.gradient(gradient).background();
51        let long = " ".repeat(100);
52        let long = long.gradient(gradient).background();
53        let name = format!("{:?}", gradient);
54        println!(" {:<15} {} {}", name, short, long);
55    });
56}
Source

pub const fn foreground(self) -> Self

Colorize foreground.

It’s a default option.

Trait Implementations§

Source§

impl<'a, I: Clone> Clone for GradientDisplay<'a, I>

Source§

fn clone(&self) -> GradientDisplay<'a, I>

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

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

Performs copy-assignment from source. Read more
Source§

impl<'a, I: Debug> Debug for GradientDisplay<'a, I>

Source§

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

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

impl<I> Display for GradientDisplay<'_, I>

Source§

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

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

impl<'a, I: Ord> Ord for GradientDisplay<'a, I>

Source§

fn cmp(&self, other: &GradientDisplay<'a, I>) -> 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<'a, I: PartialEq> PartialEq for GradientDisplay<'a, I>

Source§

fn eq(&self, other: &GradientDisplay<'a, I>) -> 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<'a, I: PartialOrd> PartialOrd for GradientDisplay<'a, I>

Source§

fn partial_cmp(&self, other: &GradientDisplay<'a, I>) -> 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<'a, I: Eq> Eq for GradientDisplay<'a, I>

Source§

impl<'a, I> StructuralPartialEq for GradientDisplay<'a, I>

Auto Trait Implementations§

§

impl<'a, I> Freeze for GradientDisplay<'a, I>
where I: Freeze,

§

impl<'a, I> RefUnwindSafe for GradientDisplay<'a, I>
where I: RefUnwindSafe,

§

impl<'a, I> Send for GradientDisplay<'a, I>
where I: Send,

§

impl<'a, I> Sync for GradientDisplay<'a, I>
where I: Sync,

§

impl<'a, I> Unpin for GradientDisplay<'a, I>
where I: Unpin,

§

impl<'a, I> UnwindSafe for GradientDisplay<'a, I>
where I: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> 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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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