forked from palexlee/Projet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
week01.pde
54 lines (45 loc) · 950 Bytes
/
week01.pde
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
void settings() {
size(400, 800, P2D);
}
void setup() {
noLoop();
background(255, 77, 205);
}
void draw() {
plant(15, 0.4, 0.8);
}
void leaf() {
beginShape();
vertex(100.0, -70.0);
bezierVertex(90.0, -60.0, 40.0, -100.0, 0.0, 0.0);
bezierVertex(0.0, 0.0, 100.0, 40.0, 100.0, -70.0);
endShape();
}
void plant(int numLeaves, float minLeafScale, float maxLeafScale) {
line(width/2, 0, width/2, height);
int gap = height/numLeaves;
float angle = 0;
for (int i = 0; i < numLeaves; i++) {
int x = width/2;
int y = gap*i + (int)random(gap);
float scale = random(minLeafScale, maxLeafScale);
pushMatrix();
rotate(angle);
translate(x,y);
scale(scale);
leaf();
popMatrix();
angle += PI/8;
}
}
/*boolean isMoving = true;
void mousePressed() {
if (isMoving) {
noLoop();
isMoving = false;
}
else {
loop();
isMoving = true;
}
}*/