xxxxxxxxxx
63
let x, y, xspeed, yspeed
let cols = createColors("https://coolors.co/ffadad-ffd6a5-fdffb6-caffbf-9bf6ff-a0c4ff-bdb2ff-ffc6ff")
function setup() {
createCanvas(windowWidth, windowHeight)
x = width / 2 + 50
y = height / 2 - 100
xspeed = width * random(0.05, 0.15)
yspeed = height * random(0.05, 0.15)
background('#ffe0e0')
}
function createColors(_url)
{
let slash_index = _url.lastIndexOf('/');
let pallate_str = _url.slice(slash_index + 1);
let arr = pallate_str.split('-');
for (let i = 0; i < arr.length; i++) {
arr[i] = '#' + arr[i];
}
return arr;
}
let count = 0
let i, rad
function drawEllipse() {
count++
i = count % 8
noStroke()
fill(cols[i])
ellipse(x, y, 50, 50)
}
function draw() {
x = x + xspeed
y = y + yspeed
if ((x > width) || (x < 0)) {
xspeed *= -1
x = width--
}
if ((y > height) || (y < 0)) {
yspeed *= -1
y = height--
}
drawEllipse()
}
function mousePressed() {
clear()
background('#ffe0e0')
}
function keyPressed() {
clear()
background('#ffe0e0')
}