-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
55 lines (45 loc) · 940 Bytes
/
sketch.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
53
54
55
var canvas;
let numbers = [];
let count = 1;
let sequence = [];
let index = 0;
let arcs = [];
let biggest = 0;
let osc;
function setup(){
canvas = createCanvas(windowWidth,windowHeight);
numbers[index] = true;
sequence.push(index);
for(let i = 0; i < 11; i++){
step();
}
osc = new p5.Oscillator();
osc.setType('sine');
osc.freq(240);
osc.amp(2);
osc.start();
}
function step(){
let next = index-count;
if(next < 0 || numbers[next]){
next = index+count;
}
let a = new Arc(index,next,count%2);
arcs.push(a);
if(index > biggest){
biggest = index;
}
numbers[next] = true;
sequence.push(next);
index = next;
count++;
}
function draw(){
step();
translate(0,height/2)
scale(width/biggest);
background(0);
for(let a of arcs){
a.show();
}
}