Crates.io | hex_to_rgb |
lib.rs | hex_to_rgb |
version | 0.1.3 |
source | src |
created_at | 2024-10-28 20:29:06.613386 |
updated_at | 2024-11-21 01:17:42.412852 |
description | A simple Rust library to convert hex color codes to RGB values. |
homepage | |
repository | |
max_upload_size | |
id | 1426051 |
size | 5,939 |
hex_to_rgb is a simple Rust library that converts a hexadecimal color code (in #RRGGBB format) to an RGB tuple ((u8, u8, u8)). This crate is designed for quick, lightweight color conversions, making it useful for applications that work with color manipulation and representation.
To use hex_to_rgb, add it to your Cargo.toml:
[dependencies] hex_to_rgb = "0.1.0"
Then, in your Rust code:
use hex_to_rgb::hex_to_rgb;
fn main() {
let rgb = hex_to_rgb("#FF5733").unwrap();
println!("The color #FF5733 is represented as RGB {:?}", rgb);
// Outputs: The color #FF5733 is represented as RGB (255, 87, 51)
}
Converts hex color codes (like #RRGGBB) to RGB tuples ((u8, u8, u8)). Lightweight and easy to use. Includes error handling for invalid hex inputs.
This project is licensed under the MIT License.
bensatlantik