This commit is contained in:
zhbhun
2023-08-07 10:07:17 +08:00
committed by GitHub

View File

@@ -600,11 +600,20 @@ export class CanvasRenderer extends Renderer {
image.height, image.height,
image.width / image.height image.width / image.height
]); ]);
const pattern = this.ctx.createPattern( const scaleX = width / image.naturalWidth;
this.resizeImage(image, width, height), const scaleY = height / image.naturalHeight;
'repeat' const pattern = this.ctx.createPattern(image, 'repeat') as CanvasPattern;
) as CanvasPattern; const scaledPath = (path as Vector[]).map((item) => {
this.renderRepeat(path, pattern, x, y); item.x = item.x / scaleX;
item.y = item.y / scaleY;
return item;
});
const scaledOffsetX = x / scaleX;
const scaledOffsetY = y / scaleY;
this.ctx.save();
this.ctx.scale(scaleX, scaleY);
this.renderRepeat(scaledPath, pattern, scaledOffsetX, scaledOffsetY);
this.ctx.restore();
} }
} else if (isLinearGradient(backgroundImage)) { } else if (isLinearGradient(backgroundImage)) {
const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [null, null, null]); const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [null, null, null]);