From d46dd1477b3e7f7e1df34f8faa6724cb184ca018 Mon Sep 17 00:00:00 2001 From: "yuqi.pyq" Date: Thu, 23 May 2024 13:44:33 +0800 Subject: [PATCH] fix: render correctly in canvas when stroke is empty #1616 --- .../g-plugin-canvas-renderer/src/shapes/styles/Default.ts | 6 +++--- .../src/CanvaskitRendererPlugin.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/g-plugin-canvas-renderer/src/shapes/styles/Default.ts b/packages/g-plugin-canvas-renderer/src/shapes/styles/Default.ts index 7d5898c3a..243cbc193 100644 --- a/packages/g-plugin-canvas-renderer/src/shapes/styles/Default.ts +++ b/packages/g-plugin-canvas-renderer/src/shapes/styles/Default.ts @@ -43,9 +43,9 @@ export class DefaultRenderer implements StyleRenderer { filter, miterLimit, } = parsedStyle; - const hasFill = !isNil(fill) && !(fill as CSSRGB).isNone; - const hasStroke = - !isNil(stroke) && !(stroke as CSSRGB).isNone && lineWidth > 0; + const hasFill = fill && !(fill as CSSRGB).isNone; + const hasStroke = stroke && !(stroke as CSSRGB).isNone && lineWidth > 0; + const isFillTransparent = (fill as CSSRGB)?.alpha === 0; const hasFilter = !!(filter && filter.length); const hasShadow = !isNil(shadowColor) && shadowBlur > 0; diff --git a/packages/g-plugin-canvaskit-renderer/src/CanvaskitRendererPlugin.ts b/packages/g-plugin-canvaskit-renderer/src/CanvaskitRendererPlugin.ts index f37618251..695665bc0 100644 --- a/packages/g-plugin-canvaskit-renderer/src/CanvaskitRendererPlugin.ts +++ b/packages/g-plugin-canvaskit-renderer/src/CanvaskitRendererPlugin.ts @@ -565,9 +565,9 @@ export class CanvaskitRendererPlugin implements RenderingPlugin { canvas.rotate(rot, 0, 0); canvas.scale(sx, sy); - const hasFill = !isNil(fill) && !(fill as CSSRGB).isNone; - const hasStroke = !isNil(stroke) && !(stroke as CSSRGB).isNone; - const hasShadow = !isNil(shadowColor) && shadowBlur > 0; + const hasFill = fill && !(fill as CSSRGB).isNone; + const hasStroke = stroke && !(stroke as CSSRGB).isNone; + const hasShadow = shadowColor && shadowBlur > 0; let fillPaint: Paint = null; let strokePaint: Paint = null;