@@ -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