forked from skooter500/OOP-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.java
More file actions
53 lines (42 loc) · 944 Bytes
/
Loops.java
File metadata and controls
53 lines (42 loc) · 944 Bytes
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
package ie.tudublin;
import processing.core.PApplet;
public class Loops extends PApplet {
int mode = 0;
public void settings() {
size(1000, 1000);
//fullScreen(SPAN);
}
public void setup() {
colorMode(HSB);
}
public void keyPressed() {
mode = key - '0';
println(mode);
}
float off = 0;
public void draw() {
background(0);
fill(255);
noStroke();
switch (mode) {
case 0:
int numCircles = (int) max(1, mouseX / 50.0f);
float d = width / numCircles;
for (int j = 0; j < numCircles; j++) {
for (int i = 0; i < numCircles; i++) {
float x = (d * 0.5f) + (d * i);
float y = (d * 0.5f) + (d * j);
float c = ((i + j) / ((numCircles - 1) * 2.0f)) * 255.0f;
fill((c + off) % 256, 255, 255);
circle(x, y, d);
}
}
off += (mouseY / 50.0f);
break;
case 1:
break;
default:
break;
}
}
}