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 › Newbie: out of the line
Page Index Toggle Pages: 1
Newbie: out of the line (Read 354 times)
Newbie: out of the line
Dec 2nd, 2008, 1:36pm
 
hi everyone...

I#m also into learning processing now. and i always try to get all my problems soved by myself, but on thisone i really got stuck....

i got a simple code of movinge shapes in an array.
the outer points are changing direction as they get to a certain width or height. but some of the points in the array change differently which makes them move away from the other points...
is there a mistake in the "if-loop"?

the second thing i tried to figure out is the opengl antialiasing issue. i cant get the shape to be smooth in opengl mode. the regular mode works well, but cannot handle so many lines.

maybe someone can give me a hint where to look into to get rid of this problems. thanks a lot...

and heres the code:


import processing.opengl.*;

int bezierCount = 500;
float[] pt1x = new float[bezierCount];
float[] pt1y = new float[bezierCount];
float[] pt2x = new float[bezierCount];
float[] pt2y = new float[bezierCount];
float[] pt3x = new float[bezierCount];
float[] pt3y = new float[bezierCount];
float[] pt4x = new float[bezierCount];
float[] pt4y = new float[bezierCount];
float[] xspeed = new float [bezierCount];
float[] yspeed = new float [bezierCount];
float[] xspeed4 = new float [bezierCount];
float[] yspeed4 = new float [bezierCount];
float[] strokeAlpha = new float [bezierCount];

void setup(){
 size (800,600,OPENGL);
 background (255);
 noFill();
 hint (ENABLE_OPENGL_4X_SMOOTH);
 for (int i=0; i<bezierCount; i++){
   pt1x[i] = 10+i;
   pt1y[i] = 10+i;
   pt2x[i] = width/2-10;
   pt2y[i] = height/2-10;
   pt3x[i] = width/2+10;
   pt3y[i] = height/2+10;
   pt4x[i] = 10+i;
   pt4y[i] = 10+i;
   xspeed[i] = 8;
   yspeed[i] = 3;
   xspeed4[i] = 3;
   yspeed4[i] =7;
   strokeAlpha[i] = 255;
 }
}

void draw (){
 background(255);
 for (int i=0; i<bezierCount; i++){
   strokeWeight (1);
   stroke (91+(i*(int)164/bezierCount),0+(i*(int)193/bezierCount),84-(i*(int)84/bezierCoun
t),strokeAlpha[i]);
   beginShape();
   vertex (pt1x[i], pt1y[i]);
   bezierVertex (pt2x[i], pt2y[i], pt3x[i], pt3y[i], pt4x[i], pt4y[i]);
   endShape();
   pt1x[i]+=xspeed[i];
   pt1y[i]+=yspeed[i];
   pt4x[i]+=xspeed4[i];
   pt4y[i]+=yspeed4[i];

 if (pt1x[i] >= width*2 || pt1x[i] <= -width){
   xspeed[i]*= -1;
 }

 if (pt1y[i] >= height*2|| pt1y[i] <= -height){
   yspeed[i]*=-1;
 }
 
 if (pt4x[i] >= width*2|| pt4x[i] <= -width){
   xspeed4[i]*=-1;
 }

 if (pt4y[i] >= height*2 || pt4y[i] <= -height){
   yspeed4[i]*=-1;
 }
}
}
Re: Newbie: out of the line
Reply #1 - Dec 2nd, 2008, 7:41pm
 
looks like the "anti-aliasing"-problem wasn't one from openGL.
found the bezierDetail() function... and its solved!!
Page Index Toggle Pages: 1