Within setup and main. I am creating a pg graphics at x,y resolution, placing a value in centre. Then randomly choosing a point. If the point = centre then x,y found.
Wth am I doing wrong??
PGraphics pg;
float col=10;
int count=0;
int xsize=1500;
int ysize=500;
int tempx;
int tempy;
int temppixel;
float pixheight;
int pixel;
void setup(){
size(1500, 500);
noSmooth();
colorMode(RGB,255);
pg=createGraphics(xsize, ysize);
pg.noSmooth();
pg.beginDraw();
pg.background(0,0,0);
pg.loadPixels();
pg.fill(255);
pg.strokeCap(SQUARE);
frameRate(1);
int px=xsize/2;
int py=ysize/2;
pixel=(px+(py*xsize));
pg.pixels[pixel] = color(200,200,200);
positionchange();
}
void draw(){
pg.colorMode(RGB,255);
pg.beginDraw();
pg.updatePixels();
image(pg,0,0,1500,500);
}
void positionchange(){
tempx=int(random(1,xsize));
tempy=int(random(1,ysize));
temppixel=(tempx+(tempy*xsize));
pixheight=red(pg.pixels[temppixel]);
println(temppixel);
if (pixheight==0); {
positionchange();
}
}