|
@@ -344,6 +344,17 @@ const drawElementOnCanvas = (
|
|
|
? renderConfig.imageCache.get(element.fileId)?.image
|
|
|
: undefined;
|
|
|
if (img != null && !(img instanceof Promise)) {
|
|
|
+ if (element.roundness && context.roundRect) {
|
|
|
+ context.beginPath();
|
|
|
+ context.roundRect(
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ element.width,
|
|
|
+ element.height,
|
|
|
+ getCornerRadius(Math.min(element.width, element.height), element),
|
|
|
+ );
|
|
|
+ context.clip();
|
|
|
+ }
|
|
|
context.drawImage(
|
|
|
img,
|
|
|
0 /* hardcoded for the selection box*/,
|
|
@@ -1301,6 +1312,31 @@ export const renderElementToSvg = (
|
|
|
}) rotate(${degree} ${cx} ${cy})`,
|
|
|
);
|
|
|
|
|
|
+ if (element.roundness) {
|
|
|
+ const clipPath = svgRoot.ownerDocument!.createElementNS(
|
|
|
+ SVG_NS,
|
|
|
+ "clipPath",
|
|
|
+ );
|
|
|
+ clipPath.id = `image-clipPath-${element.id}`;
|
|
|
+
|
|
|
+ const clipRect = svgRoot.ownerDocument!.createElementNS(
|
|
|
+ SVG_NS,
|
|
|
+ "rect",
|
|
|
+ );
|
|
|
+ const radius = getCornerRadius(
|
|
|
+ Math.min(element.width, element.height),
|
|
|
+ element,
|
|
|
+ );
|
|
|
+ clipRect.setAttribute("width", `${element.width}`);
|
|
|
+ clipRect.setAttribute("height", `${element.height}`);
|
|
|
+ clipRect.setAttribute("rx", `${radius}`);
|
|
|
+ clipRect.setAttribute("ry", `${radius}`);
|
|
|
+ clipPath.appendChild(clipRect);
|
|
|
+ addToRoot(clipPath, element);
|
|
|
+
|
|
|
+ g.setAttributeNS(SVG_NS, "clip-path", `url(#${clipPath.id})`);
|
|
|
+ }
|
|
|
+
|
|
|
const clipG = maybeWrapNodesInFrameClipPath(
|
|
|
element,
|
|
|
root,
|