oblakstudio / qr-code-styling Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Type of qr-code must be "svg". For "canvas" type works correctly.
Moreover, settings of one reflects on another.
For this code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QR Code Styling</title>
<script type="text/javascript" src="https://unpkg.com/[email protected]/lib/qr-code-styling.js"></script>
</head>
<body>
<div id="qr_1" style="display: inline;"></div>
<div id="qr_2" style="display: inline;"></div>
<script type="text/javascript">
const qrCode1 = new QRCodeStyling({
width: 300,
height: 300,
type: "svg",
data: "https://www.facebook.com/",
image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
dotsOptions: {
color: "#4267b2",
type: "rounded"
},
backgroundOptions: {
color: "#e9ebee",
},
imageOptions: {
crossOrigin: "anonymous",
margin: 20
}
});
const qrCode2 = new QRCodeStyling({
width: 290,
height: 290,
type: "svg",
data: "https://www.google.com/",
dotsOptions: {
color: "#4267b2",
type: "rounded"
},
backgroundOptions: {
color: "#e9ebee",
},
imageOptions: {
crossOrigin: "anonymous",
margin: 20
}
});
qrCode1.append(document.getElementById("qr_1"));
qrCode2.append(document.getElementById("qr_2"));
//qrCode.download({ name: "qr", extension: "svg" });
</script>
</body>
</html>
After zooming the page, SVG style has spaces between the dots
The documentation says that qr-code-styling/lib/qr-code-styling.common.js should be referenced but that file does not exists.
When trying to use it from server it says
Error: Cannot find module 'qr-code-styling/lib/qr-code-styling.common.js'
and when i substitute this reference
const { QRCodeStyling } = require("qr-code-styling/lib/qr-code-styling.common.js");
for this
const { QRCodeStyling } = require("qr-code-styling/lib/qr-code-styling.js");
it says
ReferenceError: self is not defined
at Object. (C:\www\qrGenerator\node\node_modules\qr-code-styling\lib\qr-code-styling.js:1:208)
Hi,
first thing first, thanks for the library!
Now, about the feature request, would it be possible to allow the user to add some text around the QR-Code ?
I would be interested by something looking like that:
If adding such a feature wouldn't respect the scope of the library, then a simple margin around the QR-Code would be enough, as it would allow user to add manually the text with something like this:
// var ctx = $0.getContext("2d"); //getting the canvas context in the debugger
ctx.font = "30px Arial";
ctx.fillText("Hello World", 100, 100);
What do you think about this idea ?
I'm trying to use the library in my custom element like this:
const qrCode = new QRCodeStyling({
width: 300,
height: 300,
//type: "svg",
data: "https://www.facebook.com/",
image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
dotsOptions: {
color: "#4267b2",
type: "rounded"
},
backgroundOptions: {
color: "#e9ebee",
},
imageOptions: {
crossOrigin: "anonymous",
margin: 20
}
});
let canvas = document.createElement('canvas');
this.append(canvas);
qrCode.append(canvas);
But the canvas remains empty. What's going wrong?
It would be great if this library could generate code with some more code styles like on this website https://www.qrcode-monkey.com/
I can try to add these styles, but I don't have the free time right now... :c
Hey, just wanted to try this library with Node according to the readme, yet the build doesn't seem to accommodate this option, i'm I right or am I missing something? Thanks
Hi there!
For my project I just need the svg string generated using QRCodeStyling
instance. For now I am using the append method and extracting the svg string from a virtual element.
const qrCode = new QRCodeStyling(options)
const container = document.createElement('div')
qrCode.append(container)
const svg = container.innerHTML
I was wondering if there was a more elegant way of doing this?
I have a responsive design, the size of the canvas where I want to show the QR code can vary. How to I make the QR code the same size as the canvas.
I've tried setting the width and height to:
Has anybody another suggestion?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.