xxxxxxxxxx
31
// Demonstrates how to use the CPX's mouse input as a paintbrush.
// - CPX Paint 3 adds ability to "pick up/down" paintbrush uses mouse presses
// - CPX Paint 2 adds in clear by receiving an "UP" arrow
//
// This program is intended to be used with the CPX + MakeCode program:
// https://makecode.com/_eKmJcvX13aKf
//
// By Jon E. Froehlich
// https://jonfroehlich.github.io/
let brushSize = 50;
function setup() {
createCanvas(400, 400);
background(220);
}
function draw() {
// background(220);
if(mouseIsPressed){
// If we're here, the moues is pressed so let's draw a circle
circle(mouseX, mouseY, brushSize);
}
}
function keyPressed() {
if(keyCode == DELETE){
print("DELETE key received, deleting canvas...")
background(220); // simply redraws the background on top of our painting
}
}