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 › can an ellipse follow a bezier curve
Page Index Toggle Pages: 1
can an ellipse follow a bezier curve? (Read 407 times)
can an ellipse follow a bezier curve?
Aug 7th, 2006, 8:42am
 
Hi,

I looked at the example, where an ellipse is following a curve made by a Line_STRIP, but is it possible to somehow make an ellipse follow a bezier curve?

I looked at this example, but could not figure out how to modify it ... should I try something completely different, or should I just modify this?

int e1_size = 18;
float e1_x, e1_y = 0;
float e1_speed = 1.0;
int e1_direction = 1;


void setup()
{
 size(200, 200);
 stroke(102);
 ellipseMode(CENTER);
 smooth();
 framerate(30);
}

void draw()
{
 background(0);
 
 stroke(102);
 
 beginShape(LINE_STRIP);
 for(int i=0; i<width; i++) {
  vertex(i, singraph((float)i/width)*height);
 }
 endShape();
 
 
 e1_x += e1_speed * e1_direction;
 if (e1_x > width || e1_x < 0) {
   e1_direction = e1_direction * -1;
 }
 e1_y = singraph((float)e1_x/width)*height;
 noStroke();
 fill(255);
 ellipse(e1_x, e1_y, e1_size, e1_size);
 
}

float singraph(float sa) {
 sa = (sa - 0.5) * 1.0; //scale from -1 to 1
 sa = sin(sa*PI)/2 + 0.5;
 return sa;
}

float quad(float sa) {
 return sa*sa*sa*sa;
}

float hump(float sa) {
 sa = (sa - 0.5) * 2; //scale from -2 to 2
 sa = sa*sa;
 if(sa > 1) { sa = 1; }
 return 1-sa;
}

Re: can an ellipse follow a bezier curve?
Reply #1 - Aug 7th, 2006, 12:57pm
 
Page Index Toggle Pages: 1