let speed=20; let d=50; let x; let y; let c=0; function setup(){ createCanvas(480,480); x=width/2; y=height/2; colorMode(HSB,360,100,100,1); } function draw(){ c+=0.1; if(c>360){ c=0; } noStroke(); fill(c,100,100,0.5); x+=random(-speed,speed); y+=random(-speed,speed); x=constrain(x,0,width); y=constrain(y,0,height); ellipse(x,y,d,d); }
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>