mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-03 05:12:43 +02:00
.
This commit is contained in:
@@ -23,12 +23,13 @@ function generateGraphicsModule(code, width, height) {
|
|||||||
|
|
||||||
const example = new Example(undefined, ${width}, ${height}, (w,h) => {
|
const example = new Example(undefined, ${width}, ${height}, (w,h) => {
|
||||||
const canvas = CanvasBuilder.createCanvas(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.addEventListener = canvas.setAttribute = noop;
|
||||||
canvas.classList = { add: noop };
|
canvas.classList = { add: noop };
|
||||||
canvas.style = {};
|
canvas.style = {};
|
||||||
|
ctx.getTransform = () => ctx.currentTransform;
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
ctx.getTransform = () => ctx.currentTransform; // node-canvas lacks getTransform() support?
|
|
||||||
|
|
||||||
return { canvas, ctx};
|
return { canvas, ctx};
|
||||||
});
|
});
|
||||||
|
@@ -119,7 +119,7 @@ async function generateFallbackImage(src, width, height) {
|
|||||||
const start = dataURI.indexOf(`base64,`) + 7;
|
const start = dataURI.indexOf(`base64,`) + 7;
|
||||||
const imageData = Buffer.from(dataURI.substring(start), `base64`);
|
const imageData = Buffer.from(dataURI.substring(start), `base64`);
|
||||||
|
|
||||||
fs.ensureDirSync(path.dirname(destPath));
|
fs.ensureDirSync(path.dirname(filename));
|
||||||
fs.writeFileSync(filename, imageData);
|
fs.writeFileSync(filename, imageData);
|
||||||
console.log(`Generated fallback image for ${src}`);
|
console.log(`Generated fallback image for ${src}`);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user