xxxxxxxxxx
47
function setup() {
createCanvas(300, 300);
}
// If the mouse is pressed, draw blue on top and red below
// function draw() {
// if (mouseIsPressed === true) {
// if (mouseY < height / 2) {
// fill(0, 0, 255);
// rect(0, 0, width, height / 2);
// } else {
// fill(255, 0, 0);
// rect(0, height / 2, width, height);
// }
// }
// }
// if the mouse is pressed in the top half, make the top blue
// if the mouse is pressed in the bottom half, make the bottom red
// function draw() {
// if (mouseIsPressed === true && mouseY < height / 2) {
// fill(0, 0, 255);
// rect(0, 0, width, height / 2);
// }
// if (mouseIsPressed === true && mouseY > height / 2) {
// fill(255, 0, 0);
// rect(0, height / 2, width, height);
// }
// }
// this one is complicated. if the mouse is pressed in the top
// print "we are in the top"
// if the mouse is not pressed OR the mouse is in the bottom
// print the other message
function draw() {
if (mouseIsPressed === true && mouseY < height / 2) {
print("mouse is pressed in top of screen")
}else {
print("either mouse is not pressed, OR mouse is pressed in the bottom")
}
}