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 & HelpPrograms › why this program crashes
Page Index Toggle Pages: 1
why this program crashes? (Read 655 times)
why this program crashes?
Jul 30th, 2005, 6:05pm
 
hello list,

I am trying to program my first sketch in Processing: a version of "How many lines are necessary to erase a black rectangle?", www.rgbdesigndigital.com.br/atravesdoespelho/howmanylines/. But it crashes. I don't know if I have to make some pause between an interaction and another in the loop, or change the condition of stopping the animation. The fact is that it crashed my computer (last version of Processing, windows xp).

The program is below:

background(255,255,255);
fill(0,0,0);
rect(50,50,500,250);
stroke(255,255,255);
while (!mousePressed) {
   float x1 = random (50,550);
   float x2 = random (50,550);
   float y1 = random (50,300);
   float y2 = random (50,300);
   line (x1,y1,x2,y2);
}


bye, and thanks for your time,
andrei
Re: why this program crashes?
Reply #1 - Jul 30th, 2005, 6:54pm
 
Try this!

Play with the variables to suit.

Code:

void setup() {
size(600,350);
background(255,255,255);
fill(0,0,0);
rect(50,50,500,250);
stroke(255,255,255);

}

void draw() {
if (mousePressed) {
   float x1 = random (0, width);
   float x2 = random (0, width);
   float y1 = random (0, height);
   float y2 = random (0, height);
   line (x1,y1,x2,y2);
   count++;
   }
}

int count;

void mouseReleased() {

  println("no of lines: "+count);

}

Re: why this program crashes?
Reply #2 - Jul 30th, 2005, 6:57pm
 

Oh, by the way the answer is 11778. hehe!
Page Index Toggle Pages: 1