Loading...
Logo
Processing Forum
Hi,

I have a problem when trying to build a shape with curveVertex. All curve vertex are drawn round (as they are supposed to be) but the the vertex that closes the shape (first point after beginShape, last point before endShape) is drawn sharp.

Here's an example:
Copy code
  1. void setup() {
  2.   size(400, 400);
  3. }

  4. void draw() {

  5.   background(255);
  6.   fill(0);
  7.   
  8.   PVector p_a = PVector.fromAngle(PI/6.0);
  9.   p_a.mult(100);
  10.   PVector p_b = PVector.fromAngle(2*PI/3.0 + PI/6.0);
  11.   p_b.mult(100);
  12.   PVector p_c = PVector.fromAngle(2*PI/3.0*2.0 + PI/6.0);
  13.   p_c.mult(100);

  14.   // Center points between axes
  15.   PVector cp_a = PVector.lerp(p_a, p_c, 0.5);
  16.   PVector cp_b = PVector.lerp(p_b, p_a, 0.5);
  17.   PVector cp_c = PVector.lerp(p_c, p_b, 0.5);
  18.   
  19.   cp_a.mult(0.7);
  20.   cp_b.mult(0.7);
  21.   cp_c.mult(0.7);
  22.   
  23.   //calculateSecondaryPoints(cp_a, cp_b, cp_c);

  24.   pushMatrix();
  25.   translate(width/2, height/2);
  26.   rotate(PI/2.0-PI/5.0);
  27.   
  28.   fill(0);
  29.   noFill();
  30.   strokeWeight(2);
  31.   
  32.   int z = 0;
  33.   beginShape();
  34.   
  35.   curveVertex(p_a.x, p_a.y);
  36.   curveVertex(p_a.x, p_a.y);
  37.   
  38.   curveVertex(cp_b.x, cp_b.y);
  39.   curveVertex(p_b.x, p_b.y);
  40.   curveVertex(cp_c.x, cp_c.y);
  41.   curveVertex(p_c.x, p_c.y);
  42.   curveVertex(cp_a.x, cp_a.y);
  43.   
  44.   curveVertex(p_a.x, p_a.y);
  45.   curveVertex(p_a.x, p_a.y);
  46.   endShape();

  47.   popMatrix();
  48. }

In my code I generate the shape with random vertex amplitude. I've seen this thread, but doesn't really work for me.

Thanks for your help!

Replies(1)

I could fix the problem just removing the "reference points" (duplicated first and end vertex, p_a), and closing the shape with the 2nd and 3rd vertex:

Copy code
  1. beginShape();

  2. curveVertex(p_a.x, p_a.y);

  3. curveVertex(cp_b.x, cp_b.y);
  4. curveVertex(p_b.x, p_b.y);
  5. curveVertex(cp_c.x, cp_c.y);
  6. curveVertex(p_c.x, p_c.y);
  7. curveVertex(cp_a.x, cp_a.y);

  8. // 1st vertex
  9. curveVertex(p_a.x, p_a.y);

  10. // 2nd and 3rd vertex
  11. curveVertex(cp_b.x, cp_b.y);
  12. curveVertex(p_b.x, p_b.y);

  13. endShape();