-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhyllotaxis sunflower.html
59 lines (57 loc) · 1.21 KB
/
Phyllotaxis sunflower.html
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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.dom.js"></script>
<style>
*{
margin:0;
padding:0;
}
body{
padding:5px;
padding-top:40px;
background-color:black;
color:white;
}
</style>
</head>
<body>
<script>
let n=0;
let c=5;
let factor=5;
let angle=137.5;
let S=137.5;
let R=137.3;
let P=137.6;
function setup(){
createCanvas(window.innerWidth-10, window.innerWidth-10);
angleMode(DEGREES);
colorMode(HSB);
background(0);
}
function draw(){
translate(width/2, height/2);
let a;
if(n<=440){
a=n*S;
}
else if(n<=565){
a=n*R;
}
else{
a=n*P;
}
let r=c*sqrt(n);
let x=r*cos(a);
let y=r*sin(a);
//fill(255);
fill((n/factor)%255,255,255);
noStroke();
circle(x,y,5,5);
n++;
}
</script>
</body>
</html>