-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor.cpp
executable file
·144 lines (129 loc) · 3.38 KB
/
Color.cpp
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* File: Color.cpp
* Author: scribble
*
* Created on November 5, 2012, 6:01 PM
*/
#include "Color.h"
#include "Alert.h"
Color::Color() {
//black by default
red = 0.0;
green = 0.0;
blue = 0.0;
}
Color::Color(int color) {
switch (color) {
case GREEN:
red = convertToFloat(102);
green = convertToFloat(204);
blue = convertToFloat(102);
break;
case LIGHT_GRAY:
red = convertToFloat(220);
green = convertToFloat(220);
blue = convertToFloat(220);
break;
case DARK_GRAY:
red = convertToFloat(130);
green = convertToFloat(130);
blue = convertToFloat(130);
break;
case WHITE:
red = convertToFloat(255);
green = convertToFloat(255);
blue = convertToFloat(255);
break;
case PALETTE_BLACK:
red = convertToFloat(0);
green = convertToFloat(0);
blue = convertToFloat(0);
break;
case PALETTE_WHITE:
red = convertToFloat(255);
green = convertToFloat(255);
blue = convertToFloat(255);
break;
case PALETTE_GRAY:
red = convertToFloat(128);
green = convertToFloat(128);
blue = convertToFloat(128);
break;
case PALETTE_BLUE:
red = convertToFloat(0);
green = convertToFloat(0);
blue = convertToFloat(153);
break;
case PALETTE_GREEN:
red = convertToFloat(0);
green = convertToFloat(102);
blue = convertToFloat(0);
break;
case PALETTE_INDIGO:
red = convertToFloat(0);
green = convertToFloat(102);
blue = convertToFloat(102);
break;
case PALETTE_ORANGE:
red = convertToFloat(255);
green = convertToFloat(102);
blue = convertToFloat(0);
break;
case PALETTE_RED:
red = convertToFloat(204);
green = convertToFloat(0);
blue = convertToFloat(0);
break;
case PALETTE_VIOLET:
red = convertToFloat(153);
green = convertToFloat(0);
blue = convertToFloat(204);
break;
case PALETTE_YELLOW:
red = convertToFloat(255);
green = convertToFloat(204);
blue = convertToFloat(0);
break;
default:
red = convertToFloat(0);
green = convertToFloat(0);
blue = convertToFloat(0);
break;
}
}
//values from 0-255
Color::Color(float r, float g, float b) {
red = convertToFloat(r);
green = convertToFloat(g);
blue = convertToFloat(b);
}
Color::Color(const Color& orig) {
red = orig.red;
green = orig.green;
blue = orig.blue;
}
Color::~Color() {
}
float Color::getRed() {
return red;
}
float Color::getGreen() {
return green;
}
float Color::getBlue() {
return blue;
}
void Color::setColor(int r, int g, int b) {
red = convertToFloat(r);
green = convertToFloat(g);
blue = convertToFloat(b);
}
/*void Color::setColorFromColor(float r, float g, float b){
#warning //error
red = r;
//green = g;
//blue = b;
}*/
float Color::convertToFloat(int x) {
return x / 255.0;
}