xxxxxxxxxx
59
/**
* Simple painting app created entirely by Chat GPT4 using chat.bing.com on Jan 26, 2024
* All comments also by Chat GPT4.
*
* The prompt:
*
* "Create a simple interactive painting app in p5js that uses the mouse to control the
* paintbrush and left mouse button down to paint."
*
* See the other painting apps here:
*
* - This version (basic app): https://editor.p5js.org/jonfroehlich/sketches/jnliJsIwb
* - Version 2 (added translucency): https://editor.p5js.org/jonfroehlich/sketches/EjBgSYhBE
* - Version 3 (added color): https://editor.p5js.org/jonfroehlich/sketches/Ajylq5-Fe
* - Version 4 (added erase brush): https://editor.p5js.org/jonfroehlich/sketches/4Yxtt4bJV
*
* By Professor Jon E. Froehlich
* https://jonfroehlich.github.io/
* https://makeabilitylab.github.io/p5js/
* http://makeabilitylab.cs.washington.edu
**/
// Here is Chat GPT4's description of the code
// In this code:
//
// * The setup function creates a canvas and sets the background color to white.
// * The draw function checks if the left mouse button is pressed. If it is, it
// draws a black circle at the current mouse position.
// * The keyPressed function clears the canvas when any key is pressed. This allows you to start a
// new drawing without refreshing the page.
//
// You can run this code in the p5.js web editor or in any HTML file where the p5.js library is
// included. To paint, simply click and drag the mouse across the canvas. To clear the canvas,
// press any key. Enjoy painting! 🎨
// setup the canvas
function setup() {
createCanvas(800, 600);
background(255);
}
// draw function
function draw() {
// check if the left mouse button is pressed
if (mouseIsPressed) {
// if so, draw an ellipse at the current mouse position
fill(0);
noStroke();
ellipse(mouseX, mouseY, 20, 20);
}
}
// reset the canvas when any key is pressed
function keyPressed() {
background(255);
}