Colorous
========
[](https://github.com/dtolnay/colorous)
[](https://crates.io/crates/colorous)
[](https://docs.rs/colorous)
[](https://github.com/dtolnay/colorous/actions?query=branch%3Amaster)
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`
[d3-scale-chromatic]: https://github.com/d3/d3-scale-chromatic
## Example
```rust
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](https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html).
# colorous::VIRIDIS
The “viridis” perceptually-uniform color scheme designed by [van der Walt, Smith and Firing](https://bids.github.io/colormap/) for matplotlib.
# colorous::INFERNO
The “inferno” perceptually-uniform color scheme designed by [van der Walt and Smith](https://bids.github.io/colormap/) for matplotlib.
# colorous::MAGMA
The “magma” perceptually-uniform color scheme designed by [van der Walt and Smith](https://bids.github.io/colormap/) for matplotlib.
# colorous::PLASMA
The “plasma” perceptually-uniform color scheme designed by [van der Walt and Smith](https://bids.github.io/colormap/) for matplotlib.
# colorous::CIVIDIS
The “cividis” color vision deficiency-optimized color scheme designed by [Nuñez, Anderton, and Renslow](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0199239).
# colorous::WARM
A 180° rotation of [Niccoli’s perceptual rainbow](https://mycarta.wordpress.com/2013/02/21/perceptual-rainbow-palette-the-method/).
# colorous::COOL
[Niccoli’s perceptual rainbow](https://mycarta.wordpress.com/2013/02/21/perceptual-rainbow-palette-the-method/).
# colorous::CUBEHELIX
[Green’s default Cubehelix](https://www.mrao.cam.ac.uk/~dag/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](http://bl.ocks.org/mbostock/310c99e53880faec2434) color scheme.
# colorous::SINEBOW
The “sinebow” color scheme by [Jim Bumgardner](https://krazydad.com/tutorials/makecolors.php) and [Charlie Loyd](http://basecase.org/env/on-rainbows).
## 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](https://www.tableau.com/about/blog/2016/7/colors-upgrade-tableau-10-56782).
## License
Licensed under the Apache License, Version 2.0.