forked from gefercan/processing_exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch_02_archs.txt
61 lines (55 loc) · 1.46 KB
/
sketch_02_archs.txt
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
// grid of arcs exercise by tim rodenbroeker
// general variables
color bg=#010101;
color fg=#ff0101;
//init function
void setup() {
//canvas size
size(900, 900);
}
//render function
void draw() {
//callback function
grid();
}
//grid building function
void grid(){
//set up colors
background(bg,mouseX/2,mouseY/2);
fill(fg,mouseY,mouseX);
noStroke();
//building grid
float tilesX=4;
float tilesY= tilesX;
//size of tiles
float tileW= width/tilesX;
float tileH=height/tilesY;
//nested for loops
for (int x=0; x < tilesX; x++) {
for (int y =0; y< tilesY; y++) {
float posX = tileW * x;
float posY = tileH * y;
//using sine variations as input
float wave=sin(radians(frameCount + x*10 + y* 10));
//mapping the sine into the options
float mappedWave= map(wave, -1, 1, 0, 5);
//linking wave to select arcs
int selector= int(mappedWave);
//options linked to selector variable
pushMatrix();
translate(posX, posY);
if (selector ==0) {
arc(0, 0, tileW*2, tileH*2, radians(0), radians(90));
} else if (selector == 1) {
arc(tileW, 0, tileW*2, tileH*2, radians(90), radians(180));
} else if (selector == 2) {
arc(tileW, tileH, tileW*2, tileH*2, radians(180), radians(270));
} else if (selector == 3) {
arc(0, tileH, tileW*2, tileH*2, radians(270), radians(360));
} else {
rect (0, 0, tileW, tileH);
}
popMatrix();
}
}
}