#hex-color #hex-string #hex #color #literals #proc-macro #color-string

macro color-hex

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

1 unstable release

0.2.0 May 7, 2022

#669 in Procedural macros

Download history 2196/week @ 2024-03-14 3850/week @ 2024-03-21 5169/week @ 2024-03-28 1086/week @ 2024-04-04 698/week @ 2024-04-11 2289/week @ 2024-04-18 2353/week @ 2024-04-25 969/week @ 2024-05-02 1182/week @ 2024-05-09 1831/week @ 2024-05-16 3371/week @ 2024-05-23 2805/week @ 2024-05-30 1746/week @ 2024-06-06 1785/week @ 2024-06-13 1802/week @ 2024-06-20 3472/week @ 2024-06-27

9,570 downloads per month
Used in 11 crates (5 directly)

MIT license

9KB
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