0.1.3 • Published 1 year ago

@yishiashia/wasm-qrcode v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

wasm-qrcode

A QR Code WebAssembly library implemented with Rust.

Methods

qrcode(data: string, width: number, height: number)

Generate the SVG format QR Code image with the given data and image widht/height.

qrcode_base64(data: string, width: number, height: number)

Generate a base64 encoded SVG QR Code image with the given data and image widht/height.

Example

import * as wasm from "wasm-qrcode";

window.onload = function() {
  const qr_b64img = wasm.qrcode_base64(
    "https://github.com/yishiashia",
    36, 36
  );
  const img = document.createElement('img');

  img.src = `data:image/svg+xml;base64,${qr_b64img}`;
  img.alt = "QR Code";
  img.style.width = "100px";
  img.style.height = "100px";

  document.body.append(img);
}