From 6aaff4cb855c933ca902589cc546ede3ece49eb2 Mon Sep 17 00:00:00 2001
From: CPunisher <1343316114@qq.com>
Date: Tue, 5 May 2020 10:33:20 +0800
Subject: [PATCH] Fix rand rect display bug
---
src/components/QrRendererRandRect.js | 18 +++++++++++-------
src/utils/util.js | 12 ++----------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/src/components/QrRendererRandRect.js b/src/components/QrRendererRandRect.js
index 4e796cf..d17377c 100644
--- a/src/components/QrRendererRandRect.js
+++ b/src/components/QrRendererRandRect.js
@@ -23,13 +23,17 @@ function listPoint(props) {
for (let i = 0; i < randArr.length; i++) {
let row = randArr[i][0];
let col = randArr[i][1];
- if (qrcode.isDark(row, col)) {
- let tempRand = rand(0.8, 1.3);
- let tempRGB = randRGB();
- let width = 0.15;
- pointList.push();
- pointList.push();
- }
+ if (qrcode.isDark(row, col)) {
+ let tempRand = rand(0.8, 1.3);
+ let randNum = rand(50,230);
+ let tempRGB = [
+ 'rgb(' + Math.floor(20 + randNum) + ',' + Math.floor(170 - randNum / 2) + ',' + Math.floor(60 + randNum * 2) + ')',
+ 'rgb(' + Math.floor(-20 + randNum) + ',' + Math.floor(130 - randNum / 2) + ',' + Math.floor(20 + randNum * 2) + ')'
+ ];
+ let width = 0.15;
+ pointList.push();
+ pointList.push();
+ }
}
return pointList;
}
diff --git a/src/utils/util.js b/src/utils/util.js
index 3e78309..de6357f 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -9,16 +9,8 @@ export function rand(min, max) {
return min + (seed / 233280.0) * (max - min);
}
-export function randRGB() {
- let randNum = rand(50,230);
- let rgb = [];
- rgb.push(
- 'rgb(' + String(20 + randNum) + ',' + String(170 - randNum / 2) + ',' + String(60 + randNum * 2) + ')'
- )
- rgb.push(
- 'rgb(' + String(-20 + randNum) + ',' + String(130 - randNum / 2) + ',' + String(20 + randNum * 2) + ')'
- )
- return rgb;
+export function randRGB(minR, maxR, minG, maxG, minB, maxB) {
+ return 'rgb(' + parseInt(minR, maxR) + ',' + parseInt(minG, maxG) + ',' + parseInt(minB, maxB) + ')';
}
export function isWeiXin(){