#pragma once #define IMAGE_STORE_SIZE 256 #define MIN_TILE_SIZE 8 #define MAX_TILE_SIZE 16 #include "ofMain.h" #include "ofxJSONElement.h" long ofToLong(const string& intString); class imageStore : public ofThread{ public: float interval; //time between refreshes in seconds std::string instagram_url; ofxJSONElement response; std::map images; deque to_update; imageStore(){ instagram_url = "https://api.instagram.com/v1/tags/tycleeson/media/recent?client_id=c1d74d701fdf4ddd9f8d30ee9e8f944b"; interval=5.00f; } void set_interval(float _interval){ interval=_interval; } void start(){ startThread(true, false); // blocking, verbose } void stop(){ stopThread(); } //-------------------------- void threadedFunction(){ //1st get the pre-existing images ofDirectory image_path(ofToString(IMAGE_STORE_SIZE)+"/"); cerr<<"image path: "<::iterator i=images.begin();i!=images.end();++i){ // if(i->second.isUsingTexture()){ // drawcount++; // } //} //cout<<"loaded "<::iterator i=images.begin();i!=images.end();++i){ if(i->second.isUsingTexture()){ i->second.draw(ofToLong(i->first)%(long)(ofGetWidth()-i->second.getWidth()+1),ofToLong(i->first)%(long)(ofGetHeight()-i->second.getHeight()+1)); } } */ map::iterator it=images.begin(); if (it!=images.end()){ for (int i=0;isecond.isUsingTexture()){ it->second.draw(i*MAX_TILE_SIZE,j*MAX_TILE_SIZE); } it++; if (it==images.end()) it=images.begin(); } } } unlock(); } } };