forked from latentcat/qrbtf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request latentcat#6 from gexin1/develop
文件名字大小写问题
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; | ||
}; | ||
} |