Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix: rounded left and top clipped image export to SVG (#10387)

zsvicziand7e63e66a78f
diff --git a/packages/excalidraw/renderer/staticSvgScene.ts b/packages/excalidraw/renderer/staticSvgScene.ts
index 89af1dc724..2983112499 100644
--- a/packages/excalidraw/renderer/staticSvgScene.ts
+++ b/packages/excalidraw/renderer/staticSvgScene.ts
@@ -541,7 +541,7 @@ const renderElementToSvg = (
"clipPath",
);
clipPath.id = `image-clipPath-${element.id}`;
-
+ clipPath.setAttribute("clipPathUnits", "userSpaceOnUse");
const clipRect = svgRoot.ownerDocument!.createElementNS(
SVG_NS,
"rect",
@@ -550,6 +550,10 @@ const renderElementToSvg = (
Math.min(element.width, element.height),
element,
);
+ const clipOffsetX = element.crop ? normalizedCropX : 0;
+ const clipOffsetY = element.crop ? normalizedCropY : 0;
+ clipRect.setAttribute("x", `${clipOffsetX}`);
+ clipRect.setAttribute("y", `${clipOffsetY}`);
clipRect.setAttribute("width", `${element.width}`);
clipRect.setAttribute("height", `${element.height}`);
clipRect.setAttribute("rx", `${radius}`);