We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I know that if I want to use images in PJS I have to put this at the top
/* @pjs preload="image101.png, image102.png, image103.png, image104.png, image105.png, image106.png, image107.png, image108.png, image109.png"; */
I've just written a gallery which selects images at random from those in the source directory; the population looks like this
num = 899;
allImages = new PImage[num];
for (int i = 0; i < num; i++)
{
allImages[i] = loadImage(imagePath + fileName + (i + 100) + ".jpg");
if (allImages[i] == null)
{
num = i;
break;
}
}
'S'not very elegant but 'tis functional!
Do I have to preload image100.png, ... image 999.png
(a) even though there might be only 120 images?
(b) I choose to display a sample 100 of those 120 say?
(c) if so, can I use a for loop?
(d) will it fail altogether if any of the images in the preload list don't exist?
Answers
I've always been curious about that 1 too: Whether we MUST use
/* @pjs preload=""; */
in order to load any resources? :-??I wonder whether eventually all of the loadImage() files end up fully loaded down the road? :-?
Why don't you preload only the images you need right way and use loadImage() to them?
And then use requestImage() to those non-preloaded 1s? That's an experiment I'd like to see the result! [-O<
Thanks - people on various forums seem divided about the preload and requestImage(); I was trying the former as that's how I fixed my openProcessing sketch which uses images.
I've stumbled over more problems before I can test those: I was using the really neat IntList.shuffle() to generate my random list of images, getting the error message "ha ha, you didn't expect this to work did you?" when I tried in js mode; and of course there's something wrong with the mouse positioning. sigh
Class IntList is Processing 2+! JS Mode 1.4.1 is from an age where Processing 1.5.1 reigned supreme! 8->