xxxxxxxxxx
// inspired by https://openprocessing.org/sketch/1339639 and https://openprocessing.org/sketch/621245/
//if click, texts stops shaking
//leading cause of death in nyc in 2017
var APIURL = 'https://data.cityofnewyork.us/resource/jb7j-dtam.json';
var thestuff = {};
var isready = false;
var onOff
var fontsize = 18;
function preload() {
thestuff = loadJSON(APIURL, goforit);
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
stroke(0);
fill(0);
textSize(fontsize);
onOff=true
}
function draw() {
if(isready)
{
background('#A0A1FE');
if(onOff==true){
translate(random(-5,5),random(-5,5));
}
fill('#679436');
noStroke();
let y = fontsize;
for(let i =0;i<25;i++)
{
fill(255);
let s = '';
s+=thestuff[i].sex + ' : ';
s+=thestuff[i].leading_cause + ', ';
s+=thestuff[i].race_ethnicity + '!!!';
text(s, 20, y);
y+=fontsize;
fill(0,0,255);
let a = thestuff[i].year + ' ' + thestuff[i].deaths + ' ' ;
text(a, 40, y);
y+=fontsize;
}
}
}
function mousePressed(){
if(onOff==true){
onOff=false;
}else{
onOff=true;
}
}
function goforit() { // response function
isready = true;
console.log(thestuff);
}