1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
#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++)
{
//if (instagram.getImageURL()!=)
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(150);
myText.init("American Typewriter Regular.ttf", 14*FACTOR, 'i');
background.load("images/background1080.png");
overlay.load("images/overlay1080.png");
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
ofSetFrameRate(5);
}
//--------------------------------------------------------------
void ofApp::update(){
ofBackground(255);
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetColor(255,255,255);
ofPushMatrix(); //Store the coordinate system nexessary for some reason
background.draw(0,0,ofGetWidth(),ofGetHeight());
ofPopMatrix(); //Restore the coordinate system
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=20;
int textrowinset=50;
//some kind of rendering bug with textsuite means it has to go last or everything is dim
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];
myText.setText(caption);
myText.wrapTextX(imgsize*FACTOR);
myText.setColor(255,255,255,255);
myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset)*FACTOR),2);
}
col++;
if (col==cols){
col=0;
row++;
}
}
}
ofEnableAlphaBlending();
overlay.draw(0,0,ofGetWidth(),ofGetHeight());
ofDisableAlphaBlending();
float t=ofGetElapsedTimef();
}
//--------------------------------------------------------------
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();
}
|