VR-Engage  2.2
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1/*********************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*********************************************************************************/
5
6#pragma once
7
8//! \file color.h
9//! \brief Provides color representation and manipulation functionality
10
11#include "vreUtil/export.h"
12
13namespace makVre
14{
15
16//! \brief Class for representing and manipulating RGBA colors
17//!
18//! This class provides functionality for working with colors in RGBA format.
19//! It includes methods for creating common colors and converting between
20//! different color representations.
22{
23public:
24 //! \brief Fill mode enumeration for rendering
25 enum Fill
26 {
27 FILL_SOLID, //!< Solid fill mode
28 FILL_TRANSPARENT, //!< Transparent fill mode
29 FILL_WIREFRAME, //!< Wireframe fill mode
30 FILL_NONE //!< No fill mode
31 };
32
33 //! \brief Default constructor
34 //!
35 //! Creates a white opaque color (RGBA: 1,1,1,1)
36 DtColor() { r = g = b = a = 1.0; }
37
38 //! \brief Constructor with RGBA components
39 //!
40 //! \param rr Red component (0.0 to 1.0)
41 //! \param gg Green component (0.0 to 1.0)
42 //! \param bb Blue component (0.0 to 1.0)
43 //! \param aa Alpha component (0.0 to 1.0, where 1.0 is fully opaque)
44 DtColor(float rr, float gg, float bb, float aa)
45 : r(rr)
46 , g(gg)
47 , b(bb)
48 , a(aa)
49 {
50 }
51
52 //! \brief Destructor
54
55 //! \brief Converts the color to an unsigned integer representation
56 //!
57 //! The color is packed as 0xRRGGBBAA with 8 bits per channel
58 //!
59 //! \return The color as a 32-bit unsigned integer
60 unsigned int toUInt() const;
61
62 //! \brief Creates a white color (RGBA: 1,1,1,1)
63 //!
64 //! \return A white color
65 static DtColor white() { return DtColor(1, 1, 1, 1); }
66
67 //! \brief Creates a black color (RGBA: 0,0,0,1)
68 //!
69 //! \return A black color
70 static DtColor black() { return DtColor(0, 0, 0, 1); }
71
72 //! \brief Creates a blue color (RGBA: 0,0,1,1)
73 //!
74 //! \return A blue color
75 static DtColor blue() { return DtColor(0, 0, 1, 1); }
76
77 //! \brief Creates a green color (RGBA: 0,1,0,1)
78 //!
79 //! \return A green color
80 static DtColor green() { return DtColor(0, 1, 0, 1); }
81
82 //! \brief Creates a red color (RGBA: 1,0,0,1)
83 //!
84 //! \return A red color
85 static DtColor red() { return DtColor(1, 0, 0, 1); }
86
87 //! \brief Creates an orange color (RGBA: 1,0.5,0,1)
88 //!
89 //! \return An orange color
90 static DtColor orange() { return DtColor(1, 0.5, 0, 1); }
91
92 //! \brief Creates a yellow color (RGBA: 1,1,0,1)
93 //!
94 //! \return A yellow color
95 static DtColor yellow() { return DtColor(1, 1, 0, 1); }
96
97 //! \brief Equality comparison operator
98 //!
99 //! \param other The color to compare with
100 //! \return true if the colors are identical, false otherwise
101 bool operator==(const DtColor& other) const;
102
103 //! \brief Red component (0.0 to 1.0)
104 float r;
105
106 //! \brief Green component (0.0 to 1.0)
107 float g;
108
109 //! \brief Blue component (0.0 to 1.0)
110 float b;
111
112 //! \brief Alpha component (0.0 to 1.0, where 1.0 is fully opaque)
113 float a;
114};
115
116} // namespace makVre
~DtColor()
Destructor.
Definition color.h:53
static DtColor white()
Creates a white color (RGBA: 1,1,1,1)
Definition color.h:65
float b
Blue component (0.0 to 1.0)
Definition color.h:110
static DtColor red()
Creates a red color (RGBA: 1,0,0,1)
Definition color.h:85
Fill
Fill mode enumeration for rendering.
Definition color.h:26
@ FILL_TRANSPARENT
Transparent fill mode.
Definition color.h:28
@ FILL_SOLID
Solid fill mode.
Definition color.h:27
@ FILL_NONE
No fill mode.
Definition color.h:30
@ FILL_WIREFRAME
Wireframe fill mode.
Definition color.h:29
bool operator==(const DtColor &other) const
Equality comparison operator.
float r
Red component (0.0 to 1.0)
Definition color.h:104
static DtColor green()
Creates a green color (RGBA: 0,1,0,1)
Definition color.h:80
static DtColor yellow()
Creates a yellow color (RGBA: 1,1,0,1)
Definition color.h:95
static DtColor black()
Creates a black color (RGBA: 0,0,0,1)
Definition color.h:70
DtColor()
Default constructor.
Definition color.h:36
static DtColor blue()
Creates a blue color (RGBA: 0,0,1,1)
Definition color.h:75
DtColor(float rr, float gg, float bb, float aa)
Constructor with RGBA components.
Definition color.h:44
float g
Green component (0.0 to 1.0)
Definition color.h:107
unsigned int toUInt() const
Converts the color to an unsigned integer representation.
float a
Alpha component (0.0 to 1.0, where 1.0 is fully opaque)
Definition color.h:113
static DtColor orange()
Creates an orange color (RGBA: 1,0.5,0,1)
Definition color.h:90
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49