So I wanted to make an animation of code being written in the minimap, so I set up VS Code so that it would write the minimap canvas to a PNG file every time there's a backspace (play that in reverse and you have typing out a file).
var fs = require('fs')
var curFrame = 0;
function saveCallback() {
// Get the DataUrl from the Canvas
const url = document.querySelectorAll('canvas')[1].toDataURL();
// remove Base64 stuff from the Image
const base64Data = url.replace(/^data:image\/png;base64,/, "");
fs.writeFile('E:/Desktop/codeframes/'+curFrame + '.png', base64Data, 'base64', function (err) {
console.log(err);
});
curFrame++;
}
let backspaceCallback = (e) => {
/*
* keyCode: 8
* keyIdentifier: "U+0008"
*/
if(e.keyCode === 8 && document.activeElement !== 'text') {
e.preventDefault();
console.log('backspace ' + curFrame);
saveCallback();
}
};
window.addEventListener("keydown", backspaceCallback);