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 › add shapes / replace shapes
Page Index Toggle Pages: 1
add shapes / replace shapes (Read 332 times)
add shapes / replace shapes
Jul 7th, 2008, 12:31am
 
Hi there,
this is a basic question i guess and I`m afraid I just didn`t understand how proc works.

void setup(){
 size(300,300, P3D);
}
void draw(){
 int x=int(random(100));
 int y=int(random(100));
 int z=int(random(100));
 fill(1,2,200);
 rect(x, z,y, x+y);
 fill(200,200,10);
 beginShape();
 vertex(x, x,y);
 vertex(z, x,y);
 vertex(z, z,y);
 endShape();
}

This code is just adding one rnd shape to the other.
But in a longer version, the same code structure the shapes get replaced, so that you always see only one shape.

Why is this? How can I change this - so that I have additive shapes?

thanx for help! proc is great...- anyway!
Re: add shapes / replace shapes
Reply #1 - Jul 7th, 2008, 2:35am
 
I'm a bit unsure what you mean by add shapes.  Are you adding new vertices to the shape, or drawing new layers on top of the shape?  The problem in your more complex code sounds like you're drawing a new background on top of the shape, replacing the old one.
Re: add shapes / replace shapes
Reply #2 - Jul 7th, 2008, 9:37am
 
yeah.. -thanx!
it was the background!
defined in setup or in draw - that makes the difference!

Great forum! thx
Page Index Toggle Pages: 1