Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Dinamically setting the points of a bezierVertex in a PShape

$
0
0
Hi all,

I'm drawing PShapes that basically are born quite small (this is when I create it) and then I increase their size dinamically, using setVertex(). I'm using Processing 2.0.

All of this is ok, until I want to change a shape that has been made using some bezier vertexs myShape.bezierVertex(...), and not only the typical vertex() method. For instance, drawing a heart:
  1.         myShape = createShape();
  2.         myShape.beginShape();
  3.         myShape.vertex (heartSize/2, heartSize*0.15);
  4.         myShape.bezierVertex(heartSize*0.5, -heartSize*0.05, heartSize*0.9, heartSize*0.05, heartSize*0.5, heartSize*0.4);
  5.         myShape.vertex(heartSize/2, heartSize*0.15);
  6.         myShape.bezierVertex(heartSize*0.5, -heartSize*0.05, heartSize*0.1, heartSize*0.05, heartSize*0.5, heartSize*0.4);
  7.         myShape.endShape();

doing this, when I call getVertexCount(), I get 42 vertexs!! Why? I just defined a few of them. Does processing calculates the path and creates like 20 'normal' vertexs for each of my bezierVertex? 

Is there an easy way to access to the bezierVertexs I defined, in order I can update their values? As I see in the PShape javadoc page, there's nothing like setBezierVertex, that's what I'd ideally need, so I could update the 6 parameters I used when defining the bezierVertex. 

Also, calling getVertexCode() throws a null pointer error, plus processing doesn't show it in blue color like, for instance, getVertex, so it makes me think getVertexCode is not fully/correctly implemented?:
  1. for (int i=0; i<myShape.getVertexCount(); i++) {
  2.    //println(myShape.getVertex(i)+"    "+myShape.getVertexCode(i));  //Can't use it! it crashes!!
  3.    println(myShape.getVertex(i)+"    ");
  4. }
Caused by: java.lang.NullPointerException
    at processing.core.PShape.getVertexCode(PShape.java:2401)

         ...

Any help or light on this issue will be very highly appreciated. Thanks!


Viewing all articles
Browse latest Browse all 1768

Trending Articles