-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfibo.js
52 lines (39 loc) · 996 Bytes
/
fibo.js
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
// source: https://github.com/dherault/fibonacci_spiral
const fcanvas = document.getElementById('layer1')
var coords = [];
fcanvas.width = 800;
fcanvas.height = 600;
const { width, height } = fcanvas
const _ = fcanvas.getContext('2d')
function drawSquareAndQuarterCircle(size) {
_.beginPath()
_.rect(0, 0, size, size)
// _.arc(0, 0, size, 0, Math.PI / 2)
// _.write("hello")
_.stroke()
}
let size = 1
let previousSize = size
_.lineWidth = 1
_.strokeStyle = 'black'
_.translate(width / 2, height / 2)
// _.rotate(-Math.PI / 2)
for (let i = 0; i < 15; i++) {
drawSquareAndQuarterCircle(size)
coords.push(size);
console.log(coords);
// _.fillText(size, 10, 10);
const tempSize = previousSize
previousSize = size
size += tempSize
// if(i==4)
// _.fillText("middle way", _.width,_.height);
//
//
// if(i==10) {
// console.log(size);
// _.fillText("middle way", _.width,_.height);
// }
_.translate(-tempSize, 0)
_.rotate(-Math.PI / 2)
}