parent
59fd84c94c
commit
bc0c8b2601
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,24 @@
|
||||
import { IEditorOption } from "../../interface/Editor"
|
||||
|
||||
export class Strikeout {
|
||||
|
||||
private ctx: CanvasRenderingContext2D
|
||||
private options: Required<IEditorOption>
|
||||
|
||||
constructor(ctx: CanvasRenderingContext2D, options: Required<IEditorOption>) {
|
||||
this.ctx = ctx
|
||||
this.options = options
|
||||
}
|
||||
|
||||
render(x: number, y: number, width: number) {
|
||||
const { strikeoutColor } = this.options
|
||||
this.ctx.save()
|
||||
this.ctx.strokeStyle = strikeoutColor
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(x, y)
|
||||
this.ctx.lineTo(x + width, y)
|
||||
this.ctx.stroke()
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { IEditorOption } from "../../interface/Editor"
|
||||
|
||||
export class Underline {
|
||||
|
||||
private ctx: CanvasRenderingContext2D
|
||||
private options: Required<IEditorOption>
|
||||
|
||||
constructor(ctx: CanvasRenderingContext2D, options: Required<IEditorOption>) {
|
||||
this.ctx = ctx
|
||||
this.options = options
|
||||
}
|
||||
|
||||
render(x: number, y: number, width: number) {
|
||||
const { underlineColor } = this.options
|
||||
this.ctx.save()
|
||||
this.ctx.strokeStyle = underlineColor
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(x, y)
|
||||
this.ctx.lineTo(x + width, y)
|
||||
this.ctx.stroke()
|
||||
this.ctx.restore()
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue