-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColour.java
134 lines (113 loc) · 4 KB
/
Colour.java
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
//Custom Colours
import java.awt.Color;
public class Colour {
//colours used for each piece
//pieces with more or less chunks/squares imitate its closest shape based off of the original tetris game
private static final Color iPiece = new Color(81, 204, 200);
private static final Color jPiece = new Color(3, 65, 174);
private static final Color lPiece = new Color(255, 151, 28);
private static final Color oPiece = new Color(255, 213, 0);
private static final Color sPiece = new Color(114, 203, 59);
private static final Color zPiece = new Color(255, 50, 19);
private static final Color tPiece = new Color(113, 92, 204);
//customized culours
public static final Color beige = new Color(237, 224, 178);
public static final Color grey = new Color(212, 202, 198);
public static final Color black = new Color(58, 57, 53);
public static final Color white = new Color(222, 222, 222);
public static Color defaultColour = beige;
public static Color defaultLineColour = grey;
//colour set that will be passed on which include the corresponding colour for each piece used in the current set
public static Color[] PieceColors;
public static final Color[] CompleteColourSet = {
iPiece,
jPiece,
lPiece,
lPiece,
jPiece,
zPiece,
sPiece,
oPiece,
oPiece,
tPiece,
tPiece,
iPiece,
tPiece,
tPiece,
lPiece,
jPiece,
sPiece,
zPiece,
iPiece,
jPiece,
lPiece,
oPiece,
sPiece,
tPiece,
zPiece,
iPiece,
lPiece,
iPiece,
oPiece
};
public static Color getDefaultColour() {
return defaultColour;
}
public static void setDefaultColour(int r, int g, int b) {
defaultColour = new Color(r, g, b);
return;
}
//fun piece of code which determines whether a given colour is considered "dark", "neutral", or "bright"
public static void setLineColour(Color defaultColour) {
int r = defaultColour.getRed();
int g = defaultColour.getGreen();
int b = defaultColour.getBlue();
double hspValue = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
if (hspValue < 85) {
defaultLineColour = white;
} else if (hspValue < 170) {
defaultLineColour = grey;
} else {
defaultLineColour = black;
}
return;
}
//takes the correct colours from the full colour pool and adds it to the pool for the pieces that WILL be used
public static void setPieceColourSet(int pieceSetInclusion) {
switch (pieceSetInclusion) {
case 1:
PieceColors = new Color[1];
for (int i = 0; i < 1; i++) {
PieceColors[i] = CompleteColourSet[CompleteColourSet.length - (1 + i)];
}
break;
case 2:
PieceColors = new Color[1];
for (int i = 0; i < 1; i++) {
PieceColors[i] = CompleteColourSet[CompleteColourSet.length - (2 + i)];
}
break;
case 3:
PieceColors = new Color[2];
for (int i = 0; i < 2; i++) {
PieceColors[i] = CompleteColourSet[CompleteColourSet.length - (3 + i)];
}
break;
case 4:
PieceColors = new Color[7];
for (int i = 0; i < 7; i++) {
PieceColors[i] = CompleteColourSet[CompleteColourSet.length - (5 + i)];
}
break;
case 5:
PieceColors = new Color[18];
for (int i = 0; i < 18; i++) {
PieceColors[i] = CompleteColourSet[CompleteColourSet.length - (12 + i)];
}
break;
case 0:
PieceColors = CompleteColourSet;
break;
}
}
}