1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use num_traits::Float;
use Yxy;
use white_point::WhitePoint;
use pixel::TransferFn;
use std::any::Any;
pub use self::rgb::{Rgb, Rgba};
pub use self::standards::{Linear};
pub mod standards;
mod rgb;
pub type Srgb<T = f32> = Rgb<standards::Srgb, T>;
pub type Srgba<T = f32> = Rgba<standards::Srgb, T>;
pub type LinSrgb<T = f32> = Rgb<Linear, T>;
pub type LinSrgba<T = f32> = Rgba<Linear, T>;
pub type GammaSrgb<T = f32> = Rgb<standards::Gamma, T>;
pub type GammaSrgba<T = f32> = Rgba<standards::Gamma, T>;
pub trait RgbStandard {
type Space: RgbSpace;
type TransferFn: TransferFn;
}
impl<S: RgbSpace, T: TransferFn> RgbStandard for (S, T) {
type Space = S;
type TransferFn = T;
}
impl<P: Primaries, W: WhitePoint, T: TransferFn> RgbStandard for (P, W, T) {
type Space = (P, W);
type TransferFn = T;
}
pub trait RgbSpace {
type Primaries: Primaries;
type WhitePoint: WhitePoint;
}
impl<P: Primaries, W: WhitePoint> RgbSpace for (P, W) {
type Primaries = P;
type WhitePoint = W;
}
pub trait Primaries: Any {
fn red<Wp: WhitePoint, T: Float>() -> Yxy<Wp, T>;
fn green<Wp: WhitePoint, T: Float>() -> Yxy<Wp, T>;
fn blue<Wp: WhitePoint, T: Float>() -> Yxy<Wp, T>;
}