xxxxxxxxxx
38
// Jon E. Froehlich
// https://jonfroehlich.github.io/
let diameter = 30;
function setup() {
createCanvas(600, 400);
}
function draw() {
// background(220);
if(mouseIsPressed){
// if the mouse is pressed, change paintbrush to blue
fill(66, 194, 245, 128);
}else{
// if mouse not pressed, change paintbrush to purple
fill(200, 0, 200, 128);
}
noStroke(); // turn off outline
// make diameter of paintbrush proportional to mouse speed
// that is, the mouse brush is the distance between the
// last mouse location and the current mouse location
diameter = dist(mouseX, mouseY, pmouseX, pmouseY);
// draw the circle (the "paintbrush") at the current mouse location
circle(mouseX, mouseY, diameter);
}
function keyPressed(){
print(key);
if(keyCode == DELETE){
background(0);
}else if(key == 'a'){
diameter = diameter + 5;
}
}