We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I recently created a simple drawing program with my students which allows them to draw, erase and clear the screen, but can't seem to figure out why, after they've used their RIGHT mouse-click to erase, they can no longer use LEFT click to draw.
Here is the code:
void setup() { size(400, 400); background(255); }
void draw() {
//if mouse is LEFT-clicked, draw! if (mouseButton == LEFT) { line(pmouseX, pmouseY, mouseX, mouseY); }
//If mouse is RIGHT-Clicked, erase! if (mouseButton == RIGHT) { fill(255); noStroke(); ellipse(mouseX, mouseY, 10, 10); }
// If any key is pressed, clear the screen. if (keyPressed) { background(255); } }
Any help would be greatly appreciated!
Thank you.
Answers
Nevermind! Problem solved – noStroke() from second "if" statement" was cancelling the non-explicit stroke() from first "if" statement.
Very glad your problem was solved, @dangerdes!
In the future, please format code in your forum posts (Leave a blank line above/below. Highlight your code. Press Ctrl+o. This will indent it four spaces, and display it with code formatting). This makes it easier for forum members to read, and to cut-paste for testing.
Thank you @jeremydouglass! When I copied and pasted it into my question, my code looked spiffy, but once it posted, not so much. I'll be sure to follow your advice in the future!
Thanks @dangerdes. And if you forget on a new thread, remember that you can still use the "gear" icon in the upper-right to edit your post and fix it after.