function
setup() {
canv = createCanvas(550, 300);
textSize(18);
text(
"Click on the buttons to toggle the "
+
"given class of the canvas"
, 20, 30);
setBtn = createButton(
"Toggle Color"
);
setBtn.position(30, 60);
setBtn.mouseClicked(toggleColor);
setBtn = createButton(
"Toggle Border"
);
setBtn.position(160, 60);
setBtn.mouseClicked(toggleBorder);
canv.addClass(
"red"
);
canv.addClass(
"border"
);
}
function
toggleColor() {
clear();
canv.toggleClass(
"red"
);
text(
"The color class has been toggled"
, 30, 120);
text(
"Click on the buttons to toggle the "
+
"given class of the canvas"
, 20, 30);
}
function
toggleBorder() {
clear();
canv.toggleClass(
"border"
);
text(
"The border class has been toggled"
, 30, 120);
text(
"Click on the buttons to toggle the "
+
"given class of the canvas"
, 20, 30);
}