#color #hex-color #constants #reference #color-string

named-colour

named-colour provides Hex Codes for popular colour names

28 releases

new 0.3.19 Mar 21, 2025
0.3.17 Feb 28, 2025
0.3.10 Dec 27, 2024
0.3.6 Nov 15, 2024
0.1.0 Sep 29, 2021

#1 in #colour

Download history 198/week @ 2024-11-28 675/week @ 2024-12-05 388/week @ 2024-12-12 475/week @ 2024-12-19 417/week @ 2024-12-26 410/week @ 2025-01-02 359/week @ 2025-01-09 367/week @ 2025-01-16 240/week @ 2025-01-23 303/week @ 2025-01-30 68/week @ 2025-02-06 380/week @ 2025-02-13 763/week @ 2025-02-20 1157/week @ 2025-02-27 562/week @ 2025-03-06 469/week @ 2025-03-13

2,954 downloads per month
Used in pcu

MIT/Apache

155KB
3.5K SLoC

Rust library named-colour

Crates.io MIT licensed CircleCI Rust Docs BuyMeaCoffee GitHubSponsors

The rust library named-colour provides a convenient set of named colours and the Hex Code for each colour.

Installation

To use named-colour in your project you can add the following to your Cargo.toml:

[dependencies]
named-colour = "0.3.19"

Usage

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

Examples

Use Basic colour

use named_colour::Basic;
println!("The colour Hex Code is: {} for the RGB colour Aqua: {}",
    Basic::Aqua,
    Basic::Aqua.as_rgb()
);

Use Extended colour

Enable the feature in the toml file:

[dependencies]
named-colour = { version = "0.3.19", 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()
);

Create a custom colour

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()
);

Features

  • 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.19", default_features = false, features = ["extended"]}

License

Licensed under either of

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 dual licensed as above, without any additional terms or conditions.

Dependencies

~0.5–1.1MB
~25K SLoC