import React, { useEffect } from "react"; import {defaultViewBox, rand} from "../../utils/util"; import {ParamTypes} from "../../constant/ParamTypes"; import {getTypeTable, QRPointType} from "../../utils/qrcodeHandler"; function listPoints(qrcode, params) { if (!qrcode) return [] const nCount = qrcode.getModuleCount(); const typeTable = getTypeTable(qrcode); const pointList = new Array(nCount); let type = params[0]; let size = params[1] / 100; let opacity = params[2] / 100; let posType = params[3]; let id = 0; let otherColor = params[4]; let posColor = params[5]; const vw = [3, -3]; const vh = [3, -3]; if (size <= 0) size = 1.0 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() else if (type == 1) pointList.push() else if (type == 2) 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 (posType == 2) { pointList.push() pointList.push() for (let w = 0; w < vw.length; w++) { pointList.push() } for (let h = 0; h < vh.length; h++) { 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() else if (type == 2) pointList.push() } } } return pointList; } function getParamInfo() { return [ { type: ParamTypes.SELECTOR, key: '信息点样式', default: 0, choices: [ "矩形", "圆形", "随机" ] }, { type: ParamTypes.TEXT_EDITOR, key: '信息点缩放', default: 100 }, { type: ParamTypes.TEXT_EDITOR, key: '信息点不透明度', default: 100, }, { type: ParamTypes.SELECTOR, key: '定位点样式', default: 0, choices: [ "矩形", "圆形", "行星", ] }, { type: ParamTypes.COLOR_EDITOR, key: '信息点颜色', default: '#000000' }, { type: ParamTypes.COLOR_EDITOR, key: '定位点点颜色', default: '#000000' } ]; } const RendererBase = ({ qrcode, params, setParamInfo}) => { useEffect(() => { setParamInfo(getParamInfo()); }, [setParamInfo]); return ( {listPoints(qrcode, params)} ) } export default RendererBase