parse-color 0.1.2

A crate that provides conversion from CSS color names or TailwindCSS classes to RGBA colors, in the form of [u8; 4].
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented1 out of 1 items with examples
  • Size
  • Source code size: 22.58 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.47 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mintlu8/parse-color
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mintlu8

parse-color

A crate that provides conversion from CSS color names or TailwindCSS classes to RGBA colors, in the form of [u8; 4].

Examples

assert_eq!(parse_color::parse("Red"), Some([255, 0, 0, 255]));
assert_eq!(parse_color::parse("Transparent"), Some([0, 0, 0, 0]));
assert_eq!(parse_color::parse("light coral"), Some([240, 128, 128, 255]));
assert_eq!(parse_color::parse("Rebecca-Purple"), Some([102, 51, 153, 255]));

// note the 0 value is only allowed on black/white/transparent
assert_eq!(parse_color::parse_tailwind("white", 0), Some([255, 255, 255, 255]));
assert_eq!(parse_color::parse_tailwind("sky", 400), Some([56, 189, 248, 255]));
assert_eq!(parse_color::parse_tailwind("fuchsia", 900), Some([112, 26, 117, 255]));