#random #color #rgb #rgba #hsl

random_color

Rust crate for generating random attractive colors

8 releases

Uses old Rust 2015

0.6.1 Sep 29, 2021
0.5.1 Mar 28, 2021
0.5.0 Oct 3, 2020
0.4.4 Oct 13, 2018
0.4.1 Nov 14, 2017

#98 in Algorithms

Download history 347/week @ 2022-04-18 314/week @ 2022-04-25 382/week @ 2022-05-02 377/week @ 2022-05-09 420/week @ 2022-05-16 324/week @ 2022-05-23 320/week @ 2022-05-30 339/week @ 2022-06-06 333/week @ 2022-06-13 396/week @ 2022-06-20 232/week @ 2022-06-27 477/week @ 2022-07-04 325/week @ 2022-07-11 456/week @ 2022-07-18 510/week @ 2022-07-25 320/week @ 2022-08-01

1,621 downloads per month
Used in 11 crates (5 directly)

MIT license

25KB
618 lines

random_color

⚙️ 🎨 Rust crate for generating random attractive colors. Checck it out on crates.io.

Inspired by RandomColor.

crate badge

Usage

Example

use random_color::{Color, Luminosity, RandomColor};

let color = RandomColor::new()
  .hue(Color::Blue) // Optional
  .luminosity(Luminosity::Light) // Optional
  .seed(42) // Optional
  .alpha(1.0) // Optional
  .to_hsl_string(); // 

// color => "hsl(179, 99%, 10%)"

Possible hue values:

  • Color::Monochrome
  • Color::Red
  • Color::Orange
  • Color::Yellow
  • Color::Green
  • Color::Blue
  • Color::Purple
  • Color::Pink

Possible luminosity values:

  • Luminosity::Random
  • Luminosity::Bright
  • Luminosity::Light
  • Luminosity::Dark

Possible alpha values:

  • You can specify a value between 0 and 1 with .alpha()
  • You can specify a random value with .random_alpha()

Avaible outputs:

  // As HSV Array
  let color = RandomColor::new().to_hsv_array();