From 64298fb4c45aa93f49ba08ef7c46695bd9210d0a Mon Sep 17 00:00:00 2001 From: dingziqi Date: Mon, 24 Jan 2022 09:33:17 +0800 Subject: [PATCH] feature: add new props highDefiniton for hd display --- lib/QRCode.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/QRCode.js b/lib/QRCode.js index 7471f47..a918968 100644 --- a/lib/QRCode.js +++ b/lib/QRCode.js @@ -16,6 +16,7 @@ function renderCanvas(canvas) { var bgColor = this.bgColor; canvas.width = size; canvas.height = size; + canvas.style.zoom = 1 / this.highDefinition; canvas.style.left = (window.innerWidth - size) / 2 + 'px'; if(window.innerHeight > size) canvas.style.top = (window.innerHeight - size) / 2 + 'px'; ctx.fillRect(0, 0, size, size); @@ -55,6 +56,7 @@ var QRCode = createReactClass({ fgColor: PropTypes.string, onLoad: PropTypes.func, onLoadEnd: PropTypes.func, + highDefinition: PropTypes.number, }, getDefaultProps: function() { @@ -65,6 +67,7 @@ var QRCode = createReactClass({ size: 128, onLoad: () => {}, onLoadEnd: () => {}, + highDefinition: 1, } }, @@ -95,11 +98,12 @@ var QRCode = createReactClass({