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

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

#704 in Procedural macros

Download history 1073/week @ 2024-07-21 2318/week @ 2024-07-28 1658/week @ 2024-08-04 1108/week @ 2024-08-11 649/week @ 2024-08-18 2957/week @ 2024-08-25 2979/week @ 2024-09-01 2320/week @ 2024-09-08 3058/week @ 2024-09-15 2576/week @ 2024-09-22 2766/week @ 2024-09-29 1840/week @ 2024-10-06 1306/week @ 2024-10-13 3036/week @ 2024-10-20 9201/week @ 2024-10-27 8548/week @ 2024-11-03

22,426 downloads per month
Used in 21 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