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

#671 in Procedural macros

Download history 809/week @ 2023-12-22 1248/week @ 2023-12-29 2438/week @ 2024-01-05 2129/week @ 2024-01-12 3117/week @ 2024-01-19 2820/week @ 2024-01-26 2444/week @ 2024-02-02 2461/week @ 2024-02-09 2289/week @ 2024-02-16 976/week @ 2024-02-23 1135/week @ 2024-03-01 1662/week @ 2024-03-08 2571/week @ 2024-03-15 3544/week @ 2024-03-22 4951/week @ 2024-03-29 1042/week @ 2024-04-05

12,387 downloads per month
Used in 6 crates (3 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