forked from skooter500/OOP-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloProcessing.java
More file actions
67 lines (53 loc) · 1.01 KB
/
HelloProcessing.java
File metadata and controls
67 lines (53 loc) · 1.01 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
package ie.tudublin;
import processing.core.PApplet;
public class HelloProcessing extends PApplet
{
public void settings()
{
size(500, 500);
}
public void setup() {
colorMode(HSB);
background(0);
x1 = random(0, width);
x2 = random(0, width);
y1 = random(0, height);
y2 = random(0, height);
float range = 5;
x1dir = random(-range, range);
x2dir = random(-range, range);
y1dir = random(-range, range);
y2dir = random(-range, range);
smooth();
}
float x1, y1, x2, y2;
float x1dir, x2dir, y1dir, y2dir;
float c = 0;
public void draw()
{
strokeWeight(2);
stroke(c, 255, 255);
c = (c + 1f) % 255;
line(x1, y1, x2, y2);
x1 += x1dir;
x2 += x2dir;
y1 += y1dir;
y2 += y2dir;
if (x1 < 0 || x1 > width)
{
x1dir = - x1dir;
}
if (y1 < 0 || y1 > height)
{
y1dir = - y1dir;
}
if (x2 < 0 || x2 > width)
{
x2dir = - x2dir;
}
if (y2 < 0 || y2 > height)
{
y2dir = - y2dir;
}
}
}