-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhyllotaxisSunflower.pde
42 lines (31 loc) · 1.11 KB
/
PhyllotaxisSunflower.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
void setup(){
size(1000,1000,P2D);
background(0);
stroke(255);
noFill();
}
//The radius from zero (The distance from the center)
float radius = 0;
//The rotation in DEGREES
float rotation = 137.5;
//The diameter of the circles
float diameter = 5;
void draw(){
//Exit condition. We stop the pattern when we reach the edge of the window.
if(radius < height){
//We move (translate) the zero of the X and Y axis to the middle of the screen
//So the grid has it's zero in the Center (x=0 and y=0 is in the CENTER now)
translate(width/2, height/2);
//Now we rotate the grid around oru new center
//IMPORTANT!! The rotate() functions expects RADIANS for a value - NOT DEFREES.
//So we convert our previously defined rotation values to radians on the fly! :)
rotate(radians(rotation));
//Now, we draw the ellipse
ellipse(0,radius,diameter,diameter);
//Here, things get set up for the next turn.
//...the radius gets bigger...
radius += 0.5;
//...and we add more rotation...
rotation += 137.5;
}
}