#hex #proc-macro #literals #color

macro color-hex

Procedural macro for converting hexadecimal strings to an RGB or RGBA byte array at compile time

1 unstable release

Uses new Rust 2021

0.2.0 May 7, 2022

#1468 in Procedural macros

Download history 241/week @ 2022-06-09 221/week @ 2022-06-16 24/week @ 2022-06-23 398/week @ 2022-06-30 153/week @ 2022-07-07 32/week @ 2022-07-14 632/week @ 2022-07-21 844/week @ 2022-07-28 185/week @ 2022-08-04 231/week @ 2022-08-11 692/week @ 2022-08-18 223/week @ 2022-08-25 116/week @ 2022-09-01 160/week @ 2022-09-08 196/week @ 2022-09-15 106/week @ 2022-09-22

580 downloads per month
Used in 3 crates (via epaint)

MIT license

8KB
98 lines

color-hex

A small Rust crate that supplies procedural macros to convert hex strings into RGB/A colors at compile time.

GitHub Workflow Status Crates.io

Documentation

The documentation includes a comprehensive description of the syntax supported for parsing hex colors.

Usage

Add this to your Cargo.toml:

[dependencies]
color_hex = "0.2.0"

Here is an example of converting a direct "HTML style" hex color string to an array:

use color_hex::color_from_hex;

fn main() {
    let color = color_from_hex!("#2d2d2d");

    println!("Color: {:x?}", color);
}

License

Licensed under the MIT license

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

No runtime deps