From 36ce87fe209b7064021e93ea15e08ddcc30f796b Mon Sep 17 00:00:00 2001 From: dongqing Date: Wed, 4 Dec 2019 14:48:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9A=B4=E9=9C=B2palette=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pen.js | 2 +- painter.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pen.js b/lib/pen.js index 4bfed02..47f8c1f 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -547,7 +547,7 @@ export default class Painter { } let lineIndex = 0; for (let j = 0; j < textArray.length; ++j) { - const preLineLength = Math.floor(textArray[j].length / linesArray[j]); + const preLineLength = Math.ceil(textArray[j].length / linesArray[j]); let start = 0; let alreadyCount = 0; for (let i = 0; i < linesArray[j]; ++i) { diff --git a/painter.js b/painter.js index e24902c..3a73580 100644 --- a/painter.js +++ b/painter.js @@ -630,7 +630,9 @@ Component({ this.bottomContext || (this.bottomContext = wx.createCanvasContext('bottom', this)); this.topContext || (this.topContext = wx.createCanvasContext('top', this)); this.globalContext || (this.globalContext = wx.createCanvasContext('k-canvas', this)); - new Pen(this.bottomContext, palette).paint(); + new Pen(this.bottomContext, palette).paint(() => { + this.triggerEvent('didShow'); + }); new Pen(this.globalContext, { width, height, From 045bc344b8605fbd49ad32a333148c324c122def Mon Sep 17 00:00:00 2001 From: dongqing Date: Wed, 4 Dec 2019 19:58:59 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20android=20=E6=9C=BA=E5=9E=8B?= =?UTF-8?q?=E4=B8=8A=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- painter.js | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/painter.js b/painter.js index 3a73580..ab6c2f1 100644 --- a/painter.js +++ b/painter.js @@ -84,7 +84,9 @@ Component({ observer: function (needClear) { if (needClear && !this.needClear) { if (this.frontContext) { - this.frontContext.draw() + setTimeout(() => { + this.frontContext.draw(); + }, 100); this.touchedView = {}; this.prevFindedIndex = this.findedIndex this.findedIndex = -1; @@ -296,8 +298,8 @@ Component({ height: this.currentPalette.height, views: this.isEmpty(doView) ? [] : [doView] } - const pen = new Pen(this.globalContext, draw); + if (isMoving && doView.type === 'text') { pen.paint((callbackInfo) => { callback && callback(callbackInfo); @@ -306,6 +308,9 @@ Component({ }); }, true, this.movingCache); } else { + // 某些机型(华为 P20)只绘制一遍会偶然性没法展示,目前采用再绘一遍的方法,次方法加上后,没法针对半透明场景,会导致叠加增强 + // 后续找到原因 + pen.paint() pen.paint((callbackInfo) => { callback && callback(callbackInfo); this.triggerEvent('viewUpdate', { @@ -313,11 +318,13 @@ Component({ }); }) } + const { rect, css, type } = doView + this.block = { width: this.currentPalette.width, height: this.currentPalette.height, @@ -419,13 +426,7 @@ Component({ } if (this.findedIndex < 0 || (this.touchedView && !this.touchedView.id)) { // 证明点击了背景 或无法移动的view - const block = { - width: this.currentPalette.width, - height: this.currentPalette.height, - views: [] - } - const topBlock = new Pen(this.frontContext, block) - topBlock.paint(); + this.frontContext.draw(); if (isDelete) { this.triggerEvent('touchEnd', { view: this.currentPalette.views[deleteIndex], @@ -439,7 +440,7 @@ Component({ this.findedIndex = -1 this.prevFindedIndex = -1 } else if (this.touchedView && this.touchedView.id) { - this.sliceLayers() + this.sliceLayers(); } }, @@ -611,7 +612,6 @@ Component({ initDancePalette() { this.initScreenK(); - this.downloadImages(this.properties.dancePalette).then((palette) => { this.currentPalette = palette const { @@ -633,21 +633,9 @@ Component({ new Pen(this.bottomContext, palette).paint(() => { this.triggerEvent('didShow'); }); - new Pen(this.globalContext, { - width, - height, - views: [] - }).paint(); - new Pen(this.frontContext, { - width, - height, - views: [] - }).paint(); - new Pen(this.topContext, { - width, - height, - views: [] - }).paint(); + this.globalContext.draw(); + this.frontContext.draw(); + this.topContext.draw(); }); this.touchedView = {}; }, @@ -838,4 +826,4 @@ function setStringPrototype(screenK, scale) { } return res; }; -} \ No newline at end of file +} From e6f7c54e97bac6ac167a38fd8efa5f8f7ce1978b Mon Sep 17 00:00:00 2001 From: dongqing Date: Wed, 4 Dec 2019 20:39:58 +0800 Subject: [PATCH 3/4] fix --- painter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/painter.js b/painter.js index ab6c2f1..05c3ff3 100644 --- a/painter.js +++ b/painter.js @@ -247,7 +247,7 @@ Component({ const doView = this.touchedView - if (!doView) { + if (!doView || this.isEmpty(doView)) { return } if (newVal && newVal.css) { @@ -268,7 +268,9 @@ Component({ } if (newVal && newVal.url && doView.url && newVal.url !== doView.url) { downloader.download(newVal.url, this.properties.LRU).then((path) => { - doView.originUrl = newVal.url + if (newVal.url.startsWidth('https')) { + doView.originUrl = newVal.url + } doView.url = path; wx.getImageInfo({ src: path, From e5bcc32b90b0a9dc25253b6babd9743a257724af Mon Sep 17 00:00:00 2001 From: dongqing Date: Thu, 5 Dec 2019 09:35:58 +0800 Subject: [PATCH 4/4] fix --- painter.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/painter.js b/painter.js index 05c3ff3..5caa934 100644 --- a/painter.js +++ b/painter.js @@ -310,9 +310,10 @@ Component({ }); }, true, this.movingCache); } else { - // 某些机型(华为 P20)只绘制一遍会偶然性没法展示,目前采用再绘一遍的方法,次方法加上后,没法针对半透明场景,会导致叠加增强 - // 后续找到原因 - pen.paint() + // 某些机型(华为 P20)非移动场景下,只绘制一遍会偶然性图片绘制失败,目前采用再绘一遍的方法 + if (!isMoving && doView.type === 'image') { + pen.paint() + } pen.paint((callbackInfo) => { callback && callback(callbackInfo); this.triggerEvent('viewUpdate', {