fix(canvas-renderer): verify image width and height

fix #1859
This commit is contained in:
xiaoyao 2021-01-07 15:25:36 +08:00
parent 7222aba1b4
commit 105ca4598c

View File

@ -561,11 +561,14 @@ export class CanvasRenderer {
image.height,
image.width / image.height
]);
const pattern = this.ctx.createPattern(
if( width > 0 && height > 0) {
const pattern = this.ctx.createPattern(
this.resizeImage(image, width, height),
'repeat'
) as CanvasPattern;
this.renderRepeat(path, pattern, x, y);
) as CanvasPattern;
this.renderRepeat(path, pattern, x, y);
}
}
} else if (isLinearGradient(backgroundImage)) {
const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [null, null, null]);