bracket_color/
lib.rs

1#![warn(clippy::all, clippy::pedantic, clippy::cargo)]
2
3//! This crate is part of the `bracket-lib` family.
4//!
5//! It provides RGB, HSV and` ColorPair` support for the bracket-lib library.
6//! You can construct an RGB with `new`, `from_f32`, `from_u8` or `named`.
7//! It exports a large number of named colors (the W3C web named colors) for easy access.
8//! It also provides convenience functions such as `to_greyscale`, `desaturate` and `lerp`.
9//!
10//! For example:
11//! ```rust
12//! use bracket_color::prelude::*;
13//!
14//! let red = RGB::named(RED);
15//! let blue = RGB::named(BLUE);
16//! for lerp in 0 .. 100 {
17//!     let lerp_by = lerp as f32 / 100.0;
18//!     let color = red.lerp(blue, lerp_by);
19//!     println!("{:?}", color);
20//!     let gray = color.to_greyscale();
21//!     println!("{:?}", gray);
22//!     let desat = color.desaturate();
23//!     println!("{:?}", desat);
24//! }
25//! ```
26//!
27//! If you use the `serde` feature flag, the exposed types are serializable/de-serializable.
28
29#[cfg(feature = "palette")]
30#[macro_use]
31extern crate lazy_static;
32
33/// Import color pair support
34pub mod color_pair;
35/// Import HSV color support
36pub mod hsv;
37/// Import Lerp as an iterator
38pub mod lerpit;
39/// Import library of named colors
40pub mod named;
41/// Import Palette support
42#[cfg(feature = "palette")]
43pub mod palette;
44/// Import RGB color support
45pub mod rgb;
46/// Import RGBA color support
47pub mod rgba;
48
49/// Exports the color functions/types in the `prelude` namespace.
50pub mod prelude {
51    pub use crate::color_pair::*;
52    pub use crate::hsv::*;
53    pub use crate::lerpit::*;
54    pub use crate::named::*;
55    #[cfg(feature = "palette")]
56    pub use crate::palette::*;
57    pub use crate::rgb::*;
58    pub use crate::rgba::*;
59}