xxxxxxxxxx
32
// An extra doodle app by Jon E. Froehlich
// and CSE412 students during office hours
//
// @jonfroehlich
function setup() {
// createCanvas accepts a width, height
createCanvas(600, 400);
background(150); // set the background once and only once
}
function draw() {
// Set the amount of red color based on mouse X position
let redAmt = map(mouseX, 0, width, 0, 255);
// Set the amount of blue color based on mouse Y position
let blueAmt = map(mouseY, 0, height, 0, 255);
// Check if mouse is pressed to draw either filled or stroked paint brush
if(mouseIsPressed){
//fill("blue");
fill(redAmt, 0, blueAmt, 50);
noStroke();
}else{
stroke(redAmt, 0, blueAmt, 50);
noFill();
}
let diameter = dist(mouseX, mouseY, pmouseX, pmouseY);
circle(mouseX, mouseY, diameter);
}