|
Author |
Topic: draw and loop (Read 258 times) |
|
Umberto Guest
|
draw and loop
« on: Oct 3rd, 2003, 3:55am » |
|
Well, I'm just getting started with processing and I really don't understand how I can do this: draw something permanent using the loop() function. I can make circles follow the mouse coordinates, but I canīt draw the circles, they disappear with every new mouse movement. I tried the draw() function, but can I use draw and loop simultaneosuly? I have tried to copy examples from reference (like the circles that change size with mouse speed) but when I paste the code and run it the circles are not permanent like they are in the example. Thanks, I'm really a beginner.
|
|
|
|
Bijeoma
|
Re: draw and loop
« Reply #1 on: Oct 3rd, 2003, 5:03am » |
|
hope this helps. it is just an ellipse that follows the cursor. void setup() { size(300,300); //centers origin for an ellipse //default value for origin is the top left corner ellipseMode(CENTER_RADIUS); } void loop() { background(0); ellipse( mouseX, mouseY, 75, 75 ); } bryan
|
|
|
|
JohnG
|
Re: draw and loop
« Reply #2 on: Oct 3rd, 2003, 10:35am » |
|
I think you need to lose and background(); call in your loop function, that causes the screen to be cleared every frame. so if your loop function just contains a command to draw the circle, it shuld stay beheind when you move the mouse , and new ones drawn over the top. E.g. http://www.hardcorepawn.com/circle the above link also includes a link to the source.
|
|
|
|
Bijeoma
|
Re: draw and loop
« Reply #3 on: Oct 3rd, 2003, 6:32pm » |
|
sorry, misunderstood the question. bryan
|
|
|
|
Umberto Roncoroni Guest
|
Re: draw and loop
« Reply #4 on: Oct 9th, 2003, 5:42am » |
|
Thanks. I have solved the problem this way: I draw the shape (circle or whatever) into a pixel array and then in the loop i display the array. When I move the mouse and a new circle is drawn, I copy this new circle into the array and display it again in the loop and so on. It works.
|
|
|
|
|