We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › The answers right in front of me...
Page Index Toggle Pages: 1
The answers right in front of me... (Read 348 times)
The answers right in front of me...
Mar 20th, 2006, 4:19am
 
 Hi, I have been fiddling with a program very similar to EXAMPLES/DRAWING/PATTERN with minor differences.
 The main being that the draw() is executed while the LEFT mouseButton is held, and my Intention was that the other mouseButton 's would clear the screen.
 The problem is after the screen clears, the program Seems finished, and you can no longer draw. I'm pretty sure the code I have would work if was moved around a bit, but I've tried many variations ( nesting functions within draw(), functions called, function order changed) I'm stuck! The code in it's entirety:

//start
float circleSize;

void setup() {
 size(200, 200);
 background(255);
 stroke(0, 102, 153, 204);
 fill(0, 102, 153, 50);
 noLoop();
}

void draw() {
 delay(10);    //changes the 'feel' of the program
 circleSize = abs(mouseX - pmouseX);  //calculates absolute difference between two mouse positions
 circles(mouseX, mouseY);  //defines mouse position for circles() function
}

void circles(int x, int y) {
 ellipse(x, y, circleSize, circleSize);  //draws circles
}

void clearScreen() {
 noStroke();
 fill(255);
 rect(-10, -10, 210, 210);
 loop();
}

void mousePressed() {
 if (mouseButton == LEFT) {
 loop();
 } else {        //  any mouseButton except LEFT
   clearScreen();//    will call clearScreen
 }
}

void mouseReleased() {
 noLoop();
}
//end
Re: The answers right in front of me...
Reply #1 - Mar 20th, 2006, 5:23am
 
You don't want to execute loop();... I think..
Page Index Toggle Pages: 1