This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

indyLoader=new ImageLoader(); loadThread=new Thread(indyLoader); for (int i=1;i<29;i++){ indyLoader.loadImg("indy/"+i+".jpg"); } loadThread.start(); MSLoader=new ImageLoader(); loadThread=new Thread(MSLoader); for (int i=0;i<30;i++){ MSLoader.loadImg("reuters/"+i+".jpg"); } loadThread.start(); //sharedLoader=new ImageLoader(); //loadThread=new Thread(sharedLoader); } void draw() { fill(0, 40); rect(0,0,width,height); xI = int(random(360, 740)); xMS = int(random(0, 300)); yI = int(random(0, 555)); yMS = int(random(0, 555)); noTint(); noStroke(); frameCounter ++; fill(255); for(int i=0; i< indyLoader.num; i++) { PImage tmp=indyLoader.getImage(i); if(tmp!=null) { image(tmp, xI, yI); //x=x+tmp.width; } } for(int i=0; i< MSLoader.num; i++) { PImage tmp=MSLoader.getImage(i); if(tmp!=null) { image(tmp, xMS,yMS); //x=x+tmp.width; } } // noTint(); tint(255, 15); image(flag, 0, 0); tint(255, 100); image(bush, 117, 0); tint(255, 100); image(citizen, 374, 0); } void stop() { indyLoader.loadDone=true; MSLoader.loadDone=true; super.stop(); } class ImageLoader implements Runnable { ImageURL img[]; int num,remaining; boolean loadDone=false; public ImageLoader() { img=new ImageURL[100]; num=0; remaining=0; } void loadImg(String _url) { // expand array if necessary if(num==img.length) img=(ImageURL[])expand(img); img[num++]=new ImageURL(_url); remaining++; } public PImage getImage(int id) { // return null if incorrect ID, image not loaded or error occurred if(img[id]==null || !img[id].loaded || img[id].error) return null; return img[id].img; } public void run() { int loadID=0; // loop run() until loadDone is set to true while(!loadDone) { // find an image to load loadID=0; if(num>0) do { if(img[loadID].loaded) loadID++; else if(img[loadID]!=null) { img[loadID].load(); // load image remaining--; // one less remaining to load break; // exit do loop; } } while(loadID< num); try { loadThread.sleep(2000); } catch(InterruptedException e) { e.printStackTrace(); } } println("Loader thread exiting."); } } class ImageURL { PImage img; boolean loaded=false,error=false; String url; public ImageURL(String _url) { url=_url; } void load() { println("nLoading image: "+url); img=loadImage(url); if(img==null) error=true; loaded=true; if(error) println("Error occurred when loading image."); else println("Load successful. "+ "Image size is "+img.width+"x"+img.height+"."); } }

Source code: url_image4

Built with Processing