1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-02 12:54:23 +02:00
This commit is contained in:
Pomax
2020-08-10 09:01:23 -07:00
parent 5e34074dc7
commit 28c9c9bd45
2 changed files with 5 additions and 4 deletions

View File

@@ -23,12 +23,13 @@ function generateGraphicsModule(code, width, height) {
const example = new Example(undefined, ${width}, ${height}, (w,h) => {
const canvas = CanvasBuilder.createCanvas(w,h);
const ctx = canvas.getContext('2d');
// as this is node-canvas, we need to shim some functions:
canvas.addEventListener = canvas.setAttribute = noop;
canvas.classList = { add: noop };
canvas.style = {};
const ctx = canvas.getContext('2d');
ctx.getTransform = () => ctx.currentTransform; // node-canvas lacks getTransform() support?
ctx.getTransform = () => ctx.currentTransform;
return { canvas, ctx};
});

View File

@@ -119,7 +119,7 @@ async function generateFallbackImage(src, width, height) {
const start = dataURI.indexOf(`base64,`) + 7;
const imageData = Buffer.from(dataURI.substring(start), `base64`);
fs.ensureDirSync(path.dirname(destPath));
fs.ensureDirSync(path.dirname(filename));
fs.writeFileSync(filename, imageData);
console.log(`Generated fallback image for ${src}`);