color/
lib.rs

1// Copyright 2013 The color-rs developers. For a full listing of the authors,
2// refer to the AUTHORS file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15extern crate num_traits;
16extern crate angle;
17extern crate serde;
18extern crate half;
19#[macro_use] extern crate serde_derive;
20#[cfg(feature="kmeans")]
21extern crate kmeans_colors;
22#[cfg(feature="kmeans")]
23extern crate rand;
24#[cfg(feature = "bytemuck")]
25extern crate bytemuck;
26
27pub use alpha::AlphaColor;
28pub use alpha::{Rgba, Hsva, YCbCra, ToRgba, LumaA};
29pub use channel::{Channel, FloatChannel};
30pub use hsv::{Hsv, ToHsv};
31pub use hsl::{Hsl, ToHsl};
32pub use rgb::{Rgb, Rg, ToRgb, consts};
33pub use ycbcr::YCbCr;
34pub use angle::Deg;
35pub use luma::{Luma, ToLuma};
36pub use xyz::{Xyz, ToXyz};
37pub use yxy::{Yxy, ToYxy};
38pub use lab::{Lab, ToLab};
39pub use oklab::{OkLab, ToOkLab, OkHsl, OkHsv};
40
41#[macro_use] mod rgb;
42#[macro_use] mod alpha;
43mod channel;
44mod hsv;
45mod hsl;
46// pub mod srgb;
47mod ycbcr;
48mod luma;
49mod xyz;
50mod yxy;
51mod lab;
52mod oklab;
53pub mod color_space;
54#[cfg(feature="kmeans")]
55pub mod kmeans;
56
57pub trait Color<T>: Copy {
58    fn clamp_s(self, lo: T, hi: T) -> Self;
59    fn clamp_c(self, lo: Self, hi: Self) -> Self;
60    fn inverse(self) -> Self;
61    fn mix(self, other: Self, value: T) -> Self;
62    // fn saturation(&self, value: T) -> Self;
63    // fn exposure(&self, value: T) -> Self;
64    // fn brightness(&self, value: T) -> Self;
65}
66
67pub trait FloatColor<T>: Color<T> {
68    fn saturate(self) -> Self;
69}