#include "ofApp.h" #define timtoken "3281768761.3dfcaf5.14ca9410c2aa4c00b9b60f36cd09d01a" #define hangdaitoken "3939854844.b31608d.a61a4e49a4dc40a688c22f4e0e81da3a" void ofApp::loadimages(){ images.clear(); images.resize(IMAGE_SLOTS); instagram.getUserRecentMedia("self"); //instagram.getUserLikedMedia(12); if (!instagram.getImageURL().empty()) { for ( int i = 0; i < min(IMAGE_SLOTS,(int)instagram.getImageURL().size()); i++) { getImages.loadFromURL(images[i], instagram.getImageURL()[i]); ofLog(OF_LOG_NOTICE) << instagram.getImageURL()[i]; //images[i].load("images/"+ofToString(i)+".jpg"); // //images[i].resize(480*FACTOR,480*FACTOR); } } /* for ( int i = 0; i < IMAGE_SLOTS; i++) { images[i].load("images/"+ofToString(i)+".png"); } */ } //-------------------------------------------------------------- void ofApp::setup(){ ofTrueTypeFont::setGlobalDpi(180); type14.load("American Typewriter Regular.ttf", 14*FACTOR, true, true); type14.setLineHeight(18.0f*FACTOR); type14.setLetterSpacing(1.037*FACTOR); /* bikers.load("images/bikers.jpg"); gears.load("images/gears.gif"); tdf.load("images/tdf_1972_poster.jpg"); tdfSmall.load("images/tdf_1972_poster.jpg"); tdfSmall.resize(tdfSmall.getWidth() / 4, tdfSmall.getHeight() / 4); tdfSmall.setImageType(OF_IMAGE_GRAYSCALE); transparency.load("images/transparency.png"); bikeIcon.load("images/bike_icon.png"); bikeIcon.setImageType(OF_IMAGE_GRAYSCALE); */ background.load("images/background1080.png"); overlay.load("images/overlay1080.png"); //overlay.setImageType(OF_IMAGE_GRAYSCALE); instagram.setup(hangdaitoken,"self"); instagram.setCertFileLocation(ofToDataPath("ca-bundle.crt",false)); loadimages(); /* instagram.getUserRecentMedia("self"); //instagram.searchForTags("hangdai"); //ofLog(OF_LOG_NOTICE) << instagram["data"][0]["caption"]["text"].asString(); const Json::Value selfdata = instagram.getJSON()["data"]; for ( int index = 0; index < selfdata.size(); ++index ) // Iterates over the sequence elements. ofLog(OF_LOG_NOTICE) << selfdata[index]["caption"]["text"].asString(); */ //load } //-------------------------------------------------------------- void ofApp::update(){ ofBackground(255); } //-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255); ofPushMatrix(); //Store the coordinate system nexessary for some reason background.draw(0,0,ofGetWidth(),ofGetHeight()); ofPopMatrix(); //Restore the coordinate system //ofLog(OF_LOG_NOTICE,"background is %fx%f",background.getWidth(),background.getHeight()); /* int rowinitialoffset=40; int colinitialoffset=60; int rowoffset=520; int imgsize=480; int coloffset=603; int col=0; int row=0; int rows=2; */ int colinitialoffset=40; int rowinitialoffset=60; int coloffset=520; int imgsize=480; int rowoffset=615; int col=0; int row=0; int cols=2; int textcolinset=40; int textrowinset=50; if (!images.empty()) { for (int i = 0; i < images.size(); i++) { //for (int i = 0; i < 5; i++) { if (images[i].isAllocated()) { //ofLog(OF_LOG_NOTICE,"Image %i is %fx%f",i,images[i].getWidth(),images[i].getHeight()); int imgx=(colinitialoffset+(col*coloffset))*FACTOR; int imgy=(rowinitialoffset+(row*rowoffset))*FACTOR; images[i].draw(imgx,imgy,imgsize*FACTOR,imgsize*FACTOR); std::string caption=instagram.getImageCaption()[i]; int captionend = caption.find("#"); if (captionend == std::string::npos){ captionend=caption.size(); } float width=type14.stringWidth(caption.substr(0,captionend)); ofLog(OF_LOG_NOTICE) << caption.substr(0,captionend) << " <<<<:width: " << width; vector captions = ofSplitString(caption.substr(0,captionend), " "); if (width