xxxxxxxxxx
36
let circleX = 0, circleY=0;
let xInc = 1, yInc = 1
let xDir = 1, yDir = 1
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
noStroke()
fill(map(mouseX, 0, windowWidth, 0,255),map(mouseY, 0, windowHeight,0,255),255,205)
ellipse(circleX,circleY,50)
circleX = circleX+xInc*xDir
circleY = circleY + yInc*yDir
if (circleX>=windowWidth || circleY>=windowHeight){
yDir = -1
xDir = -1
xInc = random(5)
yInc = random(5)
}
if (circleX<=0 || circleY <=0){
yDir = 1
xDir = 1
xInc = random(5)
yInc = random(5)
}
}
function mousePressed(){
background(0)
circleX = 0
circleY = 0
}