-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincludes.h
More file actions
91 lines (89 loc) · 1.36 KB
/
includes.h
File metadata and controls
91 lines (89 loc) · 1.36 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <GL/glut.h>
#include <iostream>
#include <vector>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "Keyboard.h"
using namespace std;
void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v)
{
float minval, maxval, delta;
minval = min(r, min(g, b));
maxval = max(r, max(g, b));
*v = maxval;
delta = maxval - minval;
if (maxval != 0)
*s = delta / maxval;
else
{
*s = 0;
*h = -1;
return;
}
if (r == maxval)
*h = (g - b) / delta;
else if (g == maxval)
*h = 2 + (b - r) / delta;
else
*h = 4 + (r - g) / delta;
*h *= 60;
if (*h < 0)
*h += 360;
}
void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v)
{
int i;
float f, p, q, t;
if (s == 0) {
*r = *g = *b = v;
return;
}
h /= 60;
i = (int)floor(h);
f = h - i;
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));
switch (i) {
case 0:
*r = v;
*g = t;
*b = p;
break;
case 1:
*r = q;
*g = v;
*b = p;
break;
case 2:
*r = p;
*g = v;
*b = t;
break;
case 3:
*r = p;
*g = q;
*b = v;
break;
case 4:
*r = t;
*g = p;
*b = v;
break;
default:
*r = v;
*g = p;
*b = q;
break;
}
}
Keyboard kbd;
void keyboardUp(int keyCode, int x, int y) {
kbd.keyboardUp(keyCode);
}
void keyboardDown(int keyCode, int x, int y) {
//printf("%d ", keyCode);
kbd.keyboardDown(keyCode);
}