blob: 91a545541a03c5eff70a40bd77b011f01b76631c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "compute.h"
void function audio2hsv_1(gint audio_level, gint *light_h, gint *light_s, gint *light_v) {
// Dummy code
*light_h=-audio_level;
*light_s=audio_level;
*light_v=65535;
}
void hsv2rgb(gint h, gint s, gint v, gint *r, gint *g, gint *b) {
/*
* Purpose:
* Convert HSV values to RGB values
* All values are in the range [0..65535]
*/
float F, M, N, K;
int I;
if ( s == 0 ) {
/*
* Achromatic case, set level of grey
*/
*r = v;
*g = v;
*b = v;
} else {
I = (int) h/(65535/6); /* should be in the range 0..5 */
F = h - I; /* fractional part */
M = v * (1 - s);
N = v * (1 - s * F);
K = v * (1 - s * (1 - F));
if (I == 0) { *r = v; *g = K; *b = M; }
if (I == 1) { *r = N; *g = v; *b = M; }
if (I == 2) { *r = M; *g = v; *b = K; }
if (I == 3) { *r = M; *g = N; *b = v; }
if (I == 4) { *r = K; *g = M; *b = v; }
if (I == 5) { *r = v; *g = M; *b = N; }
}
}
|