Skip to content

persevie/grimoire-css-color-toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grimoire CSS Color Toolkit

CSS Color Module Level 4 compliant color manipulation toolkit, strictly follows CSS specifications.

Installation

# CLI tool
cargo install grimoire_css_color_toolkit

# Library
cargo add grimoire_css_color_toolkit

Quick Start

Library:

use grimoire_css_color_toolkit_lib::Color;

let red = Color::try_from_str("red").unwrap();
let lighter = red.lighten(20.0);
let mixed = Color::mix(red, Color::try_from_str("blue").unwrap(), 50.0);
println!("{}", mixed.to_hex_string()); // "#800080"

CLI:

# CLI examples
grimoire_css_color_toolkit lighten "red" 20    # #ff6666
grimoire_css_color_toolkit mix "red" "blue" 50 # #800080
grimoire_css_color_toolkit to-hsl "#ff0000"    # 0 100 50

Methods

Method Description
new Create RGBA color from components
from-rgb Create color from RGB values
from-hsl Create color from HSL values
from-hwb Create color from HWB values
from-hex Parse hex color string
parse Parse any CSS color string
red Get red channel value
green Get green channel value
blue Get blue channel value
alpha Get alpha channel value
opacity Get opacity value (same as alpha)
to-hsl Convert to HSL format
to-rgba Convert to RGBA format
to-hex Convert to hex format
to-named Convert to named color if possible
grayscale Convert to grayscale
complement Get complement color
invert Invert color
mix Mix two colors
adjust-hue Adjust hue by degrees
adjust-color Adjust color properties by delta
change-color Change color properties to absolute values
scale-color Scale color properties by percentage
rgba Set alpha channel
lighten Increase lightness
darken Decrease lightness
saturate Increase saturation
desaturate Decrease saturation
opacify Increase opacity
fade-in Increase opacity (alias for opacify)
transparentize Decrease opacity
fade-out Decrease opacity (alias for transparentize)

Supports all CSS color formats: hex (#ff0000), named (red), RGB (rgb(255,0,0)), HSL (hsl(0,100%,50%)), HWB (hwb(0 0% 0%))

Features

  • CSS Color Module Level 4 compliant - Strictly follows CSS specifications
  • 32 color manipulation functions - All standard CSS color operations
  • Multiple formats - Hex, named colors, RGB, HSL, HWB support
  • Dual interface - Both CLI tool and Rust library
  • Fast & reliable - Written in Rust with comprehensive tests

About

CSS Color Module Level 4 compliant color manipulation toolkit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages