#hex #convert-hex #hex-color #rgb #conversion #convert #color

hex_to_rgb

A simple Rust library to convert hex color codes to RGB values

4 releases

new 0.1.3 Nov 21, 2024
0.1.2 Oct 31, 2024
0.1.1 Oct 29, 2024
0.1.0 Oct 28, 2024

#575 in Algorithms

Download history 214/week @ 2024-10-24 183/week @ 2024-10-31 15/week @ 2024-11-07

412 downloads per month

MIT license

5KB

hex_to_rgb

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.

Installation

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)
}

Features

Converts hex color codes (like #RRGGBB) to RGB tuples ((u8, u8, u8)). Lightweight and easy to use. Includes error handling for invalid hex inputs.

License

This project is licensed under the MIT License.

Author

bensatlantik

No runtime deps