Ok, so to be clear, my goal here is to create sketches using my own functions inside large files that I can save to disk.
So, I got it to stop complaining about nullPointerException on the setup object function calls, by extending PGraphics instead of PGraphics2, but... now I can't save the image because that's in PGraphics2, I'm guessing.
Quote:
int counter;
int arc_start_x;
int arc_start_y;
int arc_height;
int random_height;
// this won't work because myClass is extending PGraphics2, which takes 3 arguments to construct,
// so this applet will launch, but fail because it's missing arguments
myClass big = new myClass();
// this doesn't work because it won't find my extensions to pgraphics2 .. I'm so confused.
// myClass big = new myClass(2000,2000,null);
// this will work but will fail on calling my function, obviously
// PGraphics2 big = new PGraphics2(2000,2000,null);
void setup() {
// so, shouldn't I be doing something in the setup after object construction to set these arguments as defaults?
// big.height1(2000);
// big.width1(2000);
big.background(128);
big.defaults();
big.smooth();
}
void draw()
{
int randomNumber = int(random(width));
for(int x=0;x<=2;x++)
{
// uncomment these, and they work fine because they're not in the class extension.
big.stroke(int(random(255)),int(random(255)),100);
big.line(counter*10, randomNumber, int(random(2000)), int(random(2000)));
int arc_start_x = int(random(2000));
int arc_start_y = int(random(2000));
int arc_height = int(random(1900,1900));
// BONK...
big.myFunction(arc_height, arc_start_x, arc_start_y);
}
// etc..
counter++;
if(counter >= 100)
{
// big.endFrame();
// make sure the file is written to the sketch folder
String path = savePath("big-"+int(random(100000000,1000000000))+".png");
big.save(path);
noLoop();
}
}
class myClass extends PGraphics
{
int height1 = 2000;
int width1 = 2000;
void myFunction(int arc_height, int arc_start_x, int arc_start_y)
{
arc_height = abs(arc_height);
arc(arc_start_x, arc_start_y, arc_height, arc_height, TWO_PI-PI/2, TWO_PI);
}
}
here's the error
Quote:java.lang.RuntimeException: Error while saving image.
at processing.core.PImage.save(PImage.java:2215)
at Temporary_271_588.draw(Temporary_271_588.java:57)
at processing.core.PApplet.handleDisplay(PApplet.java:1336)
at processing.core.PGraphics.requestDisplay(PGraphics.java:535)
at processing.core.PApplet.run(PApplet.java:1152)
at java.lang.Thread.run(Thread.java:613)
because the save function is in PGraphics2, not PGraphics, yeah? How do I extend PGraphics2 and construct an object without parameters?