pub struct RGB<T = u8> {
pub r: T,
pub g: T,
pub b: T,
}
Expand description
Red Green Blue
Fields§
§r: T
Red
g: T
Green
b: T
Blue
Implementations§
Source§impl<T> RGB<T>
impl<T> RGB<T>
Sourcepub const fn new(r: T, g: T, b: T) -> Self
pub const fn new(r: T, g: T, b: T) -> Self
Creates a new RGB
Examples found in repository?
examples/list.rs (line 21)
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}
Trait Implementations§
Source§impl<T: Ord> Ord for RGB<T>
impl<T: Ord> Ord for RGB<T>
Source§impl<T: PartialOrd> PartialOrd for RGB<T>
impl<T: PartialOrd> PartialOrd for RGB<T>
impl<T: Copy> Copy for RGB<T>
impl<T: Eq> Eq for RGB<T>
impl<T> StructuralPartialEq for RGB<T>
Auto Trait Implementations§
impl<T> Freeze for RGB<T>where
T: Freeze,
impl<T> RefUnwindSafe for RGB<T>where
T: RefUnwindSafe,
impl<T> Send for RGB<T>where
T: Send,
impl<T> Sync for RGB<T>where
T: Sync,
impl<T> Unpin for RGB<T>where
T: Unpin,
impl<T> UnwindSafe for RGB<T>where
T: UnwindSafe,
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