Quote:java.lang.NullPointerException
at processing.core.PApplet.brightness(PApplet.java:6668)
at mkv.MyGUI.MyGUIStyle.tintColor(MyGUIStyle.java:156)
...
Any ideas whats going wrong, I'll explain what I know:
I am trying to get my own MyGUI code into a library that I can use and test inside processing. Its compiled as a JAR sitting in
\libraries\MyGUI\library, certain methods in the library I can access without error.
When I create a MyGUIStyle object, it by default sets up a bunch of colours, and tints one of the colours using a custom method:
Code: // sub-method, returns a single tinted value
public int tintColor(int c, int tint, float str) {
float br = (float)(brightness(c) * brightness(tint) / 255 / 255);
float r = (float)((red(tint)*str + red(c)*(1-str)) * br);
float g = (float)((green(tint)*str + green(c)*(1-str)) * br);
float b = (float)((blue(tint)*str + blue(c)*(1-str)) * br);
return color(round(r), round(g), round(b), alpha(c));
}
This explains the the trace to
mkv.MyGUI.MyGUIStyle.tintColor(MyGUIStyle.java:156) Problem, the stack trace breaks at line 6668 (the brightness method) in PApplet. I downloaded the latest PApplet.java file from
SourceForge and scrolled to line 6668 (right at the bottom coincidently)... I found this code:
Code:
public final float brightness(int what) {
return g.brightness(what);
}
The variable g is a PGraphics object. So, what is causing the null pointer exception? A dodgey int value? the PGraphics g object not being created yet? (surely not).
Please, help if you can.