Selaa lähdekoodia

SVG export: add image size (#2292)

Geraint 4 vuotta sitten
vanhempi
commit
5c26bd19d7
2 muutettua tiedostoa jossa 5 lisäystä ja 0 poistoa
  1. 1 0
      src/data/index.ts
  2. 4 0
      src/scene/export.ts

+ 1 - 0
src/data/index.ts

@@ -302,6 +302,7 @@ export const exportCanvas = async (
       exportBackground,
       viewBackgroundColor,
       exportPadding,
+      scale,
       shouldAddWatermark,
       metadata:
         appState.exportEmbedScene && type === "svg"

+ 4 - 0
src/scene/export.ts

@@ -83,11 +83,13 @@ export const exportToSvg = (
     exportBackground,
     exportPadding = 10,
     viewBackgroundColor,
+    scale = 1,
     shouldAddWatermark,
     metadata = "",
   }: {
     exportBackground: boolean;
     exportPadding?: number;
+    scale?: number;
     viewBackgroundColor: string;
     shouldAddWatermark: boolean;
     metadata?: string;
@@ -106,6 +108,8 @@ export const exportToSvg = (
   svgRoot.setAttribute("version", "1.1");
   svgRoot.setAttribute("xmlns", SVG_NS);
   svgRoot.setAttribute("viewBox", `0 0 ${width} ${height}`);
+  svgRoot.setAttribute("width", `${width * scale}`);
+  svgRoot.setAttribute("height", `${height * scale}`);
 
   svgRoot.innerHTML = `
   ${SVG_EXPORT_TAG}