xxxxxxxxxx
let pins = Array(50)
let hu
setup = () => {
createCanvas(1112, 834)
colorMode(HSB, 255)
hu = random(255);
strokeWeight(.025)
noFill()
}
refresh = () => {
background(255)
for (let i = 0; i < pins.length; i++) {
pins[i] = {
x: random(width * .15, width * .85),
y: random(height * .15, height * .85)
}
}
}
draw = () => {
frameCount % 900 == 1 && refresh()
for (let {x, y} of pins) {
stroke(hu*5%255, 255, 255);
beginShape()
for (let i = 200; i--;) {
const degree = pins.reduce(
(sum, e) => sum + sin(8 * atan2(e.y - y, e.x - x)), frameCount)
x += cos(degree) * 2
y += sin(degree) * 2
vertex(x, y)
if (pins.some(e => Math.hypot(e.x - x, e.y - y) < 2)) break;
}
endShape()
}
hu+=.1
}
// save jpg
let lapse = 0; // mouse timer
function mousePressed(){
if (millis() - lapse > 400){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
lapse = millis();
}
}