matdesign-color 0.1.2

Material Design Color Palettes for Rust
Documentation
  • Coverage
  • 100%
    319 out of 319 items documented1 out of 300 items with examples
  • Size
  • Source code size: 97.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • LeoVen/matdesign-color
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • LeoVen

Material Design Colors for Rust

Easily get color variants based on the Material Design Pallete. All colors are represented as 0xRRGGBB with the first two bytes not used. To access a color you may use the const fn under [MatColor] or access the const arrays that are publicly available. Also, check out [MatColor::new] to create Material Design colors based on [MatColorVariant] and [MatColorAccent] on demand.

For More information, check out the Official Website.

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());