Expand description
Utilities for working with RGB and hex color representations.
This crate provides types for creating, converting, and comparing colors expressed as RGB tuples or hexadecimal strings. It also includes a small collection of named colors and builder-style mutation methods.
§Quick start
use hex_rgb_converter::{Color, RgbColor, HexColor};
// Create a color from a hex string.
let hex = Color::hex("1e90ff");
// Create a color from RGB components.
let rgb = Color::rgb(30, 144, 255);
// Convert between representations.
assert_eq!(hex.to_rgb().to_hex().to_string(), hex.to_string());§Named colours
A small set of common colour names is recognised by Color::by_name:
use hex_rgb_converter::Color;
let orange = Color::by_name("orange");
assert_eq!(orange.to_string(), "#ffa500");Structs§
- Color
- Entry-point for constructing colour values.
- HexColor
- A colour represented by a six-digit hexadecimal string (without
#). - RgbColor
- A colour represented by its red, green and blue components.
Enums§
- Colors
- Selector for individual or all colour channels.
- Convertion
Error - Initialization
Error - Invalid
Parameter Error