#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(72); 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.jpg"); 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); type14.drawString(instagram.getImageCaption()[i],imgx+(textrowinset*FACTOR), imgy+(textcolinset*FACTOR)); } col++; if (col==cols){ col=0; row++; } } } ofEnableAlphaBlending(); overlay.draw(0,0,ofGetWidth(),ofGetHeight()); ofDisableAlphaBlending(); //captions[i]=getImageCaption()[i]; /* bikers.draw(0, 0); gears.draw(600, 0); tdf.draw(600, 300); ofSetColor(220, 50, 50); tdfSmall.draw(200, 300); ofSetColor(255); ofEnableAlphaBlending(); float wave = sin(ofGetElapsedTimef()); transparency.draw(500 + (wave * 100), 20); ofDisableAlphaBlending(); // getting the ofColors from an image, // using the brightness to draw circles int w = bikeIcon.getWidth(); int h = bikeIcon.getHeight(); float diameter = 10; ofSetColor(255, 0, 0); for(int y = 0; y < h; y++) { for(int x = 0; x < w; x++) { ofColor cur = bikeIcon.getColor(x, y); float size = 1 - (cur.getBrightness() / 255); ofDrawCircle(x * diameter, 500 + y * diameter, 1 + size * diameter / 2); } } // same as above, but this time // use the raw data directly with getPixels() ofPixels & pixels = bikeIcon.getPixels(); ofSetColor(0, 0, 255); for(int y = 0; y < h; y++) { for(int x = 0; x < w; x++) { int index = y * w + x; unsigned char cur = pixels[index]; float size = 1 - ((float) cur / 255); ofDrawCircle(200 + x * diameter, 500 + y * diameter, 1 + size * diameter / 2); } } ofSetColor(255); bikeIcon.draw(190, 490, 20, 20); */ } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseEntered(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseExited(int x, int y){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ } //-------------------------------------------------------------- void ofApp::exit() { getImages.stopThread(); }