I've JUST started to use Processing, and I've already encountered a problem with the tutorials. :(
I was following the code word-for-word in the
PShape tutorial "Custom Shapes", and I couldn't properly run it.
The code I copied was this:
PShape star;
void setup() {
size(500,500);
smooth();
// First create the shape
star = createShape();
// You can set fill and stroke
star.fill(102);
star.stroke(255);
star.strokeWeight(2);
// Here, we are hardcoding a series of vertices
star.vertex(0, -50);
star.vertex(14, -20);
star.vertex(47, -15);
star.vertex(23, 7);
star.vertex(29, 40);
star.vertex(0, 25);
star.vertex(-29, 40);
star.vertex(-23, 7);
star.vertex(-47, -15);
star.vertex(-14, -20);
// We are done with the shape
star.end(CLOSE);
}
void draw() {
background(51);
translate(mouseX, mouseY);
shape(star);
}
The only things I added was in lines 5 and 6, but that's it. When running the code, it highlights line 11 with this error:
NullPointerException
createShape(), or this particular variation of it, is not available with this renderer.
Exception in thread "Animation Thread" java.lang.NullPointerException
at test01.setup(test01.java:31)
at processing.core.PApplet.handleDraw(PApplet.java:2103)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:190)
at processing.core.PApplet.run(PApplet.java:2006)
at java.lang.Thread.run(Thread.java:662)
I used Processing 2.0b3 (for 64-bit Windows), but even with 1.5 I still got an error, albeit with a different error message. The tutorial said it was for Processing 2.0+.
I looked at another
similar thread, but didn't understand most of what was said there - I'm a REAL beginner with this stuff.
Is something wrong with the code or did I type something wrong? :S I'm completely clueless and stuck with what's wrong here.