roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
hsv.cpp
Go to the documentation of this file.
1
#include "
roo_display/color/hsv.h
"
2
3
#include <stdlib.h>
4
5
namespace
roo_display
{
6
7
Color
HsvToRgb
(
float
h,
float
s
,
float
v) {
8
// See https://en.wikipedia.org/wiki/HSL_and_HSV.
9
float
c
= v *
s
;
10
float
hp
= h / 60.0;
11
int
ihp
= (
int
)
hp
;
12
float
x =
c
* (1 -
abs
((
hp
- 2 * (
ihp
/ 2)) - 1));
13
float
m
= v -
c
;
14
int
ix
= (
int
)(255 * x);
15
int
ic
= (
int
)(255 *
c
);
16
int
im
= (
int
)(255 *
m
);
17
int
ixm
=
ix
+
im
;
18
int
icm
=
ic
+
im
;
19
switch
(
ihp
% 6) {
20
case
0:
21
return
Color
(
icm
,
ixm
,
im
);
22
case
1:
23
return
Color
(
ixm
,
icm
,
im
);
24
case
2:
25
return
Color
(
im
,
icm
,
ixm
);
26
case
3:
27
return
Color
(
im
,
ixm
,
icm
);
28
case
4:
29
return
Color
(
ixm
,
im
,
icm
);
30
case
5:
31
return
Color
(
icm
,
im
,
ixm
);
32
default
:
33
return
Color
(0);
34
}
35
}
36
37
}
// namespace roo_display
roo_display::Color
ARGB8888 color stored as a 32-bit unsigned integer.
Definition
color.h:16
hsv.h
roo_display
Defines 140 opaque HTML named colors.
Definition
roo_display.cpp:7
roo_display::HsvToRgb
Color HsvToRgb(float h, float s, float v)
Convert HSV (h, s, v) to an RGB Color.
Definition
hsv.cpp:7
roo_display::BlendOp
Definition
blending.h:200
temp_repos
roo_display
src
roo_display
color
hsv.cpp
Generated by
1.9.8