0.0.4 • Published 5 months ago
jsqrgb v0.0.4
jsQRGB
Introduction
A javascript package for generating and recognizing QRGB codes.
QRGB code is an extension of the traditional QR code. It distributes data across three color channels (Red, Green, and Blue) to achieve the goal of storing more information within the same number of pixels compared to a standard QR code.
A demo of QRGB code:
Warning
- The QRGB code generated by the jsQRGB package is not compatible with traditional QR codes.
Installation
Install using npm:
npm install jsqrgb
Usage
import jsQRGB from "jsqrgb";
async function main() {
// Recognize QRGB code
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')!;
const imgData = ctx.getImageData(0, 0, frame.displayWidth, frame.displayHeight)
const data = jsQRGB.recognize(imgData);
// async
const data = await jsQRGB.recognizeAsync(imgData);
// Generate QRGB code
const data = 'Hello World';
const qrgbImageData = jsQRGB.generate(textEncoder.encode(data), {
size: canvasSize,
});
// async
const qrgbImageData = await jsQRGB.generateAsync(textEncoder.encode(data), {
size: canvasSize,
});
}