Merge branch 'arnost/export-image-background' of github.com:excalidraw/excalidraw into arnost/export-image-background

This commit is contained in:
Arnošt Pleskot 2023-09-08 00:20:47 +02:00
commit d80d81cc61
No known key found for this signature in database

View File

@ -291,8 +291,31 @@ const addImageBackgroundToSvg = async ({
fancyBackgroundImage.setAttribute("filter", IMAGE_INVERT_FILTER);
}
svgRoot.appendChild(fancyBackgroundImage);
const clipRect = svgRoot.ownerDocument!.createElementNS(SVG_NS, "rect");
clipRect.setAttribute("x", "0");
clipRect.setAttribute("y", "0");
clipRect.setAttribute("width", `${dimensions.width}`);
clipRect.setAttribute("height", `${dimensions.height}`);
clipRect.setAttribute("rx", FANCY_BG_BORDER_RADIUS.toString());
clipRect.setAttribute("ry", FANCY_BG_BORDER_RADIUS.toString());
const clipPath = svgRoot.ownerDocument!.createElementNS(SVG_NS, "clipPath");
clipPath.setAttribute("id", "fancyBackgroundImageClipPath");
clipPath.appendChild(clipRect);
clipRect.setAttribute("preserveAspectRatio", "xMidYMid slice");
const fancyBgGroup = svgRoot.ownerDocument!.createElementNS(SVG_NS, "g");
fancyBgGroup.setAttributeNS(
SVG_NS,
"clip-path",
`url(#fancyBackgroundImageClipPath)`,
);
fancyBgGroup.appendChild(fancyBackgroundImage);
svgRoot.appendChild(clipPath);
svgRoot.appendChild(fancyBgGroup);
};
const addContentBackgroundToSvg = ({
svgRoot,
contentSize,