NDEVR
API Documentation
XYZColor.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: XYZColor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "Color.h"
34#include <NDEVR/Vector.h>
35namespace NDEVR
36{
37 class RGBColor;
38 class ACIColor;
39 class LABColor;
40 class HSBColor;
41 class HSLColor;
54 class XYZColor : public Vector<4, fltp04>, public Color
55 {
56 public:
60 constexpr XYZColor()
61 : Vector<4, fltp04>(Constant<fltp04>::Invalid)
62 {}
63
67 constexpr explicit XYZColor(const Vector<4, fltp04>& color)
68 : Vector<4, fltp04>(color)
69 {}
70
77 constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a = 1.0f)
78 : Vector<4, fltp04>(
79 clip(x, 0.0f, 0.9505f)
80 , clip(y, 0.0f, 1.0f)
81 , clip(z, 0.0f, 1.0f)
82 , a)
83 {}
84
88 explicit NDEVR_BASE_API XYZColor(const RGBColor&);
93 explicit NDEVR_BASE_API XYZColor(const ACIColor&);
98 explicit NDEVR_BASE_API XYZColor(const LABColor&);
103 explicit NDEVR_BASE_API XYZColor(const HSBColor&);
108 explicit NDEVR_BASE_API XYZColor(const HSLColor&);
113 void setX(fltp04 x)
114 {
115 m_values[X] = (x > 0.9505f) ? 0.9505f : ((x < 0.0f) ? 0.0f : x);
116 }
117
121 void setY(fltp04 y)
122 {
123 m_values[Y] = (y > 1.0000f) ? 1.0000f : ((y < 0.0f) ? 0.0f : y);
124 }
125
129 void setZ(fltp04 z)
130 {
131 m_values[Z] = (z > 1.0890f) ? 1.0890f : ((z < 0.0f) ? 0.0f : z);
132 }
133
137 void setA(fltp04 a)
138 {
139 m_values[W] = a;
140 }
141
146 {
147 static XYZColor D65(95.047f, 100.0f, 108.883f);
148 return D65;
149 }
150 };
151 template<>
152 constexpr const XYZColor Constant<XYZColor>::Invalid = XYZColor();
153 template<>
154 constexpr const XYZColor Constant<XYZColor>::Max = XYZColor(Constant<fltp04>::Max, Constant<fltp04>::Max, Constant<fltp04>::Max);
155 template<>
156 constexpr const XYZColor Constant<XYZColor>::Min = XYZColor(Constant<fltp04>::Min, Constant<fltp04>::Min, Constant<fltp04>::Min);
157}
A color identified by an AutoCAD Color Index (ACI) number from 1 through 255.
Definition ACIColor.h:59
The core Color class in the NDEVR API.
Definition Color.h:42
A color defined by hue, saturation, and brightness components.
Definition HSBColor.h:62
A color defined by hue, saturation, and luminosity components.
Definition HSLColor.h:51
Forward declaration of the NDEVR translated string class.
Definition LABColor.h:65
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
fltp04 m_values[t_dims]
Definition Vector.hpp:630
XYZColor(const HSLColor &)
Constructs an XYZColor by converting from an HSLColor.
void setY(fltp04 y)
Sets the Y component, clamped to [0, 1.0].
Definition XYZColor.h:121
XYZColor(const LABColor &)
Constructs an XYZColor by converting from a LABColor.
static XYZColor getD65()
Returns the CIE standard illuminant D65 reference white point.
Definition XYZColor.h:145
XYZColor(const HSBColor &)
Constructs an XYZColor by converting from an HSBColor.
constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a=1.0f)
Constructs an XYZColor from individual X, Y, Z, and alpha components, clamped to valid ranges.
Definition XYZColor.h:77
void setZ(fltp04 z)
Sets the Z component, clamped to [0, 1.089].
Definition XYZColor.h:129
XYZColor(const RGBColor &)
Constructs an XYZColor by converting from an RGBColor.
constexpr XYZColor()
Constructs an invalid XYZColor with all components set to Invalid.
Definition XYZColor.h:60
constexpr XYZColor(const Vector< 4, fltp04 > &color)
Constructs an XYZColor from a 4-component vector.
Definition XYZColor.h:67
void setA(fltp04 a)
Sets the alpha component.
Definition XYZColor.h:137
XYZColor(const ACIColor &)
Constructs an XYZColor by converting from an ACIColor.
void setX(fltp04 x)
Sets the X component, clamped to [0, 0.9505].
Definition XYZColor.h:113
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
constexpr t_type clip(const t_type &value, const t_type &lower_bound, const t_type &upper_bound)
Clips the value given so that that the returned value falls between upper and lower bound.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...