[go: up one dir, main page]

color-hex 0.2.0

Procedural macro for converting hexadecimal strings to an RGB or RGBA byte array at compile time.
Documentation
use color_hex::color_from_hex;

#[test]
fn test_const() {
    const DATA: [u8; 3] = color_from_hex!("010203");
    assert_eq!(DATA, [1, 2, 3]);
}

#[test]
fn test_character_cases() {
    assert_eq!(color_from_hex!("a1 b2 c3 d4"), [0xA1, 0xB2, 0xC3, 0xD4]);
    assert_eq!(color_from_hex!("E5 E6 90 92"), [0xE5, 0xE6, 0x90, 0x92]);
    assert_eq!(color_from_hex!("0a0B 0C"), [10, 11, 12]);
}

#[test]
fn test_hash() {
    assert_eq!(color_from_hex!("#2d2d2d"), [0x2d, 0x2d, 0x2d]);
}