We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm trying to make a finger cursor to draw in an environment. I have the environment drawn, but the cursor is giving me trouble. Whenever I move it, the cursor leaves its shape behind in the previously occupied spot. How would I make the cursor leave its mark and then move it to the next position?
Answers
@chrisu --
Please share a short sketch demonstrating your problem.
It sounds like you are using an
image()
and need to callbackground()
at the beginning of yourdraw()
. The alternative is to usecursor()
.void setup() //set up the drawing environment { size(700, 700);
fill(141); rect(0, 0, 700, 40);
fill(141); rect(25, 340, 650, 20); rect(25, 680, 650, 20);
fill(255, 248, 56); rect(0, 40, 25, 640); rect(675, 40, 25, 640); //this ends the school bus drawing environment
}
void draw() //draw with a finger { translate(mouseX,mouseY); // draw the finger fill(252,207,161); rect(mouseX, mouseY , 25, 125); }
This is the processing code. I will attach a file when I find the attach button.
Thank you so much
Sorry it's so rough
https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Dude, again, thank you so much for all the help
The general idea is to make a drawing environment that simulates drawing with your finger through the dew on school bus windows. Just in case you were wondering.
What you'll want to use is the
background(0)
command in the draw loop at the very top. Currently in your program, what happens is the program just keeps stacking rectangles where your mouse was, and doesn't delete them once the mouse is not there (think of it as just painting rectangles on a canvas : When you move your paintbrush, the previous paint is still going to be there until you paint over it) Thebackground()
function, in a sense, paints over the whole screen in a solid black color, so that the previous rectangle will be painted over so the new one can be the only rectangle on the screen. Now, if I just typed this in the draw method, the nice background you made wouldn't be seen, as the moment after it was created, the black background would completely cover it. So instead, I packaged all of your background shapes into one method that I can execute just by typing the method's (or package's) name :drawStuff()
. After drawing a black background, the program will then draw all the little background shapes that are supposed to look like a window. Then, the program will draw the rectangle where your mouse currently is. Then, the program will paint over everything in black, redraw the background, and then make a rectangle where your mouse is ... rinse and repeat!Hope this helps!
Awesome. I'll get back to you in the morning, man!
Oh, so the "void drawStuff" locks that down so that the changing cursor will show up?