-
Notifications
You must be signed in to change notification settings - Fork 0
/
idole.pde
311 lines (218 loc) · 6.64 KB
/
idole.pde
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
import gifAnimation.*;
import twitter4j.*;
import twitter4j.api.*;
import twitter4j.auth.*;
import twitter4j.conf.*;
import twitter4j.json.*;
import twitter4j.management.*;
import twitter4j.util.*;
import twitter4j.util.function.*;
import java.util.Date;
import java.util.*;
import processing.awt.PSurfaceAWT;
import java.awt.Robot;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.awt.Robot;
//screenshoot
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.imageio.ImageIO;
import java.awt.Robot;
//Déclaration des objets
TwitterFactory twitterFactory;
Twitter twitter;
RequestToken requestToken;
//Déclaration de l'objet requête
Query requete;
//Déclaration de l'objet de résultat de requête
QueryResult resultat;
//Déclaration d'un tableau pour stocker les requêtes récupérées de Twitter
ArrayList tweets;
//déclaration des variables textes qui nous permettront d'utiliser
//les résultats de requêtes
String msg, user, pseudo;
// Déclaration des objets TwitterFactory et Twitter
Status status;
String OAuthConsumerKey = "xx";
String OAuthConsumerSecret = "xx";
static String AccessToken = "xx";
static String AccessTokenSecret = "xx";
PImage img;
PImage tower;
//List<Status> statuses = null;
boolean load=true;
Robot robot;
PFont pfont;
PImage screenShot;
String tweet_ = "#processing #gif #happynewyear #your2017";
File file = new File(sketchPath() + "/data/test.jpg");
GifMaker gifExport;
PImage logo;
void setup() {
//Taille de la fenêtre de l'applet
size(500, 500);
smooth();
frameRate(24);
println("gifAnimation " + Gif.version());
gifExport = new GifMaker(this, "/data/export.gif");
gifExport.setRepeat(0); // make it an "endless" animation
// gifExport.setTransparent(0,0,0); // make black the transparent color. every black pixel in the animation will be transparent
// GIF doesn't know have alpha values like processing. a pixel can only be totally transparent or totally opaque.
// set the processing background and the transparent gif color to the same value as the gifs destination background color
// (e.g. the website bg-color). Like this you can have the antialiasing from processing in the gif.
element();
saveFrame(sketchPath() + "/data/test.jpg");
//Authentification
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey("");
cb.setOAuthConsumerSecret("");
cb.setOAuthAccessToken("-");
cb.setOAuthAccessTokenSecret("");
//Utilisation des informations d'authentification pour se connecter à l'API twitter
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
// try{
// **
// Using just the path of this sketch to demonstrate,
// but you can list any directory you like.
file = new File(sketchPath()+ "/data/test.jpg");
testPassingFile(file );
// statuses = twitter.getHomeTimeline();
/**/
/*
for (Status status:statuses){
//
println(status.getUser().getName(),status.getText());
//status = twitter.updateStatus("love me ");
}
}catch(TwitterException e){
println("Get timeline:" + e + "Status code:" + e.getStatusCode());
*/
//}
}
void testPassingFile(File _file)
{
println(_file.exists());
println(_file.getName());
println(_file.getPath());
println(_file.canRead());
}
float ii=0;
final int[] pos=new int[200];
void element(){
//background(0,1);
fill(0,80);
rect(0,0,500,500);
ellipseMode(CENTER);
//if( frameCount<1)for(int i=0;i<200;i++)pos[i]=int(random(-50,50));
for(int i=1;i<10;i++)for(int z=0;z<5;z++){
float d= dist(250,250,100*(z),50*(i));
int centerx=250,centery=250;
float flot=20*sin(ii+=0.0001+PI*2);
float flotx=20*cos(ii+=0.001 +PI*2);
fill(250/flot-flotx%ii%flot);
rect(50+i*80,50+35*z,25,40);
fill(250*flotx);
//rect(0+z*80,10+35*i,10,150);
stroke(80+flotx/flot);
fill(250/100,10);
ellipse(centerx,centery,250,250);
fill(250*flotx,0,0);
stroke (250,0,0);
strokeWeight(abs(flot));fill(250/100,10);
ellipse(centerx,centery,250+flotx,250+flotx);
strokeWeight(1);
fill(250/flot-flotx%ii%flot);
ellipse(flotx/flot+centerx+80*sin(z/PI*2),flot/flotx+centery+80*cos(z/PI*2),10,10);
fill(250,0,0);noStroke();
ellipse(flot/flotx+centerx,flotx/flot+centery,50,50);
/*ellipse(50+100*(z),+50+
50*(i),d%ii*3%100+
(50*(cos( ii+=0.0002))-z%30),d%ii*3%100+(50*(cos( ii ))-z%30));
fill(i*100,z*10,z*i*10,i*100);
//ellipse(100*(z),50*(i),(10*(cos( ii+=0.00010))-z%30),(10*(cos( ii ))-z%30));
ellipse(50+100*(z),+50+
50*(i),d%ii*3%100+
(20*(cos( ii+=0.0002))-z%30),
d%ii*3%100+(20*(cos( ii ))-z%30));
//println(frameCount);
;
*/
if(ii>20000)ii=0;
}
gifExport.setDelay(1);
gifExport.addFrame();
if(frameCount==200){ gifExport.finish();
println("gif saved");
}
}
void draw() {
//
element();
if(!load) image (screenShot,0,0,550,500);
textSize(15);
text(tweet_,10,450);
}// Fonction d'envoi de tweet
// à chaque fois que nous cliquons dans la fenêtre de l'applet...
/*void mousePressed() {
saveFrame(sketchPath() + "/data/test.jpg");
try
{
StatusUpdate status = new StatusUpdate(tweet_);
status.setMedia(file);
twitter.updateStatus(status);
}
catch (TwitterException te)
{
println("Error: "+ te.getMessage());
}
}
*/
void keyPressed (){
if(key=='1'){
try {
robot = new Robot();
robot.setAutoDelay(0);
}
catch (Exception e) {
e.printStackTrace();
}
//PImage pimage = new PImage(src);
Rectangle screenRect = new Rectangle( Toolkit.getDefaultToolkit().getScreenSize() );
try {
BufferedImage screenBuffer = new Robot().createScreenCapture( screenRect );
screenShot = new PImage( screenBuffer.getWidth(), screenBuffer.getHeight(), PConstants.ARGB );
screenBuffer.getRGB( 0, 0, screenShot.width, screenShot.height, screenShot.pixels, 0, screenShot.width );
screenShot.updatePixels();
load=false;
} catch ( AWTException e ) {
e.printStackTrace();
}
saveFrame(sketchPath() + "/data/test.jpg");
file = new File(sketchPath()+ "/data/test.jpg");
testPassingFile(file );
}
if(key=='2'){
file = new File(sketchPath()+ "/data/export.gif");
testPassingFile(file );
}
if(key=='3'){
try
{
StatusUpdate status = new StatusUpdate(tweet_);
status.setMedia(file);
twitter.updateStatus(status);
}
catch (TwitterException te)
{
println("Error: "+ te.getMessage());
}
}
}