feat: paper background color option
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user