Skip to content

Commit

Permalink
feat: 修改印章保存绘制
Browse files Browse the repository at this point in the history
  • Loading branch information
xxss0903 committed Nov 24, 2024
1 parent 12f500a commit aaa84b1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/DrawStampTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export type IDrawStampConfig = {
primaryColor: string // 印章主色
refreshSecurityPattern: boolean // 是否刷新防伪纹路
refreshOld: boolean // 是否刷新做旧效果
shouldDrawRuler: boolean // 是否绘制标尺
innerCircle: IInnerCircle // 内圈圆
outThinCircle: IInnerCircle // 比外圈细的稍微内圈
openManualAging: boolean // 是否开启手动做旧效果
Expand Down
19 changes: 14 additions & 5 deletions src/DrawStampUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ export class DrawStampUtils {
refreshOld: false,
taxNumber: this.taxNumber,
agingEffect: this.agingEffect,
shouldDrawRuler: true,
innerCircle: this.innerCircle,
outThinCircle: this.outThinCircle,
openManualAging: false,
Expand Down Expand Up @@ -1224,7 +1223,12 @@ export class DrawStampUtils {
*/
saveStampAsPNG(outputSize: number = 512) {
// 首先隐藏虚线
this.drawStampConfigs.shouldDrawRuler = false
this.drawStampConfigs.ruler.showCrossLine = false
this.drawStampConfigs.ruler.showRuler = false
this.drawStampConfigs.ruler.showDashLine = false
this.drawStampConfigs.ruler.showSideRuler = false
this.drawStampConfigs.ruler.showFullRuler = false
this.drawStampConfigs.ruler.showCurrentPositionText = false
this.refreshStamp()
setTimeout(() => {
// 创建一个新的 canvas 元素,大小为 outputSize x outputSize
Expand All @@ -1237,7 +1241,7 @@ export class DrawStampUtils {
// 清除画布,使背景透明
saveCtx.clearRect(0, 0, outputSize, outputSize)

// 计算原始 canvas 中��章的位置和大小
// 计算原始 canvas 中印章的位置和大小
const originalStampSize =
(Math.max(this.drawStampConfigs.width, this.drawStampConfigs.height) + 2) * this.mmToPixel
const sourceX =
Expand Down Expand Up @@ -1278,8 +1282,13 @@ export class DrawStampUtils {
link.click()
document.body.removeChild(link)

// 首先隐藏虚线
this.drawStampConfigs.shouldDrawRuler = true
// 恢复标尺
this.drawStampConfigs.ruler.showCrossLine = true
this.drawStampConfigs.ruler.showRuler = true
this.drawStampConfigs.ruler.showDashLine = true
this.drawStampConfigs.ruler.showSideRuler = true
this.drawStampConfigs.ruler.showFullRuler = true
this.drawStampConfigs.ruler.showCurrentPositionText = true
this.refreshStamp()
}, 50)
}
Expand Down
2 changes: 1 addition & 1 deletion src/DrawStampUtilsDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="disclaimer-content">
<div class="warning-icon">⚠️</div>
<div class="warning-text">
<h3>安���警告</h3>
<h3>安全警告</h3>
<p><strong>本项目仅供学习和参考!严禁用于任何非法用途!</strong></p>
<p>
1. 本项目开源代码仅用于技术学习和交流。<br>
Expand Down
1 change: 0 additions & 1 deletion src/assets/templates/companyStamp1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,6 @@
"agingIntensity": 50,
"agingEffectParams": []
},
"shouldDrawRuler": true,
"innerCircle": {
"drawInnerCircle": true,
"innerCircleLineWidth": 0.5,
Expand Down
1 change: 0 additions & 1 deletion src/assets/templates/companyStamp2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,6 @@
"agingIntensity": 50,
"agingEffectParams": []
},
"shouldDrawRuler": true,
"innerCircle": {
"drawInnerCircle": true,
"innerCircleLineWidth": 0.5,
Expand Down

0 comments on commit aaa84b1

Please sign in to comment.