From 3e54220e038edec925689f8858eadc386301c77b Mon Sep 17 00:00:00 2001 From: ciaochaos <1272777550@qq.com> Date: Tue, 5 May 2020 15:11:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B0=E5=AF=8C=20base=20=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/QrRendererBase.js | 78 ++++++++++++++++++++++++-------- src/components/Qrcode.css | 5 ++ 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/components/QrRendererBase.js b/src/components/QrRendererBase.js index c43d9da..97bf7ee 100644 --- a/src/components/QrRendererBase.js +++ b/src/components/QrRendererBase.js @@ -1,29 +1,57 @@ import React from "react"; import './Qrcode.css' +import {getTypeTable, QRPointType} from "../utils/qrcodeHandler"; +import {rand} from "../utils/util"; function listPoint(props) { if (!props.qrcode) return [] const qrcode = props.qrcode; const nCount = qrcode.getModuleCount(); + const typeTable = getTypeTable(qrcode); const pointList = new Array(nCount); - let type = props.params[1]; - let size = props.params[0] / 100; + let type = props.params[0]; + let size = props.params[1] / 100; + let opacity = props.params[2] / 100; + let posType = props.params[3]; let id = 0; + console.log(posType) if (size <= 0) size = 1.0 - for (let row = 0; row < nCount; row++) { - for (let col = 0; col < nCount; col++) { - if (qrcode.isDark(row, col)) { + for (let x = 0; x < nCount; x++) { + for (let y = 0; y < nCount; y++) { + if (qrcode.isDark(x, y) == false) continue; + + if (typeTable[x][y] == QRPointType.ALIGN_CENTER || typeTable[x][y] == QRPointType.ALIGN_OTHER || typeTable[x][y] == QRPointType.TIMING) { if (type == 0) - pointList.push() + pointList.push() else if (type == 1) - pointList.push() + pointList.push() + } + else if (typeTable[x][y] == QRPointType.POS_CENTER) { + if (posType == 0) { + pointList.push(); + } else if (posType == 1) { + pointList.push() + pointList.push() + } + } + else if (typeTable[x][y] == QRPointType.POS_OTHER) { + if (posType == 0) { + pointList.push(); + } + } + else { + if (type == 0) + pointList.push() + else if (type == 1) + pointList.push() } } } + return pointList; } @@ -39,18 +67,30 @@ class QrRendererBase extends React.Component { super(props); if (this.props.setParamInfo) { this.props.setParamInfo([ - { - key: '大小', - default: 100 - }, - { - key: '定位点样式', - default: 0, - choices: [ - "矩形", - "圆形" - ] - } + { + key: '信息点样式', + default: 0, + choices: [ + "矩形", + "圆形" + ] + }, + { + key: '信息点缩放', + default: 100 + }, + { + key: '信息点不透明度', + default: 100, + }, + { + key: '定位点样式', + default: 0, + choices: [ + "矩形", + "圆形" + ] + }, ] ); } diff --git a/src/components/Qrcode.css b/src/components/Qrcode.css index c9e227e..407b3a6 100644 --- a/src/components/Qrcode.css +++ b/src/components/Qrcode.css @@ -384,4 +384,9 @@ a:hover { color: #1D1D1F; font-size: 14px; } +} + +select { + padding: 0; + background-color: #FFFFFF; } \ No newline at end of file