API Documentation
Loading...
Searching...
No Matches
HSBColor.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: HSBColor
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Angle.h>
34#include <NDEVR/Vector.h>
35#include <NDEVR/Buffer.h>
36namespace NDEVR
37{
38 class RGBColor;
39 class ACIColor;
40 class LABColor;
41 class XYZColor;
42 /**----------------------------------------------------------------------------
43 \brief The HSB (Hue, Saturation, Brightness) color model defines a color space in
44 terms of three constituent components hue, brightness and brightness
45
46 Hue: the color type (such as red, blue, or yellow).
47 Ranges from 0 to 360 (each value corresponds to one color:
48 0 is red, 45 is a shade of orange and 55 is a shade of yellow).
49
50 Saturation: the saturation of the color.
51
52 Brightness: the brightness of the color.
53 Ranges from 0 to 100% (0 is always black; depending on the saturation, 100 may be white or a more or less saturated color).
54 // ----------------------------------------------------------------------------*/
57 {
58 public:
63 public:
65 {}
66 constexpr HSBColor(const Angle<HSBAngleType>& h, uint01 s, uint01 b, uint01 a = 255)
67 : hue(h)
68 , saturation(s)
69 , brightness(b)
70 , alpha(a)
71 {}
72
73 constexpr HSBColor(const Angle<HSBAngleType>& h, fltp08 s, fltp08 b, fltp08 a = 1.0)
74 : hue(h)
75 , saturation(cast<uint01>((s > 1) ? 1 : ((s < 0) ? 0 : s) * 255))
76 , brightness(cast<uint01>((b > 1) ? 1 : ((b < 0) ? 0 : b) * 255))
77 , alpha(cast<uint01>(a *255))
78 {}
79
80 constexpr HSBColor(const Angle<HSBAngleType>& h, fltp04 s, fltp04 b, fltp04 a = 1.0f)
81 : hue(h)
82 , saturation(cast<uint01>((s > 1) ? 1 : ((s < 0) ? 0 : s) * 255))
83 , brightness(cast<uint01>((b > 1) ? 1 : ((b < 0) ? 0 : b) * 255))
84 , alpha(cast<uint01>(a * 255))
85 {}
86
87 constexpr HSBColor(fltp08 h, fltp08 s, fltp08 b, fltp08 a = 1.0f)
89 , saturation(cast<uint01>((s > 1) ? 1 : ((s < 0) ? 0 : s) * 255))
90 , brightness(cast<uint01>((b > 1) ? 1 : ((b < 0) ? 0 : b) * 255))
91 , alpha(cast<uint01>(a * 255))
92 {}
93
94 constexpr HSBColor(fltp04 h, fltp04 s, fltp04 b, fltp04 a = 1.0f)
95 : hue(Angle<sint01>(DEGREES, h))
96 , saturation(cast<uint01>((s > 1) ? 1 : ((s < 0) ? 0 : s) * 255))
97 , brightness(cast<uint01>((b > 1) ? 1 : ((b < 0) ? 0 : b) * 255))
98 , alpha(cast<uint01>(a * 255))
99 {}
104
105 fltp04 getBF() const
106 {
107 return cast<fltp04>(brightness) / 255.0f;
108 }
109 fltp04 getBS() const
110 {
111 return cast<fltp04>(saturation) / 255.0f;
112 }
113 fltp04 getAF() const
114 {
115 return cast<fltp04>(alpha) / 255.0f;
116 }
117 NDEVR_BASE_API static HSBColor ConvertColor(const LABColor& current_color, const Buffer<std::pair<LABColor, LABColor>, uint04, ObjectAllocator<true>>& pairs, bool preserve_brightness, bool preserve_alpha);
118 };
119 template<>
121 template<>
123 template<>
125}
126
#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
The primary angle storage class for this API. Stores an angle in an optimized format.
Definition StringStream.h:408
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Definition HSBColor.h:57
NDEVR_BASE_API HSBColor(const RGBColor &)
constexpr HSBColor(const Angle< HSBAngleType > &h, uint01 s, uint01 b, uint01 a=255)
Definition HSBColor.h:66
uint01 alpha
Definition HSBColor.h:62
constexpr HSBColor(fltp08 h, fltp08 s, fltp08 b, fltp08 a=1.0f)
Definition HSBColor.h:87
constexpr HSBColor(fltp04 h, fltp04 s, fltp04 b, fltp04 a=1.0f)
Definition HSBColor.h:94
uint01 brightness
Definition HSBColor.h:61
uint01 saturation
Definition HSBColor.h:60
Angle< HSBAngleType > hue
Definition HSBColor.h:59
constexpr HSBColor(const Angle< HSBAngleType > &h, fltp04 s, fltp04 b, fltp04 a=1.0f)
Definition HSBColor.h:80
fltp04 getBF() const
Definition HSBColor.h:105
NDEVR_BASE_API HSBColor(const ACIColor &)
fltp04 getAF() const
Definition HSBColor.h:113
static NDEVR_BASE_API HSBColor ConvertColor(const LABColor &current_color, const Buffer< std::pair< LABColor, LABColor >, uint04, ObjectAllocator< true > > &pairs, bool preserve_brightness, bool preserve_alpha)
HSBColor()
Definition HSBColor.h:64
fltp04 getBS() const
Definition HSBColor.h:109
constexpr HSBColor(const Angle< HSBAngleType > &h, fltp08 s, fltp08 b, fltp08 a=1.0)
Definition HSBColor.h:73
NDEVR_BASE_API HSBColor(const XYZColor &)
NDEVR_BASE_API HSBColor(const Vector< 4, fltp04 > &color)
A Lab color space is a color-opponent space with dimension L for luminance and a and b for the color-...
Definition LABColor.h:60
Definition MemoryManager.h:261
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
In opposition to the previous models, the CIE XYZ model defines an absolute color space....
Definition XYZColor.h:50
Definition ACIColor.h:37
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:62
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:125
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:78
@ DEGREES
Definition Angle.h:62
int8_t sint01
-Defines an alias representing a 1 byte, signed integer. -Can represent exact integer values -127 thr...
Definition BaseValues.hpp:48
sint04 HSBAngleType
The HSB (Hue, Saturation, Brightness) color model defines a color space in terms of three constituent...
Definition HSBColor.h:55
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:94
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:379
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230