#hex-color #hex-string #hex #color #literals #color-string #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

#633 in Procedural macros

Download history 11052/week @ 2024-11-17 11796/week @ 2024-11-24 11203/week @ 2024-12-01 13426/week @ 2024-12-08 13334/week @ 2024-12-15 6104/week @ 2024-12-22 7288/week @ 2024-12-29 10814/week @ 2025-01-05 12521/week @ 2025-01-12 12747/week @ 2025-01-19 15675/week @ 2025-01-26 17026/week @ 2025-02-02 17316/week @ 2025-02-09 15599/week @ 2025-02-16 15631/week @ 2025-02-23 17618/week @ 2025-03-02

68,280 downloads per month
Used in 47 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