From bcaf750a740cda4e4f3cf5db34d32caf76321bbd Mon Sep 17 00:00:00 2001 From: personal82555 Date: Mon, 12 Oct 2026 21:45:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8D=B0=E7=AB=A0=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8=E6=96=B0=E5=A2=9E=E4=B8=89=E7=A7=8D=E6=95=88=E6=9E=9C?= =?UTF-8?q?=20=E2=80=94=20=E9=98=B2=E4=BC=AA=E7=BA=B9=E8=B7=AF(=E5=90=8C?= =?UTF-8?q?=E5=BF=83=E7=BB=86=E7=BA=BF+=E5=A4=96=E5=9C=88=E6=94=BE?= =?UTF-8?q?=E5=B0=84=E7=BA=BF,source-atop=E4=BB=85=E5=A2=A8=E5=8C=BA),=20?= =?UTF-8?q?=E6=AF=9B=E8=BE=B9(=E8=BD=AE=E5=BB=93=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E6=92=95=E8=A3=82),=20=E5=81=9A=E6=97=A7(=E6=96=91=E9=A9=B3?= =?UTF-8?q?=E7=A3=A8=E6=8D=9F),=20=E5=8F=AF=E5=A4=9A=E9=80=89=E5=8F=A0?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tools/seal-maker/seal-maker.vue | 137 ++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/tools/seal-maker/seal-maker.vue b/src/tools/seal-maker/seal-maker.vue index 94c0483..d052cf3 100644 --- a/src/tools/seal-maker/seal-maker.vue +++ b/src/tools/seal-maker/seal-maker.vue @@ -10,6 +10,10 @@ const genHist = useGenHistory('seal-maker'); // ============ 印章参数 ============ const style = ref<'circle-star' | 'circle-text'>('circle-star'); +// 效果(可叠加) +const effectPattern = ref(false); // 防伪纹路 +const effectFrayed = ref(false); // 毛边 +const effectAged = ref(false); // 做旧 const mainText = ref('在线工具大全示例专用章'); const subText = ref('合同专用章'); const sealSize = ref(300); @@ -128,6 +132,86 @@ function renderSeal() { ctx.restore(); } + // ---- 防伪纹路:只在有墨区域叠加同心细线 + 外圈放射短线 ---- + if (effectPattern.value) { + ctx.save(); + ctx.globalCompositeOperation = 'source-atop'; + ctx.strokeStyle = 'rgba(0,0,0,0.15)'; + ctx.lineWidth = Math.max(0.6, size * 0.003); + const gap = Math.max(3, size * 0.014); + for (let rr = gap; rr < Rr; rr += gap) { + ctx.beginPath(); + ctx.arc(cx, cy, rr, 0, Math.PI * 2); + ctx.stroke(); + } + // 外圈放射状防伪短线 + const spokes = 96; + ctx.beginPath(); + for (let i = 0; i < spokes; i++) { + const a = (i / spokes) * Math.PI * 2; + const r0 = Rr * 0.9; + const r1 = Rr * 0.985; + ctx.moveTo(cx + Math.cos(a) * r0, cy + Math.sin(a) * r0); + ctx.lineTo(cx + Math.cos(a) * r1, cy + Math.sin(a) * r1); + } + ctx.stroke(); + ctx.restore(); + } + + // ---- 毛边效果:沿外轮廓与文字边缘随机撕裂缺口 ---- + if (effectFrayed.value) { + ctx.save(); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'black'; + // 外圆轮廓毛刺 + const nEdge = Math.round(size / 4); + for (let i = 0; i < nEdge; i++) { + const a = Math.random() * Math.PI * 2; + const rr = Rr + (Math.random() - 0.5) * ringW * 1.8; + const sz = 0.6 + Math.random() * (size * 0.011); + ctx.beginPath(); + ctx.arc(cx + Math.cos(a) * rr, cy + Math.sin(a) * rr, sz, 0, Math.PI * 2); + ctx.fill(); + } + // 文字环带毛刺 + const nText = Math.round(size / 6); + for (let i = 0; i < nText; i++) { + const a = Math.random() * Math.PI * 2; + const rr = Rr * 0.76 + (Math.random() - 0.5) * fontPx * 1.2; + ctx.beginPath(); + ctx.arc(cx + Math.cos(a) * rr, cy + Math.sin(a) * rr, 0.5 + Math.random() * (size * 0.006), 0, Math.PI * 2); + ctx.fill(); + } + ctx.restore(); + } + + // ---- 做旧效果:全局斑驳磨损(墨色不均 + 随机磨损块) ---- + if (effectAged.value) { + ctx.save(); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'black'; + const dots = Math.round((size * size) / 500); + for (let i = 0; i < dots; i++) { + const x = Math.random() * size; + const y = Math.random() * size; + const sz = 0.4 + Math.random() * 1.6; + ctx.globalAlpha = 0.25 + Math.random() * 0.75; + ctx.beginPath(); + ctx.arc(x, y, sz, 0, Math.PI * 2); + ctx.fill(); + } + const patches = Math.round(size / 25); + for (let i = 0; i < patches; i++) { + const x = Math.random() * size; + const y = Math.random() * size; + ctx.globalAlpha = 0.12 + Math.random() * 0.38; + ctx.beginPath(); + ctx.arc(x, y, 1 + Math.random() * size * 0.02, 0, Math.PI * 2); + ctx.fill(); + } + ctx.restore(); + } + sealDataUrl.value = c.toDataURL('image/png'); const b64 = sealDataUrl.value.split(',')[1]; const bin = atob(b64); @@ -153,6 +237,9 @@ function resetSeal() { sealSize.value = 300; color.value = '#E60012'; invert.value = false; + effectPattern.value = false; + effectFrayed.value = false; + effectAged.value = false; renderSeal(); } @@ -406,6 +493,13 @@ onMounted(() => {
⚙️ 印章参数
+ +
+ + + +
+