Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
77 lines (54 loc) · 1.67 KB

File metadata and controls

executable file
·
77 lines (54 loc) · 1.67 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package inheritance;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
public class MovingCurvyShapeApp extends CurvyShapeApp {
int maxSpeed;
MovingCurvyShapeApp(int w, int h, boolean tryFSE, int ms) {
super(w, h, tryFSE);
maxSpeed = ms;
}
public void init(int nVertices) {
int width = getWidth();
int height = getHeight();
Random random = getRandom();
int[] x = new int[nVertices];
int[] y = new int[nVertices];
int[] x1 = new int[nVertices];
int[] y1 = new int[nVertices];
int[] x2 = new int[nVertices];
int[] y2 = new int[nVertices];
int[] vx = new int[nVertices];
int[] vy = new int[nVertices];
for (int i = 0; i < nVertices; i++) {
x[i] = width / 3 + random.nextInt(width / 3);
y[i] = height / 3 + random.nextInt(height / 3);
x1[i] = random.nextInt(width);
y1[i] = random.nextInt(height);
x2[i] = random.nextInt(width);
y2[i] = random.nextInt(height);
vx[i] = 1 + random.nextInt(maxSpeed - 1);
if (random.nextDouble() > 0.5)
vx[i] *= -1;
vy[i] = 1 + random.nextInt(maxSpeed - 1);
if (random.nextDouble() > 0.5)
vy[i] *= -1;
}
setShape(new MovingCurvyShape(x, y, x1, y1, x2, y2, vx, vy, nVertices));
Color color = new Color(random.nextInt(255), random.nextInt(255),
random.nextInt(255));
getShape().setColor(color);
}
public void draw(Graphics g) {
super.draw(g);
MovingCurvyShape movingCurly = (MovingCurvyShape)getShape();
movingCurly.move(0, getWidth(), 0, getHeight());
}
public static void main(String[] args) {
MovingCurvyShapeApp goo = new MovingCurvyShapeApp(500, 500, true, 10);
goo.init(100);
goo.smooth();
goo.frameRate(24);
goo.go();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.