From 7676112445d9e3eeaaae67af116fa858e6ec6eb2 Mon Sep 17 00:00:00 2001 From: MoyuScript 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(); } }