Skip to content

Commit

Permalink
Merge pull request latentcat#6 from gexin1/develop
Browse files Browse the repository at this point in the history
文件名字大小写问题
  • Loading branch information
gexin1 authored Jun 13, 2020
2 parents 34ed93b + f4616cb commit 453aa6b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/utils/renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export function createRenderer(renderer) {
const defaultViewBox = function (qrcode) {
if (!qrcode) return '0 0 0 0';

const nCount = qrcode.getModuleCount();
return (
String(-nCount / 5) +
' ' +
String(-nCount / 5) +
' ' +
String(nCount + (nCount / 5) * 2) +
' ' +
String(nCount + (nCount / 5) * 2)
);
};

renderer = {
...{
getViewBox: defaultViewBox,
listPoints: (qrcode, params) => {
return [];
},
getParamInfo: () => {
return [];
},
beginRendering: ({ qrcode, params, setParamInfo }) => {},
beforeListing: ({ qrcode, params, setParamInfo }) => {},
afterListing: ({ qrcode, params, setParamInfo }) => {},
},
...renderer,
};

return ({ qrcode, params }) => {
return `
<svg className="Qr-item-svg" width="100%" height="100%" viewBox="${renderer.getViewBox(
qrcode
)}" fill="white"
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
${renderer.listPoints(qrcode, params).join('')}
</svg>
`;
};
}

0 comments on commit 453aa6b

Please sign in to comment.