From 241eb0f109eea4592d2617b963e390e4fa8c9c5b Mon Sep 17 00:00:00 2001 From: alevikx <131615202+alevikx@users.noreply.github.com> Date: Wed, 5 Feb 2025 15:03:40 +0530 Subject: [PATCH] Update smooth-corners.js --- factors/smooth-corners.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/factors/smooth-corners.js b/factors/smooth-corners.js index 53dd0299..cb214018 100644 --- a/factors/smooth-corners.js +++ b/factors/smooth-corners.js @@ -4,19 +4,23 @@ class SmoothCorners { } paint(ctx, geom, properties) { - const radius = parseFloat(properties.get('--smooth-radius')) || 20; - const width = geom.width; - const height = geom.height; + try { + const radius = parseFloat(properties.get('--smooth-radius')) || 20; + const width = geom.width; + const height = geom.height; - ctx.fillStyle = 'black'; - ctx.beginPath(); - ctx.moveTo(radius, 0); - ctx.arcTo(width, 0, width, height, radius); - ctx.arcTo(width, height, 0, height, radius); - ctx.arcTo(0, height, 0, 0, radius); - ctx.arcTo(0, 0, width, 0, radius); - ctx.closePath(); - ctx.fill(); + ctx.fillStyle = 'black'; + ctx.beginPath(); + ctx.moveTo(radius, 0); + ctx.arcTo(width, 0, width, height, radius); + ctx.arcTo(width, height, 0, height, radius); + ctx.arcTo(0, height, 0, 0, radius); + ctx.arcTo(0, 0, width, 0, radius); + ctx.closePath(); + ctx.fill(); + } catch (error) { + console.error('SmoothCorners Paint API Error:', error); + } } }