Program won't draw anything within the void draw routine
in
Programming Questions
•
10 months ago
So I'm working on this code for a project and for some reason, I can't get anything drawn over the image. Even if the image were to be removed, it still won't draw anything. Please help me! If I remove my For Loop it draws the rectangle for some reason!
Here is my code:
------------------------------------------------------------------------------------------
- int[] arrayred = new int[607500];
- int[] arraygreen = new int[607500];
- int[] arrayblue = new int[607500];
- PImage img;
- int x = 0;
- int y = 0;
- void setup () {
- size(900,675);
- img = loadImage("Turner.jpg");
- image(img, 0, 0);
- //background(255);
- }
- void draw () {
- for (int i = 0; i < img.pixels.length; i++) {
- color pix = img.pixels[i];
- int r = (pix >> 16) & 0xFF;
- int g = (pix >> 8) & 0xFF;
- int b = (pix >> 0) & 0xFF;
- arrayred[i] = r;
- arraygreen[i] = g;
- arrayblue [i] = b;
- fill(r, g, b);
- rect(width/2, height/2,50 ,50);
- println(r);
- println(g);
- println(b);
- delay(200);
- }
- point(x,y);
- x = x + 1;
- if ( x == 900) {
- x = 0;
- y = y + 1;
- }
- }
1