15 stable releases
1.0.14 | May 6, 2024 |
---|---|
1.0.13 | Mar 24, 2024 |
1.0.12 | Jul 15, 2023 |
1.0.10 | Mar 3, 2023 |
1.0.3 | Jun 16, 2020 |
#5 in No standard library
34,850 downloads per month
Used in 40 crates
(19 directly)
81KB
1K
SLoC
Colorous
This crate provides a collection of sequential, diverging and categorical color
schemes ported from d3-scale-chromatic. Each color scheme may be sampled using
either a rational index i/n
or a continuous float 0 ≤ t ≤ 1
.
pub fn eval_rational(&self, i: usize, n: usize) -> Color
pub fn eval_continuous(&self, t: f64) -> Color
Example
let gradient = colorous::VIRIDIS;
for i in 0..100 {
println!("{:x}", gradient.eval_rational(i, 100));
}
Sequential (multi-hue)
# colorous::TURBO
The “turbo” color scheme by Anton Mikhailov.
# colorous::VIRIDIS
The “viridis” perceptually-uniform color scheme designed by van der Walt, Smith and Firing for matplotlib.
# colorous::INFERNO
The “inferno” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib.
# colorous::MAGMA
The “magma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib.
# colorous::PLASMA
The “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib.
# colorous::CIVIDIS
The “cividis” color vision deficiency-optimized color scheme designed by Nuñez, Anderton, and Renslow.
# colorous::WARM
A 180° rotation of Niccoli’s perceptual rainbow.
# colorous::COOL
# colorous::CUBEHELIX
# colorous::BLUE_GREEN
# colorous::BLUE_PURPLE
# colorous::GREEN_BLUE
# colorous::ORANGE_RED
# colorous::PURPLE_BLUE_GREEN
# colorous::PURPLE_BLUE
# colorous::PURPLE_RED
# colorous::RED_PURPLE
# colorous::YELLOW_GREEN_BLUE
# colorous::YELLOW_GREEN
# colorous::YELLOW_ORANGE_BROWN
# colorous::YELLOW_ORANGE_RED
Sequential (single-hue)
# colorous::BLUES
# colorous::GREENS
# colorous::GREYS
# colorous::ORANGES
# colorous::PURPLES
# colorous::REDS
Diverging
# colorous::BROWN_GREEN
# colorous::PURPLE_GREEN
# colorous::PINK_GREEN
# colorous::PURPLE_ORANGE
# colorous::RED_BLUE
# colorous::RED_GREY
# colorous::RED_YELLOW_BLUE
# colorous::RED_YELLOW_GREEN
# colorous::SPECTRAL
Cyclical
# colorous::RAINBOW
The cyclical less-angry rainbow color scheme.
# colorous::SINEBOW
The “sinebow” color scheme by Jim Bumgardner and Charlie Loyd.
Categorical
Categorical color schemes are exposed simply as an array [Color; N]
.
# colorous::CATEGORY10
# colorous::ACCENT
# colorous::DARK2
# colorous::PAIRED
# colorous::PASTEL1
# colorous::PASTEL2
# colorous::SET1
# colorous::SET2
# colorous::SET3
# colorous::TABLEAU10
Ten categorical colors authored by Tableau as part of Tableau 10.
License
Licensed under the Apache License, Version 2.0.