xxxxxxxxxx
72
let coordx = [];
let coordy = [];
let trans = [];
let x = 0;
let y = 0;
let x1 = 0;
let y1 = 0;
let angle = 0;
let angle1 = 0;
let dia = 8;
let count = 0;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(32, 43, 56);
//frameRate(5);
noStroke();
if (count % 255 == 0) {
x = 0;
y = 0;
x1 = 0;
y1 = 0;
}
translate(width / 2, height / 2);
circs();
next();
fade();
count++;
}
function next() {
let r = random(1);
if (r > 0.80) {
angle = angle + PI / 3 % TWO_PI;
angle1 = angle1 - PI / 3 % TWO_PI;
}
x = x + cos(angle) * dia;
y = y + sin(angle) * dia;
coordx.push(x);
coordy.push(y);
x1 = x1 + cos(angle1) * dia;
y1 = y1 + sin(angle1) * dia;
coordx.push(x1);
coordy.push(y1);
trans.push(255);
if (trans.length > 255) {
coordx.splice(0, 2);
coordy.splice(0, 2);
trans.splice(0, 1);
}
}
function circs() {
for (let j = 0; j < 6; j++) {
for (let i = 0; i < coordx.length; i++) {
fill(140, 205, 255, trans[int(i / 2)]);
circle(coordx[i], coordy[i], dia - 2);
}
rotate(PI / 3);
}
}
function fade() {
for (let i = 0; i < trans.length; i++) {
let temp = trans[i];
temp -= 2;
trans[i] = temp;
}
}