Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Commit

Permalink
add logo to qrcode
Browse files Browse the repository at this point in the history
  • Loading branch information
cssivision authored and scmx committed May 26, 2017
1 parent 5c11504 commit ea1c2d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/index.js
Expand Up @@ -31,6 +31,7 @@ type Props = {
level: $Keys<typeof ErrorCorrectLevel>,
bgColor: string,
fgColor: string,
logo: string,
};

class QRCode extends React.Component {
Expand Down Expand Up @@ -106,6 +107,19 @@ class QRCode extends React.Component {
);
});
});

if (this.props.logo) {
var size = this.props.size;
var image = document.createElement('img');
image.src = this.props.logo;
image.onload = function() {
var dx = size / 2 - size * 0.1;
var dwidth = size * 0.2;
if (ctx) {
ctx.drawImage(image, dx, dx, dwidth, dwidth);
}
};
}
}
}

Expand Down

0 comments on commit ea1c2d3

Please sign in to comment.