// Displays the photos from an Instagram export, one second per image. You must put your insta // export in the "data" directory of this sketch. PImage[] photos = new PImage[0]; // a global array to hold images from setup() to use in draw() void setup () { size(1000,1000); JSONObject myInsta = loadJSONObject("media.json"); // load the json file from my Instagram export JSONArray myPosts = myInsta.getJSONArray("photos"); // load the array of info about the photos for ( int i = 0; i < myPosts.size(); i++) { // for every photo in the array JSONObject onePost = myPosts.getJSONObject(i); // make a var to hold the photo's info and get the info PImage thisImage; // make a var to store the actual image file temporarily println("Loaded " + onePost.getString("path")); // for debugging, to be sure it is working if ((thisImage = loadImage(onePost.getString("path"))) != null) { // check for an error (missing image?) photos = (PImage[]) append(photos, thisImage); // if no error, add the image to the photos[] array } frameRate(1); // slow down the draw() loop to 1 FPS } photos = (PImage[]) reverse(photos); // for fun, let's start with the oldest photos (puppies) } void draw() { background(0); // clear the screen, black background int photoNumber = (frameCount % photos.length) - 1; // the modulo (%) operator makes it loop continuously // we subtract 1 above because frameCount starts at 1 but the array starts at 0 photos[photoNumber].resize(width, 0); // be sure it fits the window image(photos[photoNumber],0,0); // put the next image on the screen at x,y 0,0 }