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); this._doClip(this.data.borderRadius, width, height);
if (!bg) { if (!bg) {
// 如果未设置背景,则默认使用 // 如果未设置背景,则默认使用透明
this.ctx.fillStyle = '#fff'; this.ctx.fillStyle = 'transparent';
this.ctx.fillRect(-(width / 2), -(height / 2), width, height); this.ctx.fillRect(-(width / 2), -(height / 2), width, height);
} else if (bg.startsWith('#') || bg.startsWith('rgba') || bg.toLowerCase() === 'transparent') { } else if (bg.startsWith('#') || bg.startsWith('rgba') || bg.toLowerCase() === 'transparent') {
// 背景填充颜色 // 背景填充颜色

View File

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

View File

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