Last active
July 22, 2020 03:30
-
-
Save enjalot/e31c7d8b66b62a64fcd0b7eb00cf1da8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
package-lock.json | |
output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { load } = require("@alex.garcia/observable-prerender"); | |
const puppeteer = require("puppeteer"); | |
async function main() { | |
// let mapWidth = 3840 | |
// let mapHeight = 2160 | |
let mapWidth = 1000 | |
let mapHeight = 750 | |
let startDate = "20200301" | |
// let signal = "confirmed_7dav_incidence_num" | |
// let signal = "part_time_work_prop" | |
// let signal = "smoothed_adj_covid19" | |
let signal = process.argv[2] || "confirmed_7dav_incidence_num" | |
const browser = await puppeteer.launch({ | |
defaultViewport: { width: mapWidth, height: mapHeight}, | |
args: [`--window-size=${mapWidth},${mapHeight}`], | |
}); | |
const notebook = await load( | |
"@codingwithfire/cmu-covidcast-api-map-maker", | |
["map"], | |
{ browser } | |
); | |
await notebook.redefine("date", startDate); | |
const days = await notebook.value("days"); | |
console.log("rendering signal", signal) | |
console.log("going to work on", days.length, "days") | |
let i = 0 | |
for await (let day of days) { | |
console.log("rendering", i, day) | |
await notebook.redefine("mapWidth", mapWidth); | |
await notebook.redefine("mapHeight", mapHeight); | |
await notebook.redefine("date", day); | |
await notebook.redefine("signal", signal); | |
await notebook.screenshot("map", `output/${signal}_${("000" + i).slice(-3)}.png`); | |
// await notebook.svg("map", `${county.name}.svg`); | |
i++ | |
} | |
console.log("FFMPEG COMMAND") | |
console.log(`ffmpeg -framerate 15 -i output/${signal}_%03d.png -c:v libx264 -pix_fmt yuv420p output/${signal}.mp4`) | |
await notebook.browser.close(); | |
} | |
main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "prerender", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@alex.garcia/observable-prerender": "0.0.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment