pub trait RGBColor: Sized {
    const HUE: Hue<Self> = _;
Show 47 methods // Required methods fn to_rgba(&self) -> RGBA<f64>; fn from_rgba(rgba: RGBA<f64>) -> Self; // Provided methods fn gradient(&self, c1: &Self) -> Gradient<Self> { ... } fn palettes(len: usize) -> PaletteFind<Self> { ... } fn magma() -> Palette<Self> { ... } fn inferno() -> Palette<Self> { ... } fn plasma() -> Palette<Self> { ... } fn viridis() -> Palette<Self> { ... } fn cividis() -> Palette<Self> { ... } fn twilight() -> Palette<Self> { ... } fn turbo() -> Palette<Self> { ... } fn ylgn() -> PaletteIter<Self> { ... } fn ylgnbu() -> PaletteIter<Self> { ... } fn gnbu() -> PaletteIter<Self> { ... } fn bugn() -> PaletteIter<Self> { ... } fn pubugn() -> PaletteIter<Self> { ... } fn pubu() -> PaletteIter<Self> { ... } fn bupu() -> PaletteIter<Self> { ... } fn rdpu() -> PaletteIter<Self> { ... } fn purd() -> PaletteIter<Self> { ... } fn orrd() -> PaletteIter<Self> { ... } fn ylorrd() -> PaletteIter<Self> { ... } fn ylorbr() -> PaletteIter<Self> { ... } fn purples() -> PaletteIter<Self> { ... } fn blues() -> PaletteIter<Self> { ... } fn greens() -> PaletteIter<Self> { ... } fn oranges() -> PaletteIter<Self> { ... } fn reds() -> PaletteIter<Self> { ... } fn greys() -> PaletteIter<Self> { ... } fn puor() -> PaletteIter<Self> { ... } fn brbg() -> PaletteIter<Self> { ... } fn prgn() -> PaletteIter<Self> { ... } fn piyg() -> PaletteIter<Self> { ... } fn rdbu() -> PaletteIter<Self> { ... } fn rdgy() -> PaletteIter<Self> { ... } fn rdylbu() -> PaletteIter<Self> { ... } fn spectral() -> PaletteIter<Self> { ... } fn rdylgn() -> PaletteIter<Self> { ... } fn set1() -> PaletteIter<Self> { ... } fn pastel1() -> PaletteIter<Self> { ... } fn set2() -> PaletteIter<Self> { ... } fn pastel2() -> PaletteIter<Self> { ... } fn dark2() -> PaletteIter<Self> { ... } fn set3() -> PaletteIter<Self> { ... } fn paired() -> PaletteIter<Self> { ... } fn accent() -> PaletteIter<Self> { ... } fn to_gray(&self) -> Self { ... }
}
Expand description

Specifies the methods a RGB color encoding must provide.

Provided Associated Constants§

source

const HUE: Hue<Self> = _

Return the color corresponding to the hue h ∈ [0., 1.].

Example
use rgb::RGB8;
use color_brewery::{RGBColor, ColorRange};
let rgb = RGB8::HUE.rgb(0.5);

Required Methods§

source

fn to_rgba(&self) -> RGBA<f64>

Return the red, green, blue and alpha components of the color (in [0, 255]).

source

fn from_rgba(rgba: RGBA<f64>) -> Self

Create a color from its RGBA components (in [0, 255]).

Provided Methods§

source

fn gradient(&self, c1: &Self) -> Gradient<Self>

Return a gradient from color c0 to color c1.

Example
use rgb::RGB8;
use color_brewery::{RGBColor, ColorRange};
let red = RGB8::new(255,0, 0);
let blue = RGB8::new(0, 0, 255);
let grad = red.gradient(&blue);
let rgb = grad.rgb(0.5);
Examples found in repository?
examples/gradient.rs (line 48)
44
45
46
47
48
49
50
fn gradient(fh: &mut impl Write, c0: [u8; 3], c1: [u8; 3], n: usize,
            width: u32, comment: &str) -> Result<(), Err> {
    let c0 = RGB8{ r: c0[0], g: c0[1], b: c0[2] };
    let c1 = RGB8{ r: c1[0], g: c1[1], b: c1[2] };
    let g = c0.gradient(&c1);
    range(fh, |t| g.rgb(t), n, width, comment)
}
source

fn palettes(len: usize) -> PaletteFind<Self>

Find palettes matching certain criteria.

source

fn magma() -> Palette<Self>

Matplotlib magma color scheme.

magma
Examples found in repository?
examples/gradient.rs (line 86)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn inferno() -> Palette<Self>

Matplotlib inferno color scheme.

inferno
Examples found in repository?
examples/gradient.rs (line 87)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn plasma() -> Palette<Self>

Matplotlib plasma color scheme.

plasma
Examples found in repository?
examples/gradient.rs (line 88)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn viridis() -> Palette<Self>

Matplotlib viridis color scheme.

viridis
Examples found in repository?
examples/gradient.rs (line 85)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn cividis() -> Palette<Self>

Matplotlib cividis color scheme.

cividis
Examples found in repository?
examples/gradient.rs (line 90)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn twilight() -> Palette<Self>

Matplotlib twilight color scheme.

Examples found in repository?
examples/gradient.rs (line 91)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn turbo() -> Palette<Self>

Matplotlib turbo color scheme.

turbo
Examples found in repository?
examples/gradient.rs (line 92)
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
fn main() -> Result<(), Err> {
    let mut fh = BufWriter::new(File::create("gradient.html")?);
    writeln!(fh, "<html>\n\
                  <head>\n\
                  <title>Color_brewery: test {}</title>\n\
                  </head>\n\
                  <body>",
             env::args().next().unwrap())?;
    writeln!(fh, "<h3>Hue</h3>")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 10, 43, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 30, 13, "")?;
    range(&mut fh, |t| RGB8::HUE.rgb(t), 150, 1, "")?;

    writeln!(fh, "<h3>Gradients</h3>")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 10, 43, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 30, 13, "")?;
    gradient(&mut fh, [94, 0, 99], [255, 235, 170], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [255, 0, 0], [0, 255, 0], 150, 1,
             "Best <a href=\"https://youtu.be/XjHzLUnHeM0?t=230\"
              >to avoid red and green</a>.")?;
    gradient(&mut fh, [0, 0, 0], [255, 255, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 0], [0, 0, 255], 150, 1, "")?;
    gradient(&mut fh, [0, 0, 128], [144, 144, 255], 150, 1, "")?;

    writeln!(fh, "<h3>Palettes (sequential and diverging)</h3>")?;
    for (comment, p) in [("viridis", RGB8::viridis()),
                         ("magma", RGB8::magma()),
                         ("inferno", RGB8::inferno()),
                         ("plasma", RGB8::plasma()),
                         ("viridis", RGB8::viridis()),
                         ("cividis", RGB8::cividis()),
                         ("twilight", RGB8::twilight()),
                         ("turbo", RGB8::turbo())] {
        palette(&mut fh, p, 256, 1, comment)?;
    }

    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
            palette(&mut fh, p, 128, 1,
                    &format!("{} (interpolated)", stringify!($name)))?;
        } )*
    }}
    palette!(ylgn, ylgnbu, gnbu, bugn, pubugn, pubu, bupu, rdpu, purd,
             orrd, ylorrd, ylorbr, purples, blues, greens, oranges,
             reds, greys,
             // Diverging
             puor, brbg, prgn, piyg, rdbu, rdgy, rdylbu, spectral, rdylgn);

    writeln!(fh, "<h3>Palettes (others)</h3>")?;
    macro_rules! palette { ($($name: ident),*) => {
        $( if let Some(p) = RGB8::$name().last() {
            let c = format!("{} ({} colors)", stringify!($name), p.len());
            table_of_colors(&mut fh, &p.colors(), 40, &c)?;
        } )*
    }}
    palette!(set1, pastel1, set2, pastel2, dark2, set3, paired, accent);

    writeln!(fh, "</body>\n\
                  </html>")?;
    Ok(())
}
source

fn ylgn() -> PaletteIter<Self>

Brewer “Light yellow to dark green” sequential scheme.

ylgn
source

fn ylgnbu() -> PaletteIter<Self>

Brewer “Light yellow to green to dark blue” sequential scheme.

ylgnbu
source

fn gnbu() -> PaletteIter<Self>

Brewer “Light green to dark blue” sequential scheme.

gnbu
source

fn bugn() -> PaletteIter<Self>

Brewer “Light blue to dark green” sequential scheme.

bugn
source

fn pubugn() -> PaletteIter<Self>

Brewer “Light purple to blue to dark green” sequential scheme.

pubugn
source

fn pubu() -> PaletteIter<Self>

Brewer “Light purple to dark blue” sequential scheme.

pubu
source

fn bupu() -> PaletteIter<Self>

Brewer “Light blue to dark purple” sequential scheme.

bupu
source

fn rdpu() -> PaletteIter<Self>

Brewer “Light red to dark purple” sequential scheme.

rdpu
source

fn purd() -> PaletteIter<Self>

Brewer “Light purple to dark red” sequential scheme.

purd
source

fn orrd() -> PaletteIter<Self>

Brewer “Light orange to dark red” sequential scheme.

orrd
source

fn ylorrd() -> PaletteIter<Self>

Brewer “Light yellow to orange to dark red” sequential scheme.

ylorrd
source

fn ylorbr() -> PaletteIter<Self>

Brewer “Light yellow to orange to dark brown” sequential scheme.

ylorbr
source

fn purples() -> PaletteIter<Self>

Brewer “Light to dark purple” sequential scheme.

purples
source

fn blues() -> PaletteIter<Self>

Brewer “Light to dark blue” sequential scheme.

blues
source

fn greens() -> PaletteIter<Self>

Brewer “Light to dark green” sequential scheme.

greens
source

fn oranges() -> PaletteIter<Self>

Brewer “Light to dark orange” sequential scheme.

oranges
source

fn reds() -> PaletteIter<Self>

Brewer “Light to dark red” sequential scheme.

reds
source

fn greys() -> PaletteIter<Self>

Brewer “Light to dark gray” sequential scheme.

greys
source

fn puor() -> PaletteIter<Self>

Brewer “Dark orange to light to dark purple” diverging scheme

puor
source

fn brbg() -> PaletteIter<Self>

Brewer “Dark brown to light to dark blue-green” diverging scheme

brbg
source

fn prgn() -> PaletteIter<Self>

Brewer “Dark reddish-purple to light to dark green” diverging scheme

prgn
source

fn piyg() -> PaletteIter<Self>

Brewer “Dark magenta to light to dark yellow-green” diverging scheme

piyg
source

fn rdbu() -> PaletteIter<Self>

Brewer “Dark red to light to dark blue” diverging scheme.

rdbu
source

fn rdgy() -> PaletteIter<Self>

Brewer “Dark red to light to dark grey” diverging scheme.

rdgy
source

fn rdylbu() -> PaletteIter<Self>

Brewer “Dark red to light yelow to dark blue” diverging scheme.

rdylbu
source

fn spectral() -> PaletteIter<Self>

Brewer “Dark red, orange, light yellow, green, dark blue” diverging scheme.

spectral
source

fn rdylgn() -> PaletteIter<Self>

Brewer “Dark red, orange, light yellow, yellow-green, dark green” diverging scheme.

rdylgn
source

fn set1() -> PaletteIter<Self>

Brewer qualitative scheme: includes bold, readily named, basic colors (such as red, green, blue).

set1
source

fn pastel1() -> PaletteIter<Self>

Brewer qualitative scheme: Lighter version of Self::set1.

pastel1
source

fn set2() -> PaletteIter<Self>

Brewer qualitative scheme: Includes mostly a mixture colors (such as blue-green, red-orange).

set2
source

fn pastel2() -> PaletteIter<Self>

Brewer qualitative scheme: Lighter version of Self::set2.

pastel2
source

fn dark2() -> PaletteIter<Self>

Brewer qualitative scheme: Darker version of Self::set2.

dark2
source

fn set3() -> PaletteIter<Self>

Brewer qualitative scheme: Medium saturation set with more lightness variation and more classes than Self::set1 and Self::set2.

set3
source

fn paired() -> PaletteIter<Self>

Brewer qualitative scheme: Light/dark paris for namable hues.

paired
source

fn accent() -> PaletteIter<Self>

Brewer qualitative scheme: Include lightness and saturation extremes to accent small or important areas.

accent
source

fn to_gray(&self) -> Self

Convert the color to grayscale.

Examples found in repository?
examples/gradient.rs (line 26)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
fn table_of_colors(fh: &mut impl Write, colors: &Vec<RGB8>,
                   width: u32, comment: &str) -> Result<(), Err> {
    writeln!(fh, "<table style=\"border: 0px;  border-spacing: 0px\"><tr>")?;
    for &c in colors {
        writeln!(fh, "  <td style=\"width: {width}px; height: 30px; \
                      background-color: {}\"></td>",
                css_string(c))?;
    }
    writeln!(fh, "<td rowspan=\"2\" style=\"padding-left: 7px\">\
                  {comment}</td></tr><tr>")?;
    for &c in colors {
        let c = c.to_gray();
        writeln!(fh, "  <td style=\"width: {width}px; height: 12px; \
                      background-color: {}\"></td>",
                 css_string(c))?;
    }
    writeln!(fh, "</tr></table><br/>")?;
    Ok(())
}

Implementations on Foreign Types§

source§

impl RGBColor for RGB16

source§

fn to_rgba(&self) -> RGBA<f64>

source§

fn from_rgba(c: RGBA<f64>) -> Self

source§

impl RGBColor for RGBA8

source§

fn to_rgba(&self) -> RGBA<f64>

source§

fn from_rgba(c: RGBA<f64>) -> Self

source§

impl RGBColor for RGBA<f64>

source§

fn to_rgba(&self) -> RGBA<f64>

source§

fn from_rgba(c: RGBA<f64>) -> Self

source§

impl RGBColor for RGBA16

source§

fn to_rgba(&self) -> RGBA<f64>

source§

fn from_rgba(c: RGBA<f64>) -> Self

source§

impl RGBColor for RGB8

source§

fn to_rgba(&self) -> RGBA<f64>

source§

fn from_rgba(c: RGBA<f64>) -> Self

Implementors§