- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDuriusWater.java
More file actions
Latest commit
153 lines (127 loc) · 4.74 KB
/
Copy pathDuriusWater.java
File metadata and controls
153 lines (127 loc) · 4.74 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
importjava.applet.Applet;
importjava.awt.Image;
importjava.awt.MediaTracker;
importjava.awt.Graphics;
importjava.awt.Event;
importjava.awt.event.*;
importjava.net.URL;
importjava.awt.image.*;
/*
Waterpic Applet Class
*/
publicfinalclassDuriusWaterextendsWrAppimplementsRunnable {
privateScreen32screenarea, texture, opentexture;
privateWaterwater;
inttexturewidth, textureheight, timeleft;
privatebooleannoise, mouse, timer, usestexture = false;
publicvoidinit() {
intAppKey = 11128;
super.init();
screenarea = newScreen32(intAppletWidth, intAppletHeight);
screenarea.clear(intBackgroundColor);
dcm = newDirectColorModel(32, 0xff0000, 0xff00, 0xff);
mis = newMemoryImageSource(screenarea.getwidth(), screenarea.getheight(),
dcm, screenarea.getdata(), 0, screenarea.getwidth() );
img = createImage(mis);
showStatus(strLoading);
s = getParameter("image");
if (s != null) {
usestexture = true;
Imageim = getImage( getDocumentBase(), s );
MediaTrackerm = newMediaTracker(this);
m.addImage(im,0);
try { m.waitForAll(); } catch(InterruptedExceptione) {}
if(m.isErrorAny()) { boolImageError = true; strBrokenImageName = s;}
texturewidth = im.getWidth(this);
textureheight = im.getHeight(this);
opentexture = newScreen32(texturewidth,textureheight);
opentexture.load(im);
}
else {
texturewidth = 3;
textureheight = 3;
opentexture = newScreen32(texturewidth,textureheight);
}
water = newWater(intAppletWidth, intAppletHeight);
noise = false;
mouse = true;
timer = false;
s = getParameter("mouse");
if (s != null) {
water.dotsize = Integer.parseInt(s);
if(Integer.parseInt(s) == 0)
mouse = false;
}
s = getParameter("noise");
if (s != null) {
water.ndotsize = Integer.parseInt(s);
if(Integer.parseInt(s) != 0) {
s = getParameter("timer");
if (s != null) {
if (Integer.parseInt(s) >= 1) {
timer = true; timeleft = Integer.parseInt(s);
}
}
noise = true;
}
}
s = getParameter("dim"); if (s != null) water.dim = Integer.parseInt(s);
s = getParameter("strength"); if (s != null) water.dotdepth = Integer.parseInt(s);
s = getParameter("logoheight");
if (s != null) {
water.logoheight = 512+(Integer.parseInt(s));
water.logoheight2 = 512-(Integer.parseInt(s));
}
intc1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
s = getParameter("col1"); if (s != null) c1 = Integer.valueOf(s,16).intValue();
s = getParameter("col2"); if (s != null) c2 = Integer.valueOf(s,16).intValue();
s = getParameter("col3"); if (s != null) c3 = Integer.valueOf(s,16).intValue();
s = getParameter("col4"); if (s != null) c4 = Integer.valueOf(s,16).intValue();
s = getParameter("col5"); if (s != null) c5 = Integer.valueOf(s,16).intValue();
water.createPalette((c1>>16)&0xff, (c1>>8)&0xff, c1&0xff,
(c2>>16)&0xff, (c2>>8)&0xff, c2&0xff,
(c3>>16)&0xff, (c3>>8)&0xff, c3&0xff,
(c4>>16)&0xff, (c4>>8)&0xff, c4&0xff,
(c5>>16)&0xff, (c5>>8)&0xff, c5&0xff);
texture = newScreen32(intAppletWidth, intAppletHeight);
intcurrentpos = (intAppletWidth>>1)-(texturewidth>>1)+( (intAppletHeight>>1)-(textureheight>>1) )* intAppletWidth;
for(inti = 0; i<textureheight; i++) {
for(intj = 0; j<texturewidth; j++) {
texture.data[currentpos] = opentexture.data[j+opentexture.ytab[i]];
currentpos++;
}
currentpos += intAppletWidth-texturewidth;
}
boolInitialized = true;
showStatus("");
}
publicfinalvoidmouseMoved(MouseEvente) {
super.mouseMoved(e);
if(mouse) {
intx = e.getX();
inty = e.getY();
x = x - (water.dotsize / 2);
y = y - (water.dotsize / 2);
if(x>(intAppletWidth-water.dotsize)) x=intAppletWidth-water.dotsize;
if(y>(intAppletHeight-water.dotsize)) y=intAppletHeight-water.dotsize;
if(x<0) x=0;
if(y<0) y=0;
water.setDot(x, y, water.dotdepth, water.dotsize);
}
}
publicfinalvoidrender() {
water.flip();
if(noise) {
if(timer) {
if(timeleft > 0) {
water.setDot((int)((Math.random()*(water.width>>1)+(water.width>>2))-(water.ndotsize>>1)), (int)((Math.random()*(water.height>>1)+(water.height>>2))-(water.ndotsize>>1)), water.dotdepth, water.ndotsize);
timeleft -= lngFPS;
} else { }
} elsewater.setDot((int)((Math.random()*(water.width>>1)+(water.width>>2))-(water.ndotsize>>1)), (int)((Math.random()*(water.height>>1)+(water.height>>2))-(water.ndotsize>>1)), water.dotdepth, water.ndotsize);
}
if (usestexture) { water.calcOverlay(screenarea, texture); } else { water.calcWater(screenarea); }
img.flush();
gfx.drawImage(img, 0, 0, null);
}
}
/* End Water */