Heya, here's a simple app that first loads some profile pics from myspace, and then moves them across the screen, changing them every second.
I know, pointless now, used this to learn a little about the proHTML library for another project.
My problem however is that it takes quite a while to laod the pics upfront before getting to the draw loop. Any suggestions on how I could start drawing and grabbing the pics concurrently, to rid the long lead time?
Code:
import prohtml.*;
HtmlImageFinder htmlImageFinder;
PImage[] pics;
int i=0;
int frame=0;
void setup() {
String[] profiles;
size(600,600);
background(0);
frameRate(60);
pics = new PImage[6];
profiles = new String[5];
profiles[0] = "http://www.myspace.com/blahblah0";
profiles[1] = "http://www.myspace.com/blahblah1";
profiles[2] = "http://www.myspace.com/blahblah2";
profiles[3] = "http://www.myspace.com/blahblah3";
profiles[4] = "http://www.myspace.com/blahblah4";
//load pic array with profile pics
for (int c=0; c<5; c++) {
pics[c] = getProfilePic(profiles[c],c);
}
}
PImage getProfilePic(String url, int c) {
PImage pic;
htmlImageFinder = new HtmlImageFinder(url);
pic = loadImage(htmlImageFinder.getImageLink(1));
return pic;
}
void draw() {
background(0);
image(pics[i], frame*2, 10);
if(frameCount % 60 == 0) i++;
frame++;
}
Also, seeing as this is my first Processing app.. any glaring flaws or bad habits in the way I wrote this?
Many thanks!