Skip to content

Image in QRCode #4

Answered by codemasher
aSamu3l asked this question in Q&A
May 12, 2024 · 1 comments · 12 replies
Discussion options

You must be logged in to vote

You'll add the image after rendering - it has nothing to do with the QRcode at all.

// set options
let options = new qrc.QROptions({
	outputInterface   : qrc.QRMarkupSVG,
	returnAsDomElement: true,
	// ... more options ...
});

// render qrcode
let qrcodeElement = (new qrc.QRCode(options)).render(data); // returns a SVG DOM element


// modify the SVG element (nothing of the following has to do anything with the qrcode library)

// create a container to move and scale the logo
let g = document.createElement('g');

// the hard part: math! aka, calculate the proportions of the logo 
// and its position with respect to the supposed output
g.transform = 'translate(16.875 16.875) scale(0.25)'; /…

Replies: 1 comment 12 replies

Comment options

You must be logged in to vote
12 replies
@aSamu3l
Comment options

@codemasher
Comment options

@aSamu3l
Comment options

@codemasher
Comment options

Answer selected by aSamu3l
@aSamu3l
Comment options

@codemasher
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants