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 › Greenberg Code
Page Index Toggle Pages: 1
Greenberg Code (Read 394 times)
Greenberg Code
Mar 3rd, 2008, 10:04am
 
I am trying to run the Chapter 2 example "algorithmic tree sketch" from the Ira Greenberg book. I get a blank screen.
I think I can show the problem with a small program.
The import statement seems to cause the problem, but if you reduce the size to 400 x 300 it seems to work.
The import statement is not needed in this example program, but the Greenberg program uses it.

Quote:


 // If the import statement is added to the program,
 // even though it is not used,
 // you will not see the line().

// import java.awt.geom.Point2D;

void setup() {
 size(900, 600);
 background(255);
 strokeWeight(6);
 stroke(0);
 trunk();
}

void trunk() {
 line(0, 0, width, height);
}



Maybe someone can double check this.
I am using: WinXP, Java 1.4, and Processing -0135 beta
Re: Greenberg Code
Reply #1 - Mar 3rd, 2008, 7:29pm
 
Try:

Code:

// If the import statement is added to the program,
// even though it is not used,1
// you will not see the line().

// import java.awt.geom.Point2D;

void setup() {
size(900, 600,P3D);
background(255);
strokeWeight(6);
stroke(0);

}

void draw(){
trunk();

}

void trunk() {
line(0, 0, width, height);
}
Re: Greenberg Code
Reply #2 - Mar 3rd, 2008, 8:21pm
 
Thanks,

Adding the draw() and putting the trunk() in the draw works for the example program.
With the Greenberg program "algorithmic tree sketch" you have to also add noLoop() to the setup() so that trunk() is only called once.
I think that Ira added that program in the book as something we could play around with. It is a good example of recursive programming that always gives my head a spin.
Page Index Toggle Pages: 1