xxxxxxxxxx
let abs; // variable here, which is going to keep tracck of all of our beatstep data.
let angles = [];// an array for all our angles!
let radii = []; // an array for all our radii values
let tiles = 2; // number of tiles in any row and1 column
let sizes = []; // sizes
let x = [];
let y = [];
let offset;
function setup() {
createCanvas(800, 800);
offset = width/tiles; // the number of pixels between spirals or tiles
abs = new BeatStep("Arturia BeatStep");
// initialize our arrahys
for(let i =0; i< tiles*tiles;i++){
angles[i] = 0;
radii[i] = 0;
sizes[i] = 20;
x[i] = random(width);
y[i] = random(height);
}
}
function draw() {
let bg = map(abs.dials[4],0,127,0,30);
background(0,bg);
let index = 0; // index !
for (let i = 0; i < tiles; i++) { // vertical and horizontal
for (let j = 0; j < tiles; j++) {
spiral(i,j, index);// use the spiral function we've defined
index++;
}
}
}
//define the spiral function
function spiral(v,h,i) {
push();
translate(x[i],y[i]);
let ex = cos(angles[i]) * radii[i];
let why = sin(angles[i]) * radii[i];
circle(ex, why, sizes[i]);
pop();
let spd = map(abs.dials[i],0,127,0,10); // 0 -127
angles[i] += spd;
radii[i] += spd;
if (radii[i] > width / 2) {
radii[i] = 0;
x[i] = random(width);
y[i] = random(height);
}
sizes[i]+=random(-2,2);
}