xxxxxxxxxx
27
let b0, b1;
function setup() {
createCanvas(windowWidth, windowHeight);
b0 = new Button(width / 2, height / 2, 200, 50, {
on: [255, 0, 0],
text: "hello",
corners: 20,
});
b1 = new Button(width / 2, height / 2 - 100, 200, 50);
}
function draw() {
background(28);
textSize(32);
let s0 = b0.update(mouseX, mouseY, mouseIsPressed);
let s1 = b1.update(mouseX, mouseY, mouseIsPressed);
if (s0 == Button.DBL_CLICK) console.log("double clicked button 0");
if (s1 == Button.ON) console.log("pressed button 1");
if (s1 == Button.LONG_PRESS) console.log("long pressed button 1");
b0.draw();
b1.draw();
}