chromata/integration/palette.rs
1//! Palette color science integration.
2//!
3//! Provides [`From<Color>`](crate::Color) for [`palette::Srgb<u8>`].
4//!
5//! # Enable
6//!
7//! ```toml
8//! [dependencies]
9//! chromata = { version = "1", features = ["palette-integration"] }
10//! ```
11//!
12//! # Example
13//!
14//! ```rust,ignore
15//! use chromata::popular::gruvbox;
16//!
17//! let theme = gruvbox::DARK_HARD;
18//! let srgb: palette::Srgb<u8> = theme.bg.into();
19//! ```
20
21use crate::Color;
22
23/// Convert a chromata Color to a palette sRGB color with u8 components.
24impl From<Color> for ::palette::Srgb<u8> {
25 fn from(c: Color) -> Self {
26 ::palette::Srgb::new(c.r, c.g, c.b)
27 }
28}