Hey,
I have a SVG file which I want to load and change the colour, then redraw to screen. I thought I had it sussed following a recent example but I am getting an error. Can anyone help please?
Code:PGraphics splatcolored;
PShape splat_shapeA, splat_shapeB, splat_shapeC, splat_shapeD, splat_shapeE;
void setup() {
size(500,500);
splat_shapeA = loadShape("cursorSplat1_large.svg");
splat_shapeB = loadShape("cursorSplat2_large.svg");
splat_shapeC = loadShape("cursorSplat3_large.svg");
splat_shapeD = loadShape("cursorSplat4_large.svg");
splat_shapeE = loadShape("cursorSplat5_large.svg");
// SPLAT!
stroke(-65536,5);
fill (-65536);
}
void draw() {
if (mousePressed) {
splatcolored = createGraphics(325, 324, JAVA2D);
splatcolored.beginDraw();
// Randomise between the 5 splats
int ri = int(random(1,6));
if (ri == 1) {
splat_shapeA.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeA, 0, 0);
splatcolored.endDraw();
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
else if (ri == 2) {
splat_shapeB.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeB, 0, 0);
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
else if (ri == 3) {
splat_shapeC.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeC, 0, 0);
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
else if (ri == 4) {
splat_shapeD.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeD, 0, 0);
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
else if (ri == 5) {
splat_shapeE.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeE, 0, 0);
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
else {
splat_shapeC.disableStyle();
splatcolored.fill(-65536);
splatcolored.stroke(-65536);
splatcolored.shape(splat_shapeC, 0, 0);
image(splatcolored, mouseX - (splatcolored.width / 2), mouseY - (splatcolored.height / 2));
}
}
}
Here is the error I get :(
Code:Exception in thread "Animation Thread" java.lang.NullPointerException
at java.lang.System.arraycopy(Native Method)
at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:412)
at processing.core.PGraphicsJava2D.updatePixels(Unknown Source)
at processing.core.PGraphicsJava2D.imageImpl(Unknown Source)
at processing.core.PGraphics.image(Unknown Source)
at processing.core.PApplet.image(Unknown Source)
at coloursvg.draw(coloursvg.java:74)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)