カラーパレットを作る方法
配列を使うことによって事前に用意した色の中から選択することができる。
//配列に色を格納 const colorPallet = ['#38b48b','#9d5b8b','#ffea00']; function setup(){ createCanvas(400,400); background(240); //色を取得 let colorPick = Math.round(random(0,2)); fill(colorPallet[colorPick]); //四角を描画 noStroke(); rect(100,100,200,200); }