xxxxxxxxxx
/*
KJ Ha
Visulize or sonify an alternate number base or patterns among divisors.
*/
let fr;
let a;
let r = 25;
let op = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
textAlign(CENTER);
}
function draw() {
frameRate(fr);
background(0);
var number = 0;
a = random(20000);
fr = map(mouseX, 0, width, 1, 15);
for (var h = 0; h < height; h += r) {
for (var w = 0; w < width; w += r) {
number++;
for (var i = 2; i < number; i++) {
if (number % i === 0) {
fill(0);
ellipse(r / 2 + w, r / 2 + h, r, r);
fill(255)
text(char(a + i), r / 2 + w, r / 2 + h)
fill(0, op);
ellipse(r / 2 + w, r / 2 + h, r, r);
fill(255, op);
text(i, r / 2 + w, r / 2 + h)
}
}
}
}
}
function keyPressed() {
if (keyCode === ENTER) {
if (op === 0) {
op = 255
} else {
op = 0
}
}
}