Skip to content

Commit

Permalink
Update DotImageCanvas.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Jan 22, 2024
1 parent a225a5a commit a9c4c7e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/canvas/DotImageCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class DotImageCanvas {
fontWeight = 1
status = 'pending'
bgColor?: string
stop: () => void = () => {}
constructor(
src: string,
color: string,
Expand Down Expand Up @@ -94,8 +95,7 @@ export class DotImageCanvas {
async executor() {
try {
this.createImage()
}
catch (error) {}
} catch (error) {}
return this
}

Expand All @@ -120,7 +120,7 @@ export class DotImageCanvas {
}
})
}
useRic(tasks, {
this.stop = useRic(tasks, {
callback: () => {
this.status = 'success'
},
Expand All @@ -140,6 +140,7 @@ export class DotImageCanvas {
fontWeight: number,
bgColor = '#fff',
) {
this.stop()
const p = removeElement(this.canvas)
this.status = 'pending'
this.initOptions(src, color, fontWeight, bgColor)
Expand All @@ -155,11 +156,16 @@ export class DotImageCanvas {
}

clearCanvas() {
this.stop()
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
}

append(container: MaybeElement) {
insertElement(container, this.canvas)
return this
}
destory() {
this.stop()
removeElement(this.canvas)
}
}

0 comments on commit a9c4c7e

Please sign in to comment.