When you use the clear()
function, it will clear the screen for you :)
After clearing the screen, you can easily display the image again.
This is how you can do it:
function preload() {
img1 = loadImage("DSC04051.jpeg");
}
function setup() {
createCanvas(1000, 1000);
// Applying tint to affect the image on initial display
tint(100, 200);
image(img1, 0, 0, 1000, 1000);
}
function draw() {
if (mouseIsPressed) {
circle(mouseX, mouseY, 100); // Drawing a circle at mouse position when pressed
}
}
function keyPressed() {
clear(); // Clearing the screen by calling this function
// Call tint function and display the image to clear drawings on the screen
tint(100, 200);
image(img1, 0, 0, 1000, 1000);
}
I also moved the first instance of tint()
to setup, so that it affects the image right from the start.