xxxxxxxxxx
20
let gray = 0; // 背景の色
let button; // ボタンを管理する変数
function setup() {
createCanvas(400, 400);
button = createButton(gray); // ボタンの作成
button.position(10, height + 10); // ボタンの位置を指定
button.mousePressed(clicked); // クリックされたらclickedを実行
background(gray);
}
function draw() {
// background(220);
}
function clicked() {
gray += 2; // grayを2増やす
button.html(gray); // ボタンのラベルを変更
background(gray);
}