p5(sketch => {
const randomColour = object.colour;
sketch.setup = function() {
sketch.createCanvas(width, height);
sketch.colorMode(sketch.HSB, 360, 100, 100, 100);
sketch.noFill();
sketch.rect(0, 0, width, height);
};
sketch.draw = function() {
const t = new Date().getSeconds() / 2;
if (t%4 == 0) {
sketch.background(255, 5);
const circleResolution = randomIntFromInterval(2, 60);
const radius = randomIntFromInterval(0.5, width / 2);
const angle = sketch.TWO_PI / circleResolution;
sketch.strokeWeight(randomIntFromInterval(0.5, 2));
const randomThisColour = randomIntFromInterval(randomColour - 20, randomColour + 20);
const randomSaturation = randomIntFromInterval(80, 100);
const randomBrightness = randomIntFromInterval(60, 80);
const colour = sketch.color(randomThisColour, randomSaturation, randomBrightness);
sketch.stroke(colour);
sketch.translate(width / 2, height / 2);
sketch.beginShape();
for (var i = 0; i <= circleResolution; i++) {
const x = sketch.cos(180 - angle * i) * radius;
const y = sketch.sin(180 - angle * i) * radius;
sketch.vertex(x, y);
}
sketch.endShape(sketch.CLOSE);
}
}
})