Skip to content

Commit fc4e278

Browse files
committed
Merge tag '5.0.4' into develop
Release 5.0.4
2 parents 1983e7a + 3948cfe commit fc4e278

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-qrcode-svg",
3-
"version": "5.0.3",
3+
"version": "5.0.4",
44
"description": "A QR Code generator for React Native based on react-native-svg and javascript-qrcode.",
55
"main": "index.js",
66
"scripts": {

src/index.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,29 @@ export default class QRCode extends PureComponent {
6060
setMatrix (props) {
6161
const { value, size, ecl } = props
6262
this._matrix = genMatrix(value, ecl)
63-
this._cellSize = size / (this._matrix.length + 2)
63+
this._cellSize = size / this._matrix.length
6464
this._path = this.transformMatrixIntoPath()
6565
}
6666
/* project the matrix into path draw */
6767
transformMatrixIntoPath () {
6868
const matrix = this._matrix
6969
const cellSize = this._cellSize
7070
// adjust origin
71-
const oY = cellSize * 1.5
72-
const oX = cellSize
7371
let d = ''
7472
matrix.forEach((row, i) => {
7573
let needDraw = false
7674
row.forEach((column, j) => {
7775
if (column) {
7876
if (!needDraw) {
79-
d += `M${oX + cellSize * j} ${oY + cellSize * i} `
77+
d += `M${cellSize * j} ${cellSize / 2 + cellSize * i} `
8078
needDraw = true
8179
}
8280
if (needDraw && j === matrix.length - 1) {
83-
d += `L${oX + cellSize * (j + 1)} ${oY + cellSize * i} `
81+
d += `L${cellSize * (j + 1)} ${cellSize / 2 + cellSize * i} `
8482
}
8583
} else {
8684
if (needDraw) {
87-
d += `L${oX + cellSize * j} ${oY + cellSize * i} `
85+
d += `L${cellSize * j} ${cellSize / 2 + cellSize * i} `
8886
needDraw = false
8987
}
9088
}
@@ -133,10 +131,8 @@ export default class QRCode extends PureComponent {
133131
<View>
134132
<Svg ref={getRef} width={size} height={size}>
135133
<Rect
136-
x={this._cellSize}
137-
y={this._cellSize}
138-
width={size - 2 * this._cellSize}
139-
height={size - 2 * this._cellSize}
134+
width={size}
135+
height={size}
140136
fill={backgroundColor}
141137
/>
142138
<Path

0 commit comments

Comments
 (0)