image() function. Screening images rare behaviour
in
Programming Questions
•
2 years ago
Hi,
I'm having a problem, but no errors neither NullPonterException...
The sketch below runs, prints all data needed and even exits correctly, but images keep stucked in the first one loaded.
The strange thing is that if you make focus on the sketch window while Processing is running and return to the screening window, you can see the whole new image or part of it, whether the sketch window was totally or partially on top of the other. Whatever, you need this action to see any changes on the screen. It was checked in three different comps.
A walk-around solution using different functions (although not optimal for other reasons) screens images correctly.
I'll appreciate any help on this. The data folder is
here.
- PImage[] images = new PImage[8];
- void setup () {
- size (400, 300);
- images[0] = loadImage("0.jpg");
- images[1] = loadImage("1.jpg");
- images[2] = loadImage("2.jpg");
- images[3] = loadImage("3.jpg");
- images[4] = loadImage("4.jpg");
- images[5] = loadImage("5.jpg");
- images[6] = loadImage("6.jpg");
- images[7] = loadImage("7.jpg");
- }
- void draw () {
- int time = millis();
- int index_before = -1;
- int index_now = -1;
- for (int j = 45; j > 2; j--) {
- index_now = int (random(images.length));
- int a = int(random(j/3, j))*100;
- if (index_now != index_before) {
- image (images [index_now], 0, 0);
- println (millis () + " " + j + " " + a + " " + index_now);
- index_before = index_now;
- delay (a);
- }
- }
- println ("EXIT");
- exit();
- }
1