Skip to main content

Crate hyperchad_color

Crate hyperchad_color 

Source
Expand description

A lightweight color parsing and manipulation library.

This crate provides a simple Color type representing RGB/RGBA colors with 8-bit channels, along with utilities for parsing hex color strings in various formats.

§Features

  • Parse hex color strings in multiple formats (RGB, RGBA, RRGGBB, RRGGBBAA)
  • Support for optional alpha channel
  • Conversion to/from hex strings
  • Optional integration with egui (via egui feature)
  • Optional property testing support (via arb feature)
  • Optional serialization support (via serde feature)

§Examples

use hyperchad_color::Color;

// Parse a hex color string
let color = Color::from_hex("#FF5733");
assert_eq!(color.r, 255);
assert_eq!(color.g, 87);
assert_eq!(color.b, 51);

// Use predefined constants
let black = Color::BLACK;
let white = Color::WHITE;

// Convert back to hex string
assert_eq!(color.to_string(), "#FF5733");

Modules§

arb
Property testing support via proptest.

Macros§

color_from_hex
Re-export of the color_from_hex! macro from the color-hex crate.

Structs§

Color
Represents an RGB or RGBA color with 8-bit channels.

Enums§

ParseHexError
Errors that can occur when parsing a hex color string.