33#include <NDEVR/Color.h>
34#include <NDEVR/Vector.h>
35#include <NDEVR/BufferBase.h>
76 : Vector<4,
uint01>(*reinterpret_cast<Vector<4,
uint01>*>(&value))
100 : Vector<4,
uint01>(r, g, b, a)
123 : Vector<4,
uint01>(color)
130 template<
class t_type>
132 : Vector<4,
uint01>(color[0], color[0], color[0], 255)
138 template<
class t_type>
146 template<
class t_type>
154 template<
class t_type>
163 NDEVR_BASE_API
explicit RGBColor(
const Vector<4, fltp04>& color);
168 NDEVR_BASE_API
explicit RGBColor(
const Vector<4, fltp08>& color);
173 NDEVR_BASE_API
explicit RGBColor(
const Vector<3, fltp04>& color);
178 NDEVR_BASE_API
explicit RGBColor(
const Vector<3, fltp08>& color);
183 NDEVR_BASE_API
explicit RGBColor(
const Vector<2, fltp04>& color);
188 NDEVR_BASE_API
explicit RGBColor(
const Vector<2, fltp08>& color);
193 NDEVR_BASE_API
explicit RGBColor(
const Vector<1, fltp04>& color);
198 NDEVR_BASE_API
explicit RGBColor(
const Vector<1, fltp08>& color);
259 NDEVR_BASE_API Vector<3, fltp04>
get3F()
const;
264 NDEVR_BASE_API Vector<4, fltp04>
get4F()
const;
333 for(
uint04 dim = 0; dim < 4; ++dim)
416 static const bool Enum =
false;
427 static_assert(
sizeof(RGBColor) == 4,
"Bad Color size");
429 template<>
constexpr const RGBColor Constant<RGBColor>::Invalid =
RGBColor(255, 255, 254, 0);
430 template<>
constexpr const RGBColor Constant<RGBColor>::Max =
RGBColor(255, 255, 255, 255);
439 template<
class t_type>
444 for (
uint01 dim = 0; dim < 3; ++dim)
459 for (
uint01 dim = 0; dim < 3; ++dim)
475 for (
uint01 dim = 0; dim < 3; ++dim)
480 static_assert(
sizeof(RGBColor) == 4,
"Bad color size");
A color identified by an AutoCAD Color Index (ACI) number from 1 through 255.
The core Color class in the NDEVR API.
A color defined by hue, saturation, and brightness components.
A color defined by hue, saturation, and luminosity components.
Forward declaration of the NDEVR translated string class.
Represents a color in the RGB space with optional alpha transparency.
fltp04 getF(uint01 channel) const
Gets a channel value as a normalized float in [0, 1].
String getHexRGB() const
Gets the hex string representation of this color in RGB format (e.g., "#FF0000").
RGBColor(const Vector< 1, fltp04 > &color)
Constructs an RGBColor from a 1-dimensional single-precision float vector (grayscale).
String getHexARGB() const
Gets the hex string representation of this color in ARGB format (e.g., "#FFFF0000").
static const uint01 a_pos
The index of the alpha channel in the RGBA color struct.
uint04 convertTo24BitColor() const
Packs this color into a 24-bit unsigned integer (RGB only, no alpha).
static const uint01 r_pos
The index of the red channel in the RGBA color struct.
static RGBColor create24BitColor(uint04 color_24)
Creates an RGBColor from a packed 24-bit RGB color value.
Vector< 3, fltp04 > get3F() const
Gets the RGB channels as a 3-dimensional float vector normalized to [0, 1].
static const uint01 g_pos
The index of the green channel in the RGBA color struct.
RGBColor(const fltp08 r, const fltp08 g, const fltp08 b, const fltp08 a=1.0f)
Constructs an RGBColor from double-precision floating-point channel values.
void setF(uint01 channel, fltp04 value)
Sets a channel value from a normalized float in [0, 1].
TranslatedString getName() const
Gets the closest known name for this color as a translated string.
RGBColor(const Vector< 2, fltp04 > &color)
Constructs an RGBColor from a 2-dimensional single-precision float vector (grayscale + alpha).
static RGBColor Average(const RGBColor &a, const RGBColor &b, fltp04 percent=0.5f)
Computes a weighted average of two colors in RGB space.
RGBColor(const Vector< 3, t_type > &color)
Constructs an RGBColor from a 3-dimensional vector (RGB).
RGBColor(const LABColor &)
Constructs an RGBColor by converting from a LABColor.
RGBColor(const fltp04 r, const fltp04 g, const fltp04 b, const fltp04 a=1.0f)
Constructor to initialize color using floating-point values for each channel.
RGBColor(const XYZColor &)
Constructs an RGBColor by converting from an XYZColor.
RGBColor(uint04 value)
Constructs an RGBColor from a packed 32-bit unsigned integer.
uint04 convertToABGR32BitColor() const
Packs this color into a 32-bit unsigned integer in ABGR byte order.
static RGBColor CreateRGBA32BitColor(uint04 color_32)
Creates an RGBColor from a packed 32-bit RGBA color value.
RGBColor(const Vector< 2, t_type > &color)
Constructs an RGBColor from a 2-dimensional vector (grayscale + alpha).
RGBColor(const Vector< 3, fltp08 > &color)
Constructs an RGBColor from a 3-dimensional double-precision float vector (RGB in [0,...
constexpr RGBColor()
Default constructor.
constexpr RGBColor & operator=(const RGBColor &color)
Copy assignment operator.
RGBColor(const Vector< 4, fltp08 > &color)
Constructs an RGBColor from a 4-dimensional double-precision float vector (RGBA in [0,...
constexpr RGBColor(const sint04 r, const sint04 g, const sint04 b, const sint04 a=255)
Constructs an RGBColor from signed integer channel values, clamping each to [0, 255].
RGBColor(const Vector< 4, fltp04 > &color)
Constructs an RGBColor from a 4-dimensional single-precision float vector (RGBA in [0,...
RGBColor(const Vector< 3, fltp04 > &color)
Constructs an RGBColor from a 3-dimensional single-precision float vector (RGB in [0,...
RGBColor(const ACIColor &)
Constructs an RGBColor by converting from an ACIColor.
fltp04 luminance() const
Returns the luminance of the color.
Vector< 4, fltp04 > get4F() const
Gets all RGBA channels as a 4-dimensional float vector normalized to [0, 1].
static RGBColor AverageLAB(const RGBColor &a, const RGBColor &b, fltp04 percent=0.5f)
Computes a weighted average of two colors in perceptually uniform LAB space.
RGBColor(const Vector< 2, fltp08 > &color)
Constructs an RGBColor from a 2-dimensional double-precision float vector (grayscale + alpha).
size_t operator()() const
Functor operator that returns the packed 32-bit RGBA representation, useful as a hash.
bool isLight() const
Determines whether this color is perceptually light.
static RGBColor CreateARGB32BitColor(uint04 color_32)
Creates an RGBColor from a packed 32-bit ARGB color value.
RGBColor(const Vector< 1, t_type > &color)
Constructs an RGBColor from a 1-dimensional vector, using the value as a grayscale intensity.
static RGBColor FromHexARGB(StringView hex)
Creates an RGBColor from a hex string in ARGB format.
RGBColor(const HSBColor &)
Constructs an RGBColor by converting from an HSBColor.
RGBColor(const Vector< 1, fltp08 > &color)
Constructs an RGBColor from a 1-dimensional double-precision float vector (grayscale).
RGBColor contrastingColor() const
Returns a color that contrasts well with this color for readability.
RGBColor(const Vector< 4, t_type > &color)
Constructs an RGBColor from a 4-dimensional vector (RGBA).
constexpr RGBColor(const uint01 r, const uint01 g, const uint01 b, const uint01 a=255)
Constructor to initialize color using integer values for each channel.
RGBColor(const HSLColor &)
Constructs an RGBColor by converting from an HSLColor.
constexpr RGBColor(const RGBColor &color)
Copy constructor.
String getHexRGBA() const
Gets the hex string representation of this color in RGBA format (e.g., "#FF0000FF").
static RGBColor Average(const RGBColor &a, const RGBColor &b, const RGBColor &c)
Computes the average of three colors in RGB space.
RGBColor opaque() const
Returns a copy of this color with alpha set to 255 (fully opaque).
uint04 convertToRGBA32BitColor() const
Packs this color into a 32-bit unsigned integer in RGBA byte order.
static const uint01 b_pos
The index of the blue channel in the RGBA color struct.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
constexpr decltype(auto) as() const
Forward declaration of HSLColor.
The primary namespace for the NDEVR SDK.
static const fltp04 inverse_255
Precomputed reciprocal of 255 for fast normalization to [0,1].
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
static constexpr Angle< t_type > operator*(const Angle< t_type > &angle_a, const Angle< t_type > &angle_b)
Multiplication operator.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
static constexpr Angle< t_angle_type > & operator*=(Angle< t_angle_type > &angle, const t_type &mult)
Multiplication assignment operator for an Angle and a scalar.
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.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
static const bool Unsigned
Not treated as a generic unsigned type.
static const bool Boolean
Not a boolean type.
static constexpr ObjectInfo< uint01, false > VectorSub()
Returns the ObjectInfo for the underlying vector element type (uint01).
static const bool Integer
Not a generic integer type.
static const bool Primitive
Useful for buffers.
static const bool Enum
Not an enum type.
static const bool Pointer
True if the object is a pointer.
static const bool Buffer
Not a buffer type.
static const bool Color
This type represents a color.
static const bool String
Not a string type.
static const bool Vector
True because RGBColor is a vector type.
static const bool Number
Not a generic number type.
static const bool Float
Not a floating-point type.
static const uint01 Dimensions
Number of channels (R, G, B, A).
Information about the object.