Crates.io | color-hex |
lib.rs | color-hex |
version | 0.2.0 |
source | src |
created_at | 2022-05-07 04:20:11.008214 |
updated_at | 2022-05-07 04:20:11.008214 |
description | Procedural macro for converting hexadecimal strings to an RGB or RGBA byte array at compile time. |
homepage | |
repository | https://github.com/newcomb-luke/color-hex |
max_upload_size | |
id | 581964 |
size | 11,555 |
A small Rust crate that supplies procedural macros to convert hex strings into RGB/A colors at compile time.
The documentation includes a comprehensive description of the syntax supported for parsing hex colors.
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);
}
Licensed under the MIT license
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.