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 <NDEVR/Vector.h>
34namespace NDEVR
35{
36 class RGBColor;
37 class ACIColor;
38 class LABColor;
39 class HSBColor;
40 class HSLColor;
41 // ----------------------------------------------------------------------------
42 // In opposition to the previous models, the CIE XYZ model defines an absolute
43 // color space.
44 // It is also known as the CIE 1931 XYZ color space and stands for:
45 // X, which can be compared to red Ranges from 0 to 0.9505
46 // Y, which can be compared to green Ranges from 0 to 1.0
47 // Z, which can be compared to blue Ranges from 0 to 1.089
48 // ----------------------------------------------------------------------------
49 class XYZColor : public Vector<4, fltp04>
50 {
51 public:
52 constexpr XYZColor()
53 : Vector<4, fltp04>(Constant<fltp04>::NaN)
54 {}
55 constexpr explicit XYZColor(const Vector<4, fltp04>& color)
56 : Vector<4, fltp04>(color)
57 {}
58 constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a = 1.0f)
59 : Vector<4, fltp04>(
60 clip(x, 0.0f, 0.9505f)
61 , clip(y, 0.0f, 1.0f)
62 , clip(z, 0.0f, 1.0f)
63 , a)
64 {}
65 explicit NDEVR_BASE_API XYZColor(const RGBColor&);
66 explicit NDEVR_BASE_API XYZColor(const ACIColor&);
67 explicit NDEVR_BASE_API XYZColor(const LABColor&);
68 explicit NDEVR_BASE_API XYZColor(const HSBColor&);
69 explicit NDEVR_BASE_API XYZColor(const HSLColor&);
70 void setX(fltp04 x)
71 {
72 m_values[X] = (x > 0.9505f) ? 0.9505f : ((x < 0.0f) ? 0.0f : x);
73 }
74 void setY(fltp04 y)
75 {
76 m_values[Y] = (y > 1.0000f) ? 1.0000f : ((y < 0.0f) ? 0.0f : y);
77 }
78 void setZ(fltp04 z)
79 {
80 m_values[Z] = (z > 1.0890f) ? 1.0890f : ((z < 0.0f) ? 0.0f : z);
81 }
82 void setA(fltp04 a)
83 {
84 m_values[W] = a;
85 }
86 static XYZColor getD65()
87 {
88 static XYZColor D65(95.047f, 100.0f, 108.883f);
89 return D65;
90 }
91 };
92 template<>
94 template<>
96 template<>
98}
#define NDEVR_BASE_API
Definition DLLInfo.h:78
ACI colors are the standard colors used in AutoCAD-based products. Each color is identified by an ACI...
Definition ACIColor.h:58
Definition HSBColor.h:56
Definition HSLColor.h:54
Definition LABColor.h:60
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
fltp04 m_values[t_dims]
Definition Vector.hpp:675
Definition XYZColor.h:50
constexpr XYZColor(fltp04 x, fltp04 y, fltp04 z, fltp04 a=1.0f)
Definition XYZColor.h:58
void setZ(fltp04 z)
Definition XYZColor.h:78
void setX(fltp04 x)
Definition XYZColor.h:70
constexpr XYZColor(const Vector< 4, fltp04 > &color)
Definition XYZColor.h:55
void setA(fltp04 a)
Definition XYZColor.h:82
static XYZColor getD65()
Definition XYZColor.h:86
void setY(fltp04 y)
Definition XYZColor.h:74
constexpr XYZColor()
Definition XYZColor.h:52
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:240
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
@ W
Definition BaseValues.hpp:206
Definition BaseValues.hpp:272