Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

增加 shouldClearRect 配置,允许在绘制前不清空 canvas #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Component({
},
methods: {
async renderToCanvas(args) {
const {wxml, style} = args
const {wxml, style, shouldClearRect = true} = args
const ctx = this.ctx
const canvas = this.canvas
const use2dCanvas = this.data.use2dCanvas
Expand All @@ -56,7 +56,9 @@ Component({
return Promise.reject(new Error('renderToCanvas: fail canvas has not been created'))
}

ctx.clearRect(0, 0, this.data.width, this.data.height)
if (shouldClearRect) {
ctx.clearRect(0, 0, this.data.width, this.data.height)
}
const {root: xom} = xmlParse(wxml)

const widget = new Widget(xom, style)
Expand Down