diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-04-12 15:42:04 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-04-12 15:42:04 +0000 |
commit | 4f9f95a05a41bfbcc9965eaaf7f2d14c6af9f261 (patch) | |
tree | c5d3d649d36e6102708d0f86edb87499e1ff8c3e /libdimensionxx/dimensionxx/color.hpp | |
parent | 510c9a95fb5f3f4a40a19ce66c95344c2013085f (diff) | |
download | dimension-4f9f95a05a41bfbcc9965eaaf7f2d14c6af9f261.tar.xz |
Write C++ libdimension-png wrapper.
Diffstat (limited to 'libdimensionxx/dimensionxx/color.hpp')
-rw-r--r-- | libdimensionxx/dimensionxx/color.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libdimensionxx/dimensionxx/color.hpp b/libdimensionxx/dimensionxx/color.hpp index 5db041a..afd7ea5 100644 --- a/libdimensionxx/dimensionxx/color.hpp +++ b/libdimensionxx/dimensionxx/color.hpp @@ -51,6 +51,8 @@ namespace Dimension double trans(double t) { m_color.trans = t; } // Color& operator=(const Color& c); + Color& operator+=(const Color& c) + { m_color = dmnsn_color_add(m_color, c.m_color); return *this; } dmnsn_color dmnsn() const { return m_color; } @@ -61,6 +63,7 @@ namespace Dimension class CIE_XYZ { public: + CIE_XYZ() { } CIE_XYZ(double X, double Y, double Z) { m_XYZ.X = X; m_XYZ.Y = Y; m_XYZ.Z = Z; } CIE_XYZ(const Color& c) : m_XYZ(dmnsn_XYZ_from_color(c.dmnsn())) { } @@ -85,6 +88,7 @@ namespace Dimension class CIE_xyY { public: + CIE_xyY() { } CIE_xyY(double x, double y, double Y) { m_xyY.x = x; m_xyY.y = y; m_xyY.Y = Y; } CIE_xyY(const Color& c) : m_xyY(dmnsn_xyY_from_color(c.dmnsn())) { } @@ -109,6 +113,7 @@ namespace Dimension class CIE_Lab { public: + CIE_Lab() { } CIE_Lab(double L, double a, double b) { m_Lab.L = L; m_Lab.a = a; m_Lab.b = b; } CIE_Lab(const Color& c, const CIE_XYZ& white = whitepoint) @@ -134,6 +139,7 @@ namespace Dimension class CIE_Luv { public: + CIE_Luv() { } CIE_Luv(double L, double u, double v) { m_Luv.L = L; m_Luv.u = u; m_Luv.v = v; } CIE_Luv(const Color& c, const CIE_XYZ& white = whitepoint) @@ -159,6 +165,7 @@ namespace Dimension class sRGB { public: + sRGB() { } sRGB(double R, double G, double B) { m_RGB.R = R; m_RGB.G = G; m_RGB.B = B; } sRGB(const Color& c) : m_RGB(dmnsn_sRGB_from_color(c.dmnsn())) { } @@ -180,6 +187,8 @@ namespace Dimension dmnsn_sRGB m_RGB; }; + // Color inline constructors + inline Color::Color(const CIE_XYZ& XYZ) : m_color(dmnsn_color_from_XYZ(XYZ.dmnsn())) { } @@ -194,6 +203,22 @@ namespace Dimension inline Color::Color(const sRGB& RGB) : m_color(dmnsn_color_from_sRGB(RGB.dmnsn())) { } + + // Color operators + + inline Color + operator+(const Color& lhs, const Color& rhs) + { + Color temp = lhs; + temp += rhs; + return temp; + } + + inline double + operator-(const Color& lhs, const Color& rhs) + { + return dmnsn_color_difference(lhs.dmnsn(), rhs.dmnsn()); + } } #endif /* DIMENSIONXX_COLOR_HPP */ |