国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Web Front-end H5 Tutorial Pure JS QR code generation plug-in based on canvas

Pure JS QR code generation plug-in based on canvas

Jan 19, 2017 pm 01:44 PM

Brief Tutorial

qrious is a pure JS QR code generation plug-in based on HTML5 Canvas. Various QR codes can be quickly generated through qrious.js. You can control the size and color of the QR code, and you can also Base64 encode the generated QR code.

Installation

You can install the qrious.js QR code plug-in through bower or npm.

$ npm install --save qrious
$ bower install --save qrious

How to use

To use this QR code generation plug-in, you need to introduce the qrious.js file into the page.

<script type="text/javascript" src="js/qrious.js"></script>

HTML structure

Use a element as a container for QR code images.

<canvas id="qr"></canvas>

Initialization plug-in

You can instantiate an object instance through the QRious() method.

(function() {
  const qr = new QRious({
    element: document.getElementById(&#39;qr&#39;),
    value: &#39;http://www.htmleaf.com/&#39;
  })
})()

If you use it in Node.js, the code is as follows:

const express = require(&#39;express&#39;)
const QRious = require(&#39;qrious&#39;)
 
const app = express()
 
app.get(&#39;/qr&#39;, (req, res) => {
  const qr = new QRious({ value: &#39;http://www.htmleaf.com/&#39; })
 
  res.end(new Buffer(qr.toDataURL(), &#39;base64&#39;))
})
 
app.listen(3000)

Configuration parameters

The available configuration parameters of qrious.js QR code plug-in are as follows:

Pure JS QR code generation plug-in based on canvas

For example:

const qr = new QRious()
qr.background = &#39;#000&#39;
qr.foreground = &#39;#fff&#39;
qr.level = &#39;H&#39;
qr.size = 500
qr.value = &#39;http://www.htmleaf.com/&#39;

Or pass it in the constructor:

const qr = new QRious({
  background: &#39;#000&#39;,
  foreground: &#39;#fff&#39;,
  level: &#39;H&#39;,
  size: 500,
  value: &#39;http://www.htmleaf.com/&#39;
})

You can set the QR code used to generate the QR code in the element parameter DOM element. The DOM element must be a element or an Pure JS QR code generation plug-in based on canvas element.

const qr = new QRious({
  element: document.querySelector(&#39;canvas&#39;),
  value: &#39;http://www.htmleaf.com/&#39;
})
 
qr.canvas.parentNode.appendChild(qr.image)

toDataURL([mime]) method

The toDataURL([mime]) method can generate the URI of the Base64 encoded data of the QR code. If you do not specify a MIME Type, the default value will be used as the mime type.

const qr = new QRious({
  value: &#39;http://www.htmleaf.com/&#39;
})
 
console.log(qr.toDataURL())
//=> "data:image/png;base64,iVBOR...AIpqDnseH86KAAAAAElFTkSuQmCC"
console.log(qr.toDataURL(&#39;image/jpeg&#39;))
//=> "data:image/jpeg;base64,/9j/...xqAqIqgKFAAAAAq3RRQAUUUUAf/Z"

The above is the content. For more related content, please pay attention to the PHP Chinese website (www.miracleart.cn)!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How to create a QR code using wps How to create a QR code using wps Mar 28, 2024 am 09:41 AM

1. Open the software and enter the wps text operation interface. 2. Find the insert option in this interface. 3. Click the Insert option and find the QR code option in its editing tool area. 4. Click the QR code option to pop up the QR code dialog box. 5. Select the text option on the left and enter our information in the text box. 6. On the right side, you can set the shape of the QR code and the color of the QR code.

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ??and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

What should I do if the QR code on Enterprise WeChat cannot be loaded? What should I do if the QR code on Enterprise WeChat cannot be loaded? Mar 14, 2024 pm 10:46 PM

What should I do if the QR code on Enterprise WeChat cannot be loaded? What should we do when we find that the QR code cannot be loaded and cannot be displayed when logging into the computer version of Enterprise WeChat? Here, the editor will give you a detailed introduction to the solution to the problem that the QR code of Enterprise WeChat cannot be loaded. Anyone who needs it Friends, come and take a look! Method 1. Network reasons 1. The network speed may be slow, resulting in slow loading and failure to display. You can disconnect and reconnect. 2. Check the computer's own network problems to see if it is connected to the network. You can restart the network device. Method 2: Maintenance and update: The QR code may not be generated because the version of Enterprise WeChat is too low. You can upgrade the software to the latest version. Method three, firewall 1

Learn the canvas framework and explain the commonly used canvas framework in detail Learn the canvas framework and explain the commonly used canvas framework in detail Jan 17, 2024 am 11:03 AM

Explore the Canvas framework: To understand what are the commonly used Canvas frameworks, specific code examples are required. Introduction: Canvas is a drawing API provided in HTML5, through which we can achieve rich graphics and animation effects. In order to improve the efficiency and convenience of drawing, many developers have developed different Canvas frameworks. This article will introduce some commonly used Canvas frameworks and provide specific code examples to help readers gain a deeper understanding of how to use these frameworks. 1. EaselJS framework Ea

The relationship between js and vue The relationship between js and vue Mar 11, 2024 pm 05:21 PM

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Explore the powerful role and application of canvas in game development Explore the powerful role and application of canvas in game development Jan 17, 2024 am 11:00 AM

Understand the power and application of canvas in game development Overview: With the rapid development of Internet technology, web games are becoming more and more popular among players. As an important part of web game development, canvas technology has gradually emerged in game development, showing its powerful power and application. This article will introduce the potential of canvas in game development and demonstrate its application through specific code examples. 1. Introduction to canvas technology Canvas is a new element in HTML5, which allows us to use

How to open Tencent Video QR code How to open Tencent Video QR code Feb 24, 2024 am 08:37 AM

How to open the QR code of Tencent Video? There is an exclusive QR code for the login account in Tencent Video, but most users do not know how to open the QR code. Next, the editor brings users how to open the QR code of Tencent Video. Graphic tutorial, interested users come and take a look together! Tencent Video usage tutorial How to open Tencent Video QR code 1. First open the Tencent Video APP and click [Personal Center] at the bottom of the main page; 2. Then enter the Personal Center interface and select [Click to log in]; 3. Finally jump Come out of the small window and click the QR code button in the upper left corner to scan and log in.

Where is the QR code on DingTalk face-to-face_A list of steps to exchange QR code business cards face-to-face on DingTalk Where is the QR code on DingTalk face-to-face_A list of steps to exchange QR code business cards face-to-face on DingTalk Mar 29, 2024 pm 10:31 PM

1. Download the latest version of DingTalk. 2. Click the avatar in the upper left corner. 3. Click the avatar in the upper right corner. 4. Select the QR code business card. 5. Choose face-to-face exchange.

See all articles