From 4a668c427eca4d0d3945c656b3f16cc3c04f42fb Mon Sep 17 00:00:00 2001 From: ciaochaos <1272777550@qq.com> Date: Wed, 24 Jun 2020 11:56:01 +0800 Subject: [PATCH] =?UTF-8?q?A=20=E2=80=94=20a=20=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/renderer/RendererLine.js | 55 +++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/src/components/renderer/RendererLine.js b/src/components/renderer/RendererLine.js index 52241bb..a01917d 100644 --- a/src/components/renderer/RendererLine.js +++ b/src/components/renderer/RendererLine.js @@ -163,6 +163,52 @@ function listPoints(qrcode, params) { } if (type === 3) { + if (x > y ^ x + y < nCount) { + if (y === 0 || (y > 0 && (!qrcode.isDark(x, y - 1) || !ava2[x][y - 1]))) { + let start = 0; + let end = 0; + let ctn = true; + while (ctn && y + end < nCount) { + if (qrcode.isDark(x, y + end) && ava2[x][y + end] && end - start <=3) { + end++; + } else { + ctn = false; + } + } + if (end - start > 1) { + for (let i = start; i < end; i++) { + ava2[x][y + i] = false; + available[x][y + i] = false; + } + pointList.push() + } + } + } else { + if (x === 0 || (x > 0 && (!qrcode.isDark(x - 1, y) || !ava2[x - 1][y]))) { + let start = 0; + let end = 0; + let ctn = true; + while (ctn && x + end < nCount) { + if (qrcode.isDark(x + end, y) && ava2[x + end][y] && end - start <=3) { + end++; + } else { + ctn = false; + } + } + if (end - start > 1) { + for (let i = start; i < end; i++) { + ava2[x + i][y] = false; + available[x + i][y] = false; + } + pointList.push() + } + } + } + if (available[x][y]) { + pointList.push() + } + } + if (type === 4) { if (y === 0 || x === 0 || ((y > 0 && x > 0) && (!qrcode.isDark(x - 1, y - 1) || !ava2[x - 1][y - 1]))) { let start = 0; let end = 0; @@ -186,8 +232,7 @@ function listPoints(qrcode, params) { pointList.push() } } - - if (type === 4) { + if (type === 5) { if (x === 0 || y === nCount - 1 || ((x > 0 && y < nCount - 1) && (!qrcode.isDark(x - 1, y + 1) || !ava2[x - 1][y + 1]))) { let start = 0; let end = 0; @@ -211,7 +256,7 @@ function listPoints(qrcode, params) { pointList.push() } } - if (type === 5) { + if (type === 6) { if (x === 0 || y === nCount - 1 || ((x > 0 && y < nCount - 1) && (!qrcode.isDark(x - 1, y + 1) || !ava2[x - 1][y + 1]))) { let start = 0; let end = 0; @@ -267,6 +312,7 @@ function getParamInfoLine() { "左右", "上下", "纵横", + "回环", "左上 — 右下", "右上 — 左下", "交叉" @@ -311,11 +357,12 @@ function getParamInfoLine2() { { type: ParamTypes.SELECTOR, key: '连线方向', - default: 5, + default: 6, choices: [ "左右", "上下", "纵横", + "回环", "左上 — 右下", "右上 — 左下", "交叉"