FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   bezierVertex
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: bezierVertex  (Read 296 times)
benelek

35160983516098 WWW Email
bezierVertex
« on: Jan 10th, 2003, 1:18pm »

the beginShape() / endShape() method of drawing bezierVertex seems to do strange things when more than 4 points are specified.
 
  it looks to me like proce55ing renders the initial bezier curve, but then continues it by drawing a straight line from the last point to the second-last control point, and then starting a new bezier curve from there.
 
  below is the code of a program that clarifies this visually. (click three times to create the first 4 bezier control points, then keep clickin'!)
 
Code:

 
// testing a method for displaying objects linked by bezier lines
// written by benelek, 2003.
 
void setup() {
  size(300,300);
  background(255);
}
 
int[][] objects = {
  {5},
  {10}
};
 
int rY = 0;
 
void loop() {
    // draw all known objects, and link them by lines.
    translate(width/2,height/2,-objects[0].length);
    rotateY(radians(rY));
    translate(-width/2,-height/2,objects[0].length);
     
    beginShape(LINE_STRIP);
    for(int i=0; i<objects[0].length; i++) {
 bezierVertex(objects[0][i],objects[1][i],3*(i-objects[0].length));
 //println(objects[0].length);
    }
    endShape();
}
 
void mousePressed() {
  // create new object
  int x = mouseX;
  int y = mouseY;
  objects[0] = grow(objects[0], x);
  objects[1] = grow(objects[1], y);
}
 
 
void mouseDragged() {
  if(keyPressed && key==' ') {
    if(mouseX-pmouseX>0) {
 rY+=3;
    } else {
 rY-=3;
    }
  }
}
 
void mouseReleased() {
  rY=0;
}
 
int[] grow( int[] theArray, int newNum) {
 
  int[] temp = new int[theArray.length+1];
   
  System.arraycopy(theArray,0,temp,0,theArray.length);
  temp[theArray.length]=newNum;
  theArray=temp;
   
  return theArray;
}
 
 

 
as i said, the problem only occurs for more than 4 control points, so i may be begging the strange result - or this may be a bug.
 
-jacob
 
fry


WWW
Re: bezierVertex
« Reply #1 on: Jan 10th, 2003, 4:34pm »

nope, that looks like a bug.
 
drawing continuous beziers is a bit tricky in principle but this looks like the indexing is off.  
 
thanks for the example, will try fix this shortly.
 
fry


WWW
Re: bezierVertex
« Reply #2 on: Sep 18th, 2003, 4:03am »

this was finally repaired in a recent release.
 
Pages: 1 

« Previous topic | Next topic »