This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
color.h
50 lines (40 loc) · 1.15 KB
/
color.h
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
// Copyright (c) 2016 Kai Luo. All rights reserved.
#ifndef ZLI_COLOR_H_
#define ZLI_COLOR_H_
#include <iostream>
#include "core_math.h"
namespace zLi {
struct xyYColor {
Float x, y, Y;
xyYColor() : x(0), y(0), Y(0) {}
xyYColor(Float x, Float y, Float Y) : x(x), y(y), Y(Y) {}
};
struct RGBColor {
Float r, g, b;
RGBColor() : r(0), g(0), b(0) {}
RGBColor(Float r, Float g, Float b) : r(r), g(g), b(b) {}
Float &operator[](int i);
Float operator[](int i) const;
RGBColor sRGB() const;
};
struct XYZColor {
Float x, y, z;
XYZColor() : x(0), y(0), z(0) {}
XYZColor(Float x, Float y, Float z) : x(x), y(y), z(z) {}
Float &operator[](int i);
Float operator[](int i) const;
};
inline std::ostream &operator<<(std::ostream &out, const RGBColor &c) {
out << "(" << c.r << ", " << c.g << ", " << c.b << ")";
return out;
}
inline std::ostream &operator<<(std::ostream &out, const XYZColor &c) {
out << "(" << c.x << ", " << c.y << ", " << c.z << ")";
return out;
}
inline std::ostream &operator<<(std::ostream &out, const xyYColor &c) {
out << "(" << c.x << ", " << c.y << ", " << c.Y << ")";
return out;
}
} // namespace zLi
#endif