feat: paper background color option
This commit is contained in:
@@ -27,6 +27,7 @@ interface IEditorOption {
|
|||||||
height?: number // Paper height. default: 1123
|
height?: number // Paper height. default: 1123
|
||||||
scale?: number // scaling. default: 1
|
scale?: number // scaling. default: 1
|
||||||
pageGap?: number // Paper spacing. default: 20
|
pageGap?: number // Paper spacing. default: 20
|
||||||
|
backgroundColor?: string // Paper background color. default: #FFFFFF
|
||||||
underlineColor?: string // Underline color. default: #000000
|
underlineColor?: string // Underline color. default: #000000
|
||||||
strikeoutColor?: string // Strikeout color. default: #FF0000
|
strikeoutColor?: string // Strikeout color. default: #FF0000
|
||||||
rangeColor?: string // Range color. default: #AECBFA
|
rangeColor?: string // Range color. default: #AECBFA
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ interface IEditorOption {
|
|||||||
height?: number // 纸张高度。默认:1123
|
height?: number // 纸张高度。默认:1123
|
||||||
scale?: number // 缩放比例。默认:1
|
scale?: number // 缩放比例。默认:1
|
||||||
pageGap?: number // 纸张间隔。默认:20
|
pageGap?: number // 纸张间隔。默认:20
|
||||||
|
backgroundColor?: string // 纸张背景色。默认:#FFFFFF
|
||||||
underlineColor?: string // 下划线颜色。默认:#000000
|
underlineColor?: string // 下划线颜色。默认:#000000
|
||||||
strikeoutColor?: string // 删除线颜色。默认:#FF0000
|
strikeoutColor?: string // 删除线颜色。默认:#FF0000
|
||||||
rangeColor?: string // 选区颜色。默认:#AECBFA
|
rangeColor?: string // 选区颜色。默认:#AECBFA
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
|
import { DeepRequired } from '../../../interface/Common'
|
||||||
|
import { IEditorOption } from '../../../interface/Editor'
|
||||||
import { Draw } from '../Draw'
|
import { Draw } from '../Draw'
|
||||||
|
|
||||||
export class Background {
|
export class Background {
|
||||||
private draw: Draw
|
private draw: Draw
|
||||||
|
private options: DeepRequired<IEditorOption>
|
||||||
|
|
||||||
constructor(draw: Draw) {
|
constructor(draw: Draw) {
|
||||||
this.draw = draw
|
this.draw = draw
|
||||||
|
this.options = draw.getOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(ctx: CanvasRenderingContext2D, pageNo: number) {
|
public render(ctx: CanvasRenderingContext2D, pageNo: number) {
|
||||||
|
const { backgroundColor } = this.options
|
||||||
const width = this.draw.getCanvasWidth(pageNo)
|
const width = this.draw.getCanvasWidth(pageNo)
|
||||||
const height = this.draw.getCanvasHeight(pageNo)
|
const height = this.draw.getCanvasHeight(pageNo)
|
||||||
ctx.save()
|
ctx.save()
|
||||||
ctx.fillStyle = '#ffffff'
|
ctx.fillStyle = backgroundColor
|
||||||
ctx.fillRect(0, 0, width, height)
|
ctx.fillRect(0, 0, width, height)
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export default class Editor {
|
|||||||
height: 1123,
|
height: 1123,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
pageGap: 20,
|
pageGap: 20,
|
||||||
|
backgroundColor: '#FFFFFF',
|
||||||
underlineColor: '#000000',
|
underlineColor: '#000000',
|
||||||
strikeoutColor: '#FF0000',
|
strikeoutColor: '#FF0000',
|
||||||
rangeAlpha: 0.6,
|
rangeAlpha: 0.6,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export interface IEditorOption {
|
|||||||
height?: number
|
height?: number
|
||||||
scale?: number
|
scale?: number
|
||||||
pageGap?: number
|
pageGap?: number
|
||||||
|
backgroundColor?: string
|
||||||
underlineColor?: string
|
underlineColor?: string
|
||||||
strikeoutColor?: string
|
strikeoutColor?: string
|
||||||
rangeColor?: string
|
rangeColor?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user