This commit is contained in:
zhbhun 2023-08-07 10:07:17 +08:00 committed by GitHub
commit 1966b2ebc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,11 +600,20 @@ export class CanvasRenderer extends Renderer {
image.height,
image.width / image.height
]);
const pattern = this.ctx.createPattern(
this.resizeImage(image, width, height),
'repeat'
) as CanvasPattern;
this.renderRepeat(path, pattern, x, y);
const scaleX = width / image.naturalWidth;
const scaleY = height / image.naturalHeight;
const pattern = this.ctx.createPattern(image, 'repeat') as CanvasPattern;
const scaledPath = (path as Vector[]).map((item) => {
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)) {
const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [null, null, null]);