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(() => {