Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
11
#include "
core/types.h
"
12
#include "
math/vec4.h
"
13
14
//------------------------------------------------------------------------------
15
namespace
Util
16
{
17
class
Color
:
public
Math::vec4
18
{
19
public
:
21
Color
() =
default
;
23
Color
(
const
Color
& c) =
default
;
25
Color
(
float
r,
float
g,
float
b,
float
a);
27
Color
(
const
Math::vec4
&
v
);
29
Color
(
const
Math::vec3
&
v
);
31
Color
(uint32_t argb);
33
explicit
Color
(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
35
static
Color
RGBA
(uint32_t rgba);
37
static
Color
ARGB
(uint32_t argb);
38
39
// predefined, common colors.
40
42
static
const
Color
red
;
44
static
const
Color
green
;
46
static
const
Color
blue
;
48
static
const
Color
yellow
;
50
static
const
Color
purple
;
52
static
const
Color
orange
;
54
static
const
Color
black
;
56
static
const
Color
white
;
58
static
const
Color
gray
;
59
};
60
61
//------------------------------------------------------------------------------
64
__forceinline
65
Color::Color
(
float
r,
float
g,
float
b,
float
a)
66
:
Math
::
vec4
(r, g, b, a)
67
{
68
// empty
69
}
70
71
//------------------------------------------------------------------------------
74
__forceinline
75
Color::Color
(
const
Math::vec4
&
v
)
76
:
Math
::
vec4
(
v
)
77
{
78
// empty
79
}
80
81
//------------------------------------------------------------------------------
84
__forceinline
85
Color::Color
(
const
Math::vec3
&
v
)
86
:
Math
::
vec4
(
v
, 1.0f)
87
{
88
// empty
89
}
90
91
//------------------------------------------------------------------------------
94
__forceinline
95
Color::Color
(uint32_t argb)
96
{
97
const
float
scale = 1.0f / 255.0f;
98
this->
vec
= _mm_setr_ps(
99
scale * ((argb >> 16) & 0xFF), scale * ((argb >> 8) & 0xFF), scale * (argb & 0xFF), scale * ((argb >> 24) & 0xFF)
100
);
101
}
102
//------------------------------------------------------------------------------
105
__forceinline
106
Color::Color
(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
107
{
108
const
float
scale = 1.0f / 255.0f;
109
this->
vec
= _mm_setr_ps(scale * r, scale * g, scale * b, scale * a);
110
}
111
112
//--------------------------------------------------------------------------
115
__forceinline
Color
116
Color::RGBA
(uint32_t rgba)
117
{
118
return
Color
((uint8_t)((rgba >> 24) & 0xFF), (uint8_t)((rgba >> 16) & 0xFF), (uint8_t)((rgba >> 8) & 0xFF), (uint8_t)(rgba & 0xFF));
119
}
120
121
//--------------------------------------------------------------------------
124
__forceinline
Color
125
Color::ARGB
(uint32_t argb)
126
{
127
return
Color
(argb);
128
}
129
130
}
// namespace Util
Util::Color
Represents colors by four single point (32-bit) floating point numbers.
Definition
color.h:18
Util::Color::Color
Color()=default
Util::Color::blue
static const Color blue
Predefined color. (0x0000FF).
Definition
color.h:46
Util::Color::green
static const Color green
Predefined color. (0x00FF00).
Definition
color.h:44
Util::Color::yellow
static const Color yellow
Predefined color. (0xFFFF00).
Definition
color.h:48
Util::Color::purple
static const Color purple
Predefined color. (0xA020F0).
Definition
color.h:50
Util::Color::ARGB
static Color ARGB(uint32_t argb)
Create color from unsigned int (R|G|B|A) -> 0..1 floats.
Definition
color.h:125
Util::Color::white
static const Color white
Predefined color. (0xFFFFFF).
Definition
color.h:56
Util::Color::RGBA
static Color RGBA(uint32_t rgba)
Create color from unsigned int (A|R|G|B) -> 0..1 floats.
Definition
color.h:116
Util::Color::gray
static const Color gray
Predefined color. (0xBEBEBE).
Definition
color.h:58
Util::Color::red
static const Color red
Predefined color. (0xFF0000).
Definition
color.h:42
Util::Color::black
static const Color black
Predefined color. (0x000000).
Definition
color.h:54
Util::Color::Color
Color(const Color &c)=default
Util::Color::orange
static const Color orange
Predefined color. (0xFFA500).
Definition
color.h:52
Math
Different curves.
Definition
angularpfeedbackloop.h:17
Util
A quad tree designed to return regions of free 2D space.
Definition
String.cs:6
Math::vec3
A 3D vector.
Definition
vec3.h:37
Math::vec4
A 4D vector.
Definition
vec4.h:24
Math::vec4::vec4
vec4()=default
default constructor, NOTE: does NOT setup components!
Math::vec4::vec
__m128 vec
Definition
vec4.h:97
Math::vec4::v
float v[4]
Definition
vec4.h:98
types.h
vec4.h
code
foundation
util
color.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.