hello,
I wrote a code that will give any pixel one after the other a random greytone. over that i would like to place a picture (.gif) with a green border and an alpha'd rectangle in the middle via a mouseclick.
both parts work when started singular, together processing returns me a "NullPointerException" i don't really get.
Can somebody tell me why it result's and how i can change that ?
Stefan
Code:
int x = 0;
int y = 0;
PImage b;
void setup() {
size(512, 384);
/* size(screen.width, screen.height); */
background(255);
noStroke();
colorMode(RGB);
/* framerate(200); */
PImage b = loadImage("testgruen.gif");
}
void draw() {
for(int i=0; i<100; i++) {
float r = random(255);
fill(r); // set Variables fill(r, r, r) for Schwarz/Weiss
if ((x <= width) && (y <= height)) {
rect(x, y, 3, 3);
x++;
}
if (x >= width) {
y++;
x = 0;
x++;
x = x - 1;
}
if (y >= height) {
x = 0;
y = 0;
rect(x, y, 3, 3);
x++;
}
}
if(mousePressed) {
image(b, 0, 0);
}
}