1 unstable release

0.1.0 Jul 25, 2022

#1783 in Text processing

Download history 1325/week @ 2023-10-27 1761/week @ 2023-11-03 2343/week @ 2023-11-10 2833/week @ 2023-11-17 3455/week @ 2023-11-24 1874/week @ 2023-12-01 1342/week @ 2023-12-08 1301/week @ 2023-12-15 178/week @ 2023-12-22 988/week @ 2023-12-29 1595/week @ 2024-01-05 848/week @ 2024-01-12 1236/week @ 2024-01-19 1781/week @ 2024-01-26 1752/week @ 2024-02-02 1247/week @ 2024-02-09

6,121 downloads per month
Used in 4 crates

MIT license

23KB
557 lines

tiny-gradient

github crates.io docs.rs

Preview

Usage

use tiny_gradient::{Gradient, GradientStr, RGB};

let text = "Hello World!";

// Use custom gradient
let colored = text.gradient([RGB::new(0x01, 0x00, 0x00), RGB::new(0xDA, 0x00, 0xFF)]);
println!("{}", colored);

// Use built-in gradient.
let colored = text.gradient(Gradient::Forest);
println!("{}", colored);

Notes

All the credit should go to https://stackoverflow.com/questions/22607043/color-gradient-algorithm/.

Some insiration were taken from https://github.com/bokub/gradient-string.

There's an analogues library https://crates.io/crates/colorgrad. I wasn't aware at the begining that it exists. It seems to be more mature so you may need to take a look at it.

Dependencies

~410KB