The rust library named-colour provides a convenient set of named colours and the Hex Code for each colour.
To use named-colour in your project you can add the following to your Cargo.toml:
[dependencies]
named-colour = "0.3.25"Provides Hex Codes for colours:
- enums that return a hex code string for named colours
- rgb colour struct to configure a colour an rgb colour and display as decimal or hex
use named_colour::Basic;
println!("The colour Hex Code is: {} for the RGB colour Aqua: {}",
Basic::Aqua,
Basic::Aqua.as_rgb()
);Enable the feature in the toml file:
[dependencies]
named-colour = { version = "0.3.25", features = ["extended"]}use named_colour::ext::Indigo;
println!("The colour Hex Code is: {} for the RGB colour Dark Orchid: {}",
Indigo::DarkOrchid,
Indigo::DarkOrchid.as_rgb()
);use named_colour::ColourRgb;
let my_colour =ColourRgb::new(12,24,48);
println!("The Hex Code is: {} for my_colour: {}",
my_colour.as_hex(),
my_colour.to_string()
);- Basic contains just 16 colours with 18 names (default)
- Extended contains a fuller set of colours divided in 11 collections
To use the extended colour set only configure toml with no-default features
[dependencies]
named-colour = { version = "0.3.25", default_features = false, features = ["extended"]}Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.
We welcome contributions! Please see our Contributing Guide for details on:
- How to submit bug reports and feature requests
- Our development process and coding standards
- How to submit pull requests
- Developer Certificate of Origin (DCO) sign-off requirements
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
For security vulnerability reports, please see our Security Policy.
For information about project governance and decision-making, see GOVERNANCE.md.
See CHANGELOG.md for a history of changes to this project.