SOURCE

console 命令行工具 X clear

                    
>
console
let x=50;
let d=50;
let y=50
let a=20
let b=30
function setup(){
    createCanvas(500,500);
    noStroke(0);
    colorMode(HSB,182,120,120);
}
function draw(){
    //background(120);
    x+=a;
    fill(random(360),123,159);
    if((x>550)||(x<0)){;a=-a
       ;
    }  
    y+=b;
    //fill(random(255));
    if((y>550)||(y<0)){b=-b
       ;
    }
    rect(x,y,d,d);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>