Index
- Custom Gradient
- Preset Gradients
- Parsing GIMP Gradient
- Using the Gradient
- Examples
- Similar Projects
- Projects using
colorgrad
Usage
Add this to your Cargo.toml
= "0.7.0"
Custom Gradient
Basic
let g = new.?;

Custom Colors
use Color;
let g = new
.colors
.?;

Using Web Color Format
.html_colors() method accepts named colors, hexadecimal (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb(), rgba(), hsl(), hsla(), hwb(), and hsv().
let g = new
.html_colors
.?;

let g = new
.html_colors
.?;

let g = new
.html_colors
.?;

Using CSS Gradient Format
let g = new
.css
.?;

Domain & Color Position
Default domain is [0..1].
let g = new
.html_colors
.?;
assert_eq!;

Set the domain to [0..100].
let g = new
.html_colors
.domain
.?;
assert_eq!;

Set the domain to [-1..1].
let g = new
.html_colors
.domain
.?;
assert_eq!;

Set exact position for each color. The domain is [0..1].
let g = new
.html_colors
.domain
.?;
assert_eq!;

Set exact position for each color. The domain is [15..80].
let g = new
.html_colors
.domain
.?;
assert_eq!;

Blending Mode
let g = new
.html_colors
.mode
.?;

Interpolation Mode
let g = new
.html_colors
.?;

Preset Gradients
See PRESET.md
Parsing GIMP Gradient
use ;
use File;
use BufReader;
let input = open?;
let buf = new;
let col = default;
let grad = new?;
assert_eq!;

Using the Gradient
Get the domain
let grad = rainbow;
assert_eq!;
Get single color at certain position
use Gradient;
let grad = blues;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
The difference of at(), repeat_at() and reflect_at().

Get n colors evenly spaced across gradient
use Gradient;
let grad = rainbow;
for c in grad.colors
Output:
#6e40aa
#c83dac
#ff5375
#ff8c38
#c9d33a
#7cf659
#5dea8d
#48b8d0
#4775de
#6e40aa
Hard-Edged Gradient
Convert gradient to hard-edged gradient with 11 segments and 0 smoothness.
let g = rainbow.sharp;

This is the effect of different smoothness.

Examples
Gradient Image
use Gradient;
Example output:

Colored Noise
use Gradient;
use NoiseFn;
Example output:

Features
Default
- named-colors: Enables parsing from named colors. Requires
phf. - preset: Preset gradients.
Can be disabled using default-features = false.
Optional
- lab: Blending colors in Lab colorspace.
- ggr: Parsing GIMP gradient format.
Similar Projects
- colorgrad (Go version of this library)
- colorous (Rust)
- chroma.js (Javascript)
- d3-scale-chromatic (Javascript)
Projects using colorgrad
- binocle - A graphical tool to visualize binary data
- bytehound - A memory profiler for Linux
- cosmic-bg - COSMIC session service which applies backgrounds to displays
- eruption - A Linux user-mode input and LED driver for keyboards, mice and other devices
- gradient - A command line tool for playing with color gradient
- lcat -
lolcatclone - lolcrab -
lolcatbut with noise (lcatfork) - rust-fractal - Mandelbrot fractal visualizer
- WezTerm - A GPU-accelerated cross-platform terminal emulator and multiplexer
- and many others..