This commit is contained in:
CPPAlien 2019-11-13 19:03:20 +08:00
parent fcac5386e0
commit 34c16e8a36
3 changed files with 22 additions and 11 deletions

View File

@ -34,8 +34,8 @@ export default class Painter {
this._doClip(this.data.borderRadius, width, height);
if (!bg) {
// 如果未设置背景,则默认使用
this.ctx.fillStyle = '#fff';
// 如果未设置背景,则默认使用透明
this.ctx.fillStyle = 'transparent';
this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
} else if (bg.startsWith('#') || bg.startsWith('rgba') || bg.toLowerCase() === 'transparent') {
// 背景填充颜色

View File

@ -130,17 +130,22 @@ Component({
background: this.currentPalette.background,
views: bottomLayers
}
new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint();
const topDraw = {
width: this.currentPalette.width,
height: this.currentPalette.height,
views: topLayers
}
new Pen(wx.createCanvasContext('top', this), topDraw).paint();
if (this.prevFindedIndex < findedIndex) {
new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint();
new Pen(wx.createCanvasContext('top', this), topDraw).paint();
} else {
new Pen(wx.createCanvasContext('top', this), topDraw).paint();
new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint();
}
this.doAction()
}
this.prevFindedIndex = findedIndex
},
onTouchEnd() {

View File

@ -1,6 +1,12 @@
<canvas canvas-id="k-canvas"
style="{{painterStyle}}{{customStyle}}"
bindtouchstart="onTouchStart"
bindtouchmove="onTouchMove"
bindtouchend="onTouchEnd"
bindtouchcancel="onTouchCancel"/>
<view style='position: relative;{{painterStyle}}{{customStyle}}'>
<canvas canvas-id="bottom" style="{{painterStyle}};position: absolute;" />
<canvas canvas-id="k-canvas" style="{{painterStyle}};position: absolute;" />
<canvas
canvas-id="top"
style="{{painterStyle}};position: absolute;"
bindtouchstart="onTouchStart"
bindtouchmove="onTouchMove"
bindtouchend="onTouchEnd"
bindtouchcancel="onTouchCancel"
disable-scroll="{{true}}" />
</view>