Skip to content

AI-native design editor. Open-source Figma alternative.

fix(canvas): shadow filled geometry shapes

Danila Poyarkov37acb2597750
diff --git a/packages/core/src/canvas/scene.ts b/packages/core/src/canvas/scene.ts
index e31b1ba2d..5d1cf7e60 100644
--- a/packages/core/src/canvas/scene.ts
+++ b/packages/core/src/canvas/scene.ts
@@ -283,7 +283,7 @@ export function renderShape(
* Returns the child to use for shadow shape, or null to use the node itself.
*/
function getShadowShapeChild(node: SceneNode, graph: SceneGraph): SceneNode | null {
- if (node.fills.some((f) => f.visible)) return null
+ if (node.fills.some((f) => f.visible) || node.fillGeometry.length > 0) return null
if (node.childIds.length === 0) return null
const child = graph.getNode(node.childIds[0])
if (!child?.visible) return null
diff --git a/packages/core/src/canvas/shadows.ts b/packages/core/src/canvas/shadows.ts
index e8a1a6304..04490ac8a 100644
--- a/packages/core/src/canvas/shadows.ts
+++ b/packages/core/src/canvas/shadows.ts
@@ -46,10 +46,12 @@ function drawShapeDropShadow(
const sp = effect.spread
const shapeNode = shadowShapeChild ?? node
const shapeHasRadius = shadowShapeChild ? nodeHasRadius(shadowShapeChild) : hasRadius
- const strokeShadow =
- !shadowShapeChild && !node.fills.some((fill) => fill.visible) && node.strokeGeometry.length > 0
- ? r.getStrokeGeometry(node)
- : null
+ const geometryShadow = !shadowShapeChild
+ ? r.getFillGeometry(node) ??
+ (!node.fills.some((fill) => fill.visible) && node.strokeGeometry.length > 0
+ ? r.getStrokeGeometry(node)
+ : null)
+ : null
r.auxFill.setColor(r.color4f(effect.color.r, effect.color.g, effect.color.b, effect.color.a))
r.auxFill.setMaskFilter(r.getCachedMaskBlur(effect.radius / 2))
@@ -59,8 +61,8 @@ function drawShapeDropShadow(
if (shadowShapeChild) drawChildTransform(canvas, shadowShapeChild, effect.offset)
else canvas.translate(effect.offset.x, effect.offset.y)
- if (strokeShadow) {
- for (const path of strokeShadow) canvas.drawPath(path, r.auxFill)
+ if (geometryShadow) {
+ for (const path of geometryShadow) canvas.drawPath(path, r.auxFill)
} else if (shapeNode.type === 'ELLIPSE') {
canvas.drawOval(r.ltrb(-sp, -sp, shapeNode.width + sp, shapeNode.height + sp), r.auxFill)
} else if (shapeHasRadius) {