xxxxxxxxxx
96
let n = 10;
// 1/23 = 1, 2/1 = 10, 2/11 = 20, 2/21 = 30, 3/2 = 40
let virus;
let tp;
let tps;
// let input;
function preload() {
tp = loadImage('TP.png');
tps = loadImage('TP98.png');
}
function setup() {
createCanvas(400, 400);
loadJSON("https://pomber.github.io/covid19/timeseries.json", gotData);
// input = select('#number');
// n = input.value();
}
function gotData(data) {
date = (data.US[n].date);
virus = (data.US[n].confirmed);
// print(data);
}
function draw() {
background(0);
for (let i = 0; i < virus; i++) {
fill(255, 0, 0);
textSize(15);
text("Date: " + (date), 15, 380);
text("Confirmed Cases: " + (virus), 240, 380);
}
// // 1/23
// toiletPaper(-50, 30);
// 2/1
for (let x = -50; x < width; x = x + 80) {
toiletPaper(x, 30);
}
for (let x = 110; x < width; x = x + 80) {
toiletPaper(x, 100);
}
// // 2/11
// for (let x = -50; x < width; x = x + 80) {
// toiletPaper(x, 30);
// }
// for (let x = -50; x < width; x = x + 80) {
// toiletPaper(x, 100);
// }
// for (let x = 190; x < width; x = x + 80) {
// toiletPaper(x, 170);
// }
// // 2/21
// for (let x = -50; x < width; x = x + 80) {
// toiletPaper(x, 30);
// }
// for (let x = -50; x < width; x = x + 80) {
// toiletPaper(x, 100);
// }
// for (let x = -50; x < width; x = x + 80) {
// toiletPaper(x, 170);
// }
// // 3/2
// toiletPapers(-30, -20);
}
function toiletPaper(x, y) {
push();
translate(width / 10, height / 10)
image(tp, x , y, 100, 100);
pop();
}
function toiletPapers(x, y) {
push();
translate(width / 10, height / 10)
image(tps, x , y, 380, 320);
pop();
}
//The Coding Train tuts
//JSON - https://www.youtube.com/watch?v=6mT3r8Qn1VY
//API Query - https://www.youtube.com/watch?v=4UoUqnjUC2c
//Data from https://github.com/pomber/covid19