xxxxxxxxxx
//Data taken from NYC Dog Licensing open dataset
//Will present the name of a dog that has gotten its license!
var APIurl = 'https://data.cityofnewyork.us/resource/nu7n-tubp.json'
var dogdata = {};
var dogimage;
var x, y;
var i;
function preload() {
dogimage = loadImage('dogs.jpg');
dogdata = loadJSON(APIurl);
}
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(15);
background(dogimage);
i = int(random(10));
textAlign(CENTER); textSize(50); textFont('Georgia');
text('OFFICIAL DOG LICENSE OF: ', 400, 80);
fill(random(255), random(255), random(255));
}
function update(){ //new text color, update index
background(dogimage);
text('OFFICIAL DOG LICENSE OF: ', 400, 80);
fill(random(255), random(255), random(255));
i++;
}
function draw() {
text(dogdata[i].animalname, 900, 80);
licenseInfo('Breed Name: ', 'Gender: ', 'Borough: ', 'ZIP: ', dogdata[i].breedname, dogdata[i].animalgender, dogdata[i].borough, dogdata[i].zipcode, 800, 200);
}
function licenseInfo(title1, title2, title3, title4, data1, data2, data3, data4, hShift, vShift){
text(title1 + data1, hShift, vShift);
text(title2 + data2, hShift, vShift+50);
text(title3 + data3, hShift, vShift+100);
text(title4 + data4, hShift, vShift+150);
}
function keyTyped() {
if (key == ' ') {
update();
}
}