Crate colourado_iter

Source
Expand description

A small and minimalistic library to generate a random color palette. The user-facing Color struct contains RGB colors ranging from 0 to 1. All colors are of type f32 (no exceptions)

§Usage

use colourado_iter::{Color, ColorPalette, PaletteType};
 
let mut palette = ColorPalette::new(PaletteType::Random, false, &mut rand::thread_rng());
let random_color = palette.next();
let color_array: [f32; 3] = palette.next().unwrap().to_array();
let many_colors = palette.take(20);
let hue = 315.0;
let saturation = 0.5;
let value = 0.3;
let rgb_color: Color = Color::hsv_to_rgb(hue, saturation, value);

The second param to ColorPalette::new() determines the color scheme.
Currently 3 different schemes are supported:
PaletteType::Random generates random colors PaletteType::Pastel generates pastel colors PaletteType::Dark generates dark colors

The third param determines whether colors are generated close to each other or are spread apart. true generates adjacent colors while false will generate a very spread color palette.

Optionally, you can use the HsvPalette struct to get a generator which spits out the immediate HSV values as opposed to a Color struct.

WARNING The ColorPalette iterator is infinite! It will never exhaust! As such, you should never use collect or for x in patterns with it. Instead, always use take if you want a certain number of colors.

Structs§

Color
A simple struct containing the three main color components of RGB color space. Colors are stored as f32 values ranging from 0.0 to 1.0
ColorPalette
HsvPalette
Container for a vector of colors. You can also use it to store your own custom palette of you so desire.

Enums§

PaletteType

Type Aliases§

Hsv