feat: paper background color option

pr675
Hufe921 3 years ago
parent 291844fd7c
commit 46be700728

@ -27,6 +27,7 @@ interface IEditorOption {
height?: number // Paper height. default: 1123
scale?: number // scaling. default: 1
pageGap?: number // Paper spacing. default: 20
backgroundColor?: string // Paper background color. default: #FFFFFF
underlineColor?: string // Underline color. default: #000000
strikeoutColor?: string // Strikeout color. default: #FF0000
rangeColor?: string // Range color. default: #AECBFA

@ -27,6 +27,7 @@ interface IEditorOption {
height?: number // 纸张高度。默认1123
scale?: number // 缩放比例。默认1
pageGap?: number // 纸张间隔。默认20
backgroundColor?: string // 纸张背景色。默认:#FFFFFF
underlineColor?: string // 下划线颜色。默认:#000000
strikeoutColor?: string // 删除线颜色。默认:#FF0000
rangeColor?: string // 选区颜色。默认:#AECBFA

@ -1,17 +1,22 @@
import { DeepRequired } from '../../../interface/Common'
import { IEditorOption } from '../../../interface/Editor'
import { Draw } from '../Draw'
export class Background {
private draw: Draw
private options: DeepRequired<IEditorOption>
constructor(draw: Draw) {
this.draw = draw
this.options = draw.getOptions()
}
public render(ctx: CanvasRenderingContext2D, pageNo: number) {
const { backgroundColor } = this.options
const width = this.draw.getCanvasWidth(pageNo)
const height = this.draw.getCanvasHeight(pageNo)
ctx.save()
ctx.fillStyle = '#ffffff'
ctx.fillStyle = backgroundColor
ctx.fillRect(0, 0, width, height)
ctx.restore()
}

@ -140,6 +140,7 @@ export default class Editor {
height: 1123,
scale: 1,
pageGap: 20,
backgroundColor: '#FFFFFF',
underlineColor: '#000000',
strikeoutColor: '#FF0000',
rangeAlpha: 0.6,

@ -39,6 +39,7 @@ export interface IEditorOption {
height?: number
scale?: number
pageGap?: number
backgroundColor?: string
underlineColor?: string
strikeoutColor?: string
rangeColor?: string

Loading…
Cancel
Save