-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconfirmationIcon.java
More file actions
189 lines (133 loc) · 5.24 KB
/
confirmationIcon.java
File metadata and controls
189 lines (133 loc) · 5.24 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package gui;
import core.mainThread;
import core.postProcessingThread;
import core.vector;
public class confirmationIcon {
public int color;
public static float[] sin;
public static float[] cos;
//centre of the icon
public vector centre;
public vector tempCentre;
public int frameIndex;
public static int screen_width = mainThread.screen_width;
public static int screen_height = mainThread.screen_height;
public confirmationIcon(){
//Make sin and cos look up tables
sin = new float[361];
cos = new float[361];
for(int i = 0; i < 361; i ++){
sin[i] = (float)Math.sin(Math.PI*i/180);
cos[i] = (float)Math.cos(Math.PI*i/180);
}
centre = new vector(0,0,0);
tempCentre = new vector(0,0,0);
frameIndex = -1;
}
public void setActive(float xPos, float zPos, int color){
centre.set(xPos, -0.5001f, zPos);
this.color = color;
frameIndex = 20;
}
public void updateAndDraw(){
if(frameIndex <0)
return;
vector cameraPosition = postProcessingThread.cameraPosition;
float X = 0,Y = 0, Z = 0,
camX = cameraPosition.x, camY = cameraPosition.y, camZ = cameraPosition.z,
sinXZ = postProcessingThread.sinXZ,
cosXZ = postProcessingThread.cosXZ,
sinYZ = postProcessingThread.sinYZ,
cosYZ = postProcessingThread.cosYZ;
X = centre.x - camX;
Y = centre.y - camY;
Z = centre.z - camZ;
//rotating
tempCentre.x = cosXZ*X - sinXZ*Z;
tempCentre.z = sinXZ*X + cosXZ*Z;
Z = tempCentre.z;
tempCentre.y = cosYZ*Y - sinYZ*Z;
tempCentre.z = sinYZ*Y + cosYZ*Z;
tempCentre.updateLocation();
int[] screen = postProcessingThread.currentScreen;
int x, y;
float a = 13f;
float b = 11.5f;
int lastIndex = -1;
int currentIndex;
int t = frameIndex - 10;
float transparency = 0.7f;
if(t < 0){
t = 0;
transparency = (float)frameIndex * transparency/10f;
}
int r1,b1,g1, r2,b2,g2, screenColor;
//draw transparent ring
for(int i = 0; i < 360; i+=1){
x = (int)(tempCentre.screenX + (a * (float)(12-t)/10f +0.7f) * cos[i]);
y = (int)(tempCentre.screenY + (b * (float)(12-t)/10f +0.7f)* sin[i]);
if(x < 0 || x >= screen_width || y < 0 || y >= screen_height)
continue;
currentIndex = x + y * screen_width;
if(currentIndex == lastIndex)
continue;
screenColor = screen[currentIndex];
r1 = (int)(((screenColor & 0xff0000) >> 16) * (1f - transparency*0.5f));
g1 = (int)(((screenColor & 0xff00) >> 8) * (1f - transparency * 0.5f));
b1 = (int)((screenColor & 0xff) * (1f - transparency * 0.5f));
r2 = (int)(((color & 0xff0000) >> 16) * transparency * 0.5f) + r1;
g2 = (int)(((color & 0xff00) >> 8) * transparency * 0.5f) + g1;
b2 = (int)((color & 0xff) * transparency * 0.5f) + b1;
screen[x + y * screen_width] = r2 << 16 | g2 << 8 | b2;
lastIndex = currentIndex;
}
for(int i = 0; i < 360; i+=1){
x = (int)(tempCentre.screenX + (a * (float)(12-t)/10f -1.7f) * cos[i]);
y = (int)(tempCentre.screenY + (b * (float)(12-t)/10f -1.7f)* sin[i]);
if(x < 0 || x >= screen_width || y < 0 || y >= screen_height)
continue;
currentIndex = x + y * screen_width;
if(currentIndex == lastIndex)
continue;
screenColor = screen[currentIndex];
r1 = (int)(((screenColor & 0xff0000) >> 16) * (1f - transparency*0.5f));
g1 = (int)(((screenColor & 0xff00) >> 8) * (1f - transparency * 0.5f));
b1 = (int)((screenColor & 0xff) * (1f - transparency * 0.5f));
r2 = (int)(((color & 0xff0000) >> 16) * transparency * 0.5f) + r1;
g2 = (int)(((color & 0xff00) >> 8) * transparency * 0.5f) + g1;
b2 = (int)((color & 0xff) * transparency * 0.5f) + b1;
screen[x + y * screen_width] = r2 << 16 | g2 << 8 | b2;
lastIndex = currentIndex;
}
//draw solid ring
for(int i = 0; i < 360; i+=1){
x = (int)(tempCentre.screenX + (a * (float)(12-t)/10f) * cos[i]);
y = (int)(tempCentre.screenY + (b * (float)(12-t)/10f)* sin[i]);
if(x < 0 || x >= screen_width || y < 0 || y >= screen_height)
continue;
screenColor = screen[x + y * screen_width];
r1 = (int)(((screenColor & 0xff0000) >> 16) * (1f - transparency));
g1 = (int)(((screenColor & 0xff00) >> 8) * (1f - transparency));
b1 = (int)((screenColor & 0xff) * (1f - transparency));
r2 = (int)(((color & 0xff0000) >> 16) * transparency) + r1;
g2 = (int)(((color & 0xff00) >> 8) * transparency) + g1;
b2 = (int)((color & 0xff) * transparency) + b1;
screen[x + y * screen_width] = r2 << 16 | g2 << 8 | b2;
}
for(int i = 0; i < 360; i+=1){
x = (int)(tempCentre.screenX + (a * (float)(12-t)/10f -1) * cos[i]);
y = (int)(tempCentre.screenY + (b * (float)(12-t)/10f- 1)* sin[i]);
if(x < 0 || x >= screen_width || y < 0 || y >= screen_height)
continue;
screenColor = screen[x + y * screen_width];
r1 = (int)(((screenColor & 0xff0000) >> 16) * (1f - transparency));
g1 = (int)(((screenColor & 0xff00) >> 8) * (1f - transparency));
b1 = (int)((screenColor & 0xff) * (1f - transparency));
r2 = (int)(((color & 0xff0000) >> 16) * transparency) + r1;
g2 = (int)(((color & 0xff00) >> 8) * transparency) + g1;
b2 = (int)((color & 0xff) * transparency) + b1;
screen[x + y * screen_width] = r2 << 16 | g2 << 8 | b2;
}
frameIndex--;
}
}