feat: paper background color option

This commit is contained in:
Hufe921
2023-09-17 20:33:24 +08:00
parent 291844fd7c
commit 46be700728
5 changed files with 10 additions and 1 deletions
+6 -1
View File
@@ -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()
}
+1
View File
@@ -140,6 +140,7 @@ export default class Editor {
height: 1123,
scale: 1,
pageGap: 20,
backgroundColor: '#FFFFFF',
underlineColor: '#000000',
strikeoutColor: '#FF0000',
rangeAlpha: 0.6,
+1
View File
@@ -39,6 +39,7 @@ export interface IEditorOption {
height?: number
scale?: number
pageGap?: number
backgroundColor?: string
underlineColor?: string
strikeoutColor?: string
rangeColor?: string