matdesign-color

Crates.iomatdesign-color
lib.rsmatdesign-color
version0.1.2
sourcesrc
created_at2021-06-02 00:28:25.882452
updated_at2021-06-07 20:03:54.519847
descriptionMaterial Design Color Palettes for Rust
homepagehttps://github.com/LeoVen/matdesign-color
repositoryhttps://github.com/LeoVen/matdesign-color
max_upload_size
id404999
size97,506
Leonardo Vencovsky (LeoVen)

documentation

https://docs.rs/matdesign-color

README

Material Design Color

Material Design Color Palettes for Rust

Installation

Include this line in your cargo.toml

matdesign-color = "0.1.2"

Examples

You may use the const fn through MatColor or access them through a specific color.

use matdesign_color::{MatColor, MatColorRed};

let red1: u32 = MatColor.red().c300();
let brown: u32 = MatColor.brown().c900();
let black: u32 = MatColor.black();

let red2 = MatColorRed.c300();
assert_eq!(red1, red2);

Or you may use MatColor::new to create colors on the fly:

use matdesign_color::{MatColor, MatColorVariant, MatColorAccent};

let orange: Option<u32> = MatColor::new(MatColorVariant::Orange, MatColorAccent::A200);
assert!(orange.is_some());

let no_brown: Option<u32> = MatColor::new(MatColorVariant::Brown, MatColorAccent::A200);
assert!(no_brown.is_none());

You may also use global constant arrays and index them using an accent.

use matdesign_color::{MAT_COLORS_RED, MatColor, MatColorAccent};

let red: u32 = MAT_COLORS_RED[MatColorAccent::A700 as usize];
assert_eq!(red, MatColor.red().a700());
Commit count: 12

cargo fmt