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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
#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();
}
|