16 releases

new 0.3.7 Dec 7, 2024
0.3.6 Nov 15, 2024
0.3.4 Oct 4, 2024
0.3.3 Sep 28, 2024
0.1.0 Sep 29, 2021

#27 in Visualization

Download history 510/week @ 2024-08-24 713/week @ 2024-08-31 489/week @ 2024-09-07 323/week @ 2024-09-14 507/week @ 2024-09-21 930/week @ 2024-09-28 832/week @ 2024-10-05 647/week @ 2024-10-12 872/week @ 2024-10-19 585/week @ 2024-10-26 897/week @ 2024-11-02 751/week @ 2024-11-09 706/week @ 2024-11-16 255/week @ 2024-11-23 238/week @ 2024-11-30

2,014 downloads per month
Used in pcu

MIT/Apache

155KB
3.5K SLoC

Rust library named-colour

Crates.io MIT licensed Build Status Rust 1.46+ FOSSA Status 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.7"

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.7", 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.7", 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.6–1.2MB
~25K SLoC