xxxxxxxxxx
69
let x, y, r, g, b, a;
let sz = 50;
let rad = 100;
let angle;
let i = 0;
let a2 = 255
let mx = 1;
let my = 1;
let easing = 0.1;
function setup() {
createCanvas(windowWidth, windowHeight);
//background(0);
frameRate(60);
}
function draw() {
background(0,a2);
//time operator
i++;
//these makes the circle lag behind the mouse
mx = mx + (mouseX - mx) * easing;
my = my + (mouseY - my) * easing;
//random colors
//r = random(0,255);
//g = random(0,255);
//r = 122 + 122 * cos(i);
//a = random(122, 255);
r = 0;
g = 0;
b = random(122, 255);
a = 255;
//this makes the circle oscillate
rad = 100 + 20 * sin(i/20);
//this generate random angles
angle = random() * PI * 2;
//cos and sin generate the circles in the perimeter of a circle of radius = rad
x = mx + cos(angle) * rad;
y = my + sin(angle) * rad;
//change background alpha to 0 to start drawing mode
if (mouseIsPressed == true) {
noStroke();
fill(r, g, b, a);
ellipse(x, y, sz);
a2 = 0;
} else {
noStroke();
fill(255, 255, 255, 0);
ellipse(x, y, sz);
a2 = 255;
}
noFill();
stroke(255);
ellipse(mx,my,rad)
}