-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
49 lines (39 loc) · 922 Bytes
/
sketch.js
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
//API part
var api = "http://api.giphy.com/v1/gifs/search?";
var apiKey = "&api_key=dc6zaTOxFJmzC";
var query = "&q=cute+cat";
var gifs = [];
var url = api + apiKey + query;
var changeState = false ;
//keep track of time
var m, h, s ;
function setup() {
noCanvas();
}
function draw(){
//keep track of time
m = minute();
h = hour();
s = second();
//print("hour:" + h + " min: " + m + " sec: " + s);
//print(changeState);
//pull new data every 5 seconds
if (s % 5 === 0) {
loadJSON(url, gotData);
//print(gifs);
}
}
//when something happens, show a gif
//right now, testing with mouse clicks
function mouseReleased() {
removeElements();
img = createImg(random(gifs));
img.size(200, 200);
changeState = !changeState ;
}
//this function creates the array
function gotData(giphy) {
for (var i = 0; i < 10; i++) {
gifs = append(gifs, giphy.data[i].images.original.url);
}
}