API Documentation
Loading...
Searching...
No Matches
XYZColor.h
Go to the documentation of this file.
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;
42 /**----------------------------------------------------------------------------
43 \brief In opposition to the previous models, the CIE XYZ model defines an absolute
44 color space.
45 It is also known as the CIE 1931 XYZ color space and stands for:
46 X, which can be compared to red Ranges from 0 to 0.9505
47 Y, which can be compared to green Ranges from 0 to 1.0
48 Z, which can be compared to blue Ranges from 0 to 1.089
49 ----------------------------------------------------------------------------*/
50 class XYZColor : public Vector<4, fltp04>, public Color
51 {
52 public:
53 constexpr XYZColor()
55 {}
56 constexpr explicit XYZColor(const Vector<4, fltp04>& color)
57 : Vector<4, fltp04>(color)
58 {}
59 constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a = 1.0f)
60 : Vector<4, fltp04>(
61 clip(x, 0.0f, 0.9505f)
62 , clip(y, 0.0f, 1.0f)
63 , clip(z, 0.0f, 1.0f)
64 , a)
65 {}
71 void setX(fltp04 x)
72 {
73 m_values[X] = (x > 0.9505f) ? 0.9505f : ((x < 0.0f) ? 0.0f : x);
74 }
75 void setY(fltp04 y)
76 {
77 m_values[Y] = (y > 1.0000f) ? 1.0000f : ((y < 0.0f) ? 0.0f : y);
78 }
79 void setZ(fltp04 z)
80 {
81 m_values[Z] = (z > 1.0890f) ? 1.0890f : ((z < 0.0f) ? 0.0f : z);
82 }
83 void setA(fltp04 a)
84 {
85 m_values[W] = a;
86 }
87 static XYZColor getD65()
88 {
89 static XYZColor D65(95.047f, 100.0f, 108.883f);
90 return D65;
91 }
92 };
93 template<>
95 template<>
97 template<>
99}
#define NDEVR_BASE_API
Definition DLLInfo.h:57
ACI colors are the standard colors used in AutoCAD-based products. Each color is identified by an ACI...
Definition ACIColor.h:58
The core Color class in the NDEVR API. Colors can be defined in several ways. The ACIColor is compact...
Definition Color.h:41
The HSB (Hue, Saturation, Brightness) color model defines a color space in terms of three constituent...
Definition HSBColor.h:57
The HSL (Hue, Saturation, Luminosity) color model defines a color space in.
Definition HSLColor.h:47
A Lab color space is a color-opponent space with dimension L for luminance and a and b for the color-...
Definition LABColor.h:61
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
fltp04 m_values[t_dims]
Definition Vector.hpp:623
In opposition to the previous models, the CIE XYZ model defines an absolute color space....
Definition XYZColor.h:51
NDEVR_BASE_API XYZColor(const HSBColor &)
constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a=1.0f)
Definition XYZColor.h:59
NDEVR_BASE_API XYZColor(const ACIColor &)
void setZ(fltp04 z)
Definition XYZColor.h:79
void setX(fltp04 x)
Definition XYZColor.h:71
NDEVR_BASE_API XYZColor(const RGBColor &)
constexpr XYZColor(const Vector< 4, fltp04 > &color)
Definition XYZColor.h:56
NDEVR_BASE_API XYZColor(const HSLColor &)
NDEVR_BASE_API XYZColor(const LABColor &)
void setA(fltp04 a)
Definition XYZColor.h:83
static XYZColor getD65()
Definition XYZColor.h:87
void setY(fltp04 y)
Definition XYZColor.h:75
constexpr XYZColor()
Definition XYZColor.h:53
Definition ACIColor.h:37
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.
Definition BaseFunctions.hpp:207
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
Definition BaseValues.hpp:127
@ Y
Definition BaseValues.hpp:169
@ X
Definition BaseValues.hpp:167
@ Z
Definition BaseValues.hpp:171
@ W
Definition BaseValues.hpp:173
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233