From ad1119a76c743e241bbc13e14c17cf0cc639dce4 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 3 Aug 2017 21:05:17 +0800 Subject: [PATCH] Apply border radius correctly on image elements --- src/CanvasRenderer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CanvasRenderer.js b/src/CanvasRenderer.js index 1b6d890..82124b2 100644 --- a/src/CanvasRenderer.js +++ b/src/CanvasRenderer.js @@ -88,7 +88,9 @@ export default class CanvasRenderer { ); const width = typeof image.width === 'number' ? image.width : contentBox.width; const height = typeof image.height === 'number' ? image.height : contentBox.height; - + this.ctx.save(); + this.path(calculatePaddingBoxPath(container.curvedBounds)); + this.ctx.clip(); this.ctx.drawImage( image, 0, @@ -100,6 +102,7 @@ export default class CanvasRenderer { contentBox.width, contentBox.height ); + this.ctx.restore(); } }