-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArbitrary.h
92 lines (80 loc) · 1.57 KB
/
Arbitrary.h
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
92
#include "Mode.h"
class Arbitrary: public Mode {
private:
int red;
int green;
int blue;
// int hue
public:
Arbitrary() : Mode() {
int red = 64;
int green = 64;
int blue = 64;
// int hue =
}
~Arbitrary() {}
void get(long now, int rgb[]) {
rgb[0] = red;
rgb[1] = green;
rgb[2] = blue;
}
void adjust(char direction) {
}
void set(int r, int g, int b) {
red = r;
green = g;
blue = b;
}
void setR(int r) {
if (r < 0) {
red = 0;
}
else if (r >= 255) {
red = 255;
}
red = r;
}
void setG(int g) {
if (g < 0) {
green = 0;
}
else if (g >= 255) {
green = 255;
}
green = g;
}
void setB(int b) {
if (b < 0) {
blue = 0;
}
else if (b > 255) {
blue = 255;
}
blue = b;
}
void setHue(int h) {
int subh = h % 256;
if (h >= 0 && h < 256) {
red = 256 - subh;
green = subh;
blue = 0;
}
else if (h > 255 && h < 512) {
red = 0;
green = 256 - subh;
blue = subh;
}
else if (h > 511 && h < 768) {
red = subh;
green = 0;
blue = 256 - subh;
}
// hue = h;
// if (hue >= 768) {
// hue = 768;
// }
// else if (hue < 0) {
// hue = 0;
// }
}
};