qrsart

0.3.1 • Public • Published

Logo

qrsart

generate QR codes with aesthetic precision


Benefits:

  • No dependencies
  • Optimal data segmentation
  • Labeled grid output
  • Built-in permutation logic
  • Isomorphic: Works in browser / NodeJS / Bun

Drawbacks:

  • No kanji support
  • API not final (just getting started)
  • Not perf optimized (yet)

Install

bun install qrsart

Usage

import { createQR } from 'qrsart'

let qr = createQR('HTTPS://GITHUB.COM/m4r-sh/qrsart',{
  minVersion: 2, // 1 - 40
  minEcl: 'medium', // 'low','medium','quartile','high'
  mask: 0, // 0 - 7
})

console.log(qr)

// QRCode {
//   version: 3,
//   ecl: "quartile",
//   mask: 0,
//   data: "HTTPS://GITHUB.COM/m4r-sh/qrsart",
//   size: 29,
//   bitstring: "001000...110000",
//   functional_grid: PixelGrid,
//   finder_grid: PixelGrid,
//   timing_grid: PixelGrid,
//   alignment_positions: PixelGrid,
//   alignment_grid: PixelGrid,
//   format_grid: PixelGrid,
//   version_grid: PixelGrid,
//   data_grid: PixelGrid,
//   grid: PixelGrid,
// }

To see an image generation example, check out examples

API

createQR(data, options)

Returns: QRCode

Creates a QRCode object which can be used in custom render logic

data

Type: String

The raw text to be encoded into the QR Code

options

Type: Object

  • minVersion: number (0 - 40)
  • maxVersion: number (0 - 40)
  • mask: number (0 - 8)
  • minEcl: string ('low' | 'medium' | 'quartile' | 'high')

PixelGrid(w,h)

Helper class for 2D matrix of pixels

  • .setPixel(x,y,v)
  • .getPixel(x,y)
  • .usedPixel(x,y)
  • PixelGrid.combine(...grids)

QRCode({ bitstring, version, ecl, mask, data })

Helper class for QR Code data

  • .size
  • .data
  • .grid
  • .data_grid
  • .functional_grid
  • .finder_grid
  • .alignment_grid
  • .timing_grid
  • .format_grid
  • .version_grid

permuteURL(url, options)

Returns: [String]

Permutes a URL into an array of all possible variations of the same URL.

url

Type: String

A URL, i.e. https://github.com/m4r-sh or m4r.sh

options

Type: Object

Options for URL variation. Caps options permute the substring into every possible uppercase/lowercase combination.

  • protocols: ['http','https']
  • protocol_caps: true
  • domain_caps: true
  • path_caps: false

permuteWIFI(name, pwd)

Returns: [String]

Permutes a WiFi name/pwd into an array of all possible encoding orders.

name

Type: String

The name of the WiFi network

pwd

Type: String

The password of the WiFi network

Examples

Tetromino Shape Packing

Example Code

Debug View

Example Code

Tilted WiFi

Example Code

Credits

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i qrsart

    Weekly Downloads

    1

    Version

    0.3.1

    License

    none

    Unpacked Size

    60.8 kB

    Total Files

    21

    Last publish

    Collaborators

    • m4rsh