Skip to content

Commit

Permalink
Update DotTextCanvas.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Jan 22, 2024
1 parent a9c4c7e commit 187218e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/canvas/DotTextCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class DotTextCanvas {
textPointSet: Array<number[]> = []
status = 'pending'
container?: HTMLElement
stop: () => void = () => {}

constructor(
text: string,
fontSize: number,
Expand Down Expand Up @@ -100,7 +102,7 @@ export class DotTextCanvas {
}
})
}
useRic(tasks, {
this.stop = useRic(tasks, {
callback: () => (this.status = 'success'),
})
}
Expand All @@ -112,6 +114,7 @@ export class DotTextCanvas {
color: string,
fontWeight: number,
): DotTextCanvas {
this.stop()
const p = removeElement(this.canvas)
if (!p) {
throw new Error(
Expand All @@ -136,11 +139,16 @@ export class DotTextCanvas {
}

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 187218e

Please sign in to comment.