I am using Processing 2.08 on mac. I am trying to create a PShape using the createShape function as given in the documentation.
PShape s;
void setup(){
size(500,500);
s = createShape();
s.beginShape(QUADS);
s.fill(0);
s.vertex(100,100);
s.vertex(100,300);
s.vertex(300,300);
s.vertex(300,100);
s.endShape();
}
void draw(){
shape(s);
}
But this program throws NullPointerException. Upon looking up on the Processing.org forum I found a thread saying that the new processing library has problem with this one.
ref: https://forum.processing.org/topic/changes-to-pshape-in-2-08
How do I make this work? Is there any workaround? Thanks
I addition to nickecarlo's answer, you could use PGraphics:
or implement your own Shape class. Here's a very crude example:
From the documentation:
You can find the reference here: http://processing.org/reference/PShape.html
In short, for now, you can't use PShape without first creating a shape elsewhere.
You could just create an image independently, save it on file and then load it with PShape. Its a hack but it makes it possible to use PShape at least until they can come up with a more proper fix.