xxxxxxxxxx
42
let abs; // variable here, which is going to keep tracck of all of our beatstep data.
let angle = 0;
let x, y;
let r = 0;
let tiles = 4; // number of tiles in any row and column
let offset;
function setup() {
createCanvas(400, 400);
offset = width/tiles; // the number of pixels between spirals or tiles
abs = new BeatStep("Arturia BeatStep");
}
function draw() {
background(0);
for (let i = 0; i < tiles; i++) { // vertical and horizontal
for (let j = 0; j < tiles; j++) {
spiral(i,j, abs.dials[0]);// use the spiral function we've defined
}
}
angle += 0.1;
r += 0.2;
if (r > width / 2) {
r = 0;
}
}
//define the spiral function
function spiral(v,h) {
push();
translate(h*offset, v*offset);
x = cos(angle) * r;
y = sin(angle) * r;
circle(x, y, 5);
pop();
}