Selaa lähdekoodia

feat: 水印大小调整

zhangjie 9 kuukautta sitten
vanhempi
commit
a44f505ced

+ 2 - 2
src/components/ImageWatermark.vue

@@ -64,7 +64,7 @@ export default {
     },
     drawWatermark(ctx, { width, height }) {
       const angle = (315 * Math.PI) / 180;
-      const fontSize = 100;
+      const fontSize = 50;
       ctx.font = `${fontSize}px serif`;
       ctx.fillStyle = "rgba(212,212,212,0.5)";
       ctx.textAlign = "center";
@@ -72,7 +72,7 @@ export default {
       // 获取内容的宽度
       const cInfo = ctx.measureText(this.content);
 
-      const spacing = [Math.max(500, width / 4), Math.max(500, height / 4)];
+      const spacing = [Math.max(300, width / 8), Math.max(300, height / 8)];
       const spaceWH = [cInfo.width + spacing[0], fontSize + spacing[1]];
       const spaceSize = Math.max(width, height);
       const wCount = Math.ceil(spaceSize / spaceWH[0]);

+ 3 - 3
src/modules/card/components/CardPreviewDialog.vue

@@ -76,10 +76,10 @@ export default {
       const canvas = document.createElement("canvas");
       const ctx = canvas.getContext("2d");
 
-      const fontSize = 100;
+      const fontSize = 40;
       ctx.font = `${fontSize}px serif`;
       const cInfo = ctx.measureText(content);
-      const cwidth = Math.max(600, cInfo.width) * 1.2;
+      const cwidth = Math.max(360, cInfo.width) * 1.2;
       canvas.width = cwidth;
       canvas.height = cwidth;
 
@@ -95,7 +95,7 @@ export default {
       ctx.rotate(angle);
       ctx.fillText(content, 0, 0);
 
-      const bgSize = 600;
+      const bgSize = 240;
 
       canvas.toBlob((val) => {
         if (!val) return;