draw() doesn't work when using saveFrame()
in
Programming Questions
•
6 months ago
- void draw()
- {
- count++;
- float diffA = 0;
- float diffB = 0;
- float diffAnew = 0;
- float diffBnew = 0;
- //randomly select two tiles
- int imgA = int(random(num_tiles));
- int imgB = int(random(num_tiles));
- //make sure they are not the same tile
- while (imgA == imgB)
- {
- imgB = int(random(num_tiles));
- }
- //get difference between tile and image under it
- diffA = difference(imgA, sect_to_px(imgA));
- diffB = difference(imgB, sect_to_px(imgB));
- //switch tiles and get difference between tile and image under it
- diffAnew = difference(imgA, sect_to_px(imgB));
- diffBnew = difference(imgB, sect_to_px(imgA));
- //switch tiles if new positions are better
- if (((diffA - diffAnew) + (diffB - diffBnew)) > 0)
- {
- //change sections of tiles
- tiles.get(index_in_list(imgA)).section = imgB;
- tiles.get(index_in_list(imgB)).section = imgA;
- display_img(tiles.get(index_in_list(imgA)).img, imgA);
- display_img(tiles.get(index_in_list(imgB)).img, imgB);
- total_diff += (diffAnew - diffB);
- total_diff += (diffBnew - diffA);
- }
- saveFrame("output/output###.jpg");
- }
1