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 › Getting a clean render with TRIANGLE_STRIP
Page Index Toggle Pages: 1
Getting a clean render with TRIANGLE_STRIP (Read 480 times)
Getting a clean render with TRIANGLE_STRIP
Dec 16th, 2008, 12:31am
 
I notice that when I use TRIANGLE_STRIP and try and get rid of the stroke by setting the weight to 0 or by setting the colour to be equal to the fill colour I can still see small sections where the shapes are not quite joining up and the background is visible - like cracks I suppose.

It does not happen when I don't use smooth.

this code demonstrates the problem:

size(500, 500);
background(204);
smooth();
//noStroke();
fill(0);
stroke(0);

int x = width/2;
int y = height/2;
int outerRad = 248;
int innerRad = 50;
float px = 0, py = 0, angle = 0;
float pts = 36;
float rot = 360.0/pts;

beginShape(TRIANGLE_STRIP);
for (int i = 0; i < pts; i++) {
 px = x + cos(radians(angle))*outerRad;
 py = y + sin(radians(angle))*outerRad;
 angle += rot;
 vertex(px, py);
 px = x + cos(radians(angle))*innerRad;
 py = y + sin(radians(angle))*innerRad;
 vertex(px, py);
 angle += rot;
}
endShape();

I'm very new to Processing so I may well be doing something wrong. Is there a way to use smooth and to get no cracks?

Processing 1.01 on Mac

Thanks and best,

John.


Re: Getting a clean render with TRIANGLE_STRIP
Reply #1 - Dec 16th, 2008, 8:51am
 
i don't see exactly what you're referring too. why not take a screen shot and indicate the problem? it may very well look different on your system.
Re: Getting a clean render with TRIANGLE_STRIP
Reply #2 - Dec 16th, 2008, 6:19pm
 
Good idea,

There is a screen shot here - the problem is subtle but occurs inside the red oval.

http://tinyurl.com/55n5l4

thanks,

John
Re: Getting a clean render with TRIANGLE_STRIP
Reply #3 - Dec 16th, 2008, 6:56pm
 
here's a simple solution: change for (int i = 0; i < pts; i++) to for (int i = 0; i <= pts; i++).
Re: Getting a clean render with TRIANGLE_STRIP
Reply #4 - Dec 16th, 2008, 7:06pm
 
Change for "i < pts;" in your for loop to "i <= pts;"
Re: Getting a clean render with TRIANGLE_STRIP
Reply #5 - Dec 16th, 2008, 10:10pm
 
Ahh, thank you both. That was simple!

So much to learn....

best,

John.
Page Index Toggle Pages: 1