xxxxxxxxxx
// Katrien van Riet - 5 November 2020 - version 4
var numberOfDots = 96;
var mult = 0;
var radius = 150;
var x = [];
var y = [];
var interval = 400;
var prevTime;
var startupCounter = 0;
var isStopped = false;
var isPressed = false;
function setup() {
createCanvas(400, 400);
textSize(32);
fill(0);
textAlign(RIGHT);
prevTime = millis();
}
function draw() {
var currentTime = millis();
var reducedPrevTime = prevTime % interval;
var reducedCurrentTime = currentTime % interval;
background(255);
translate(width/2, height/2);
drawString();
text(mult, width/2-10, height/2-10);
if (startupCounter < 20){
reducedPrevTime = reducedCurrentTime;
startupCounter++;
}
if (reducedPrevTime - reducedCurrentTime > interval/2){
if (!isStopped){
mult++;
}
}
if (mult > numberOfDots){
mult = 1;
}
prevTime = currentTime;
}
function drawString() {
var theta = TWO_PI/numberOfDots;
for (var i = 0; i < numberOfDots; i++) {
x[i] = radius*cos(theta*i);
y[i] = radius*sin(theta*i);
ellipse(x[i], y[i], 3);
line(x[i], y[i], x[(mult*i)%x.length], y[(mult*i)%y.length]);
}
}
function mousePressed(){
if (isPressed){
isStopped = true;
isPressed = false;
}
else {
isStopped = false;
isPressed = true;
}
}