qrterminal

package
v1.3.33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: Apache-2.0, MIT Imports: 3 Imported by: 0

README

QRCode Terminal

Build Status

A golang library for generating QR codes in the terminal.

Originally this was a port of the NodeJS version. Recently it's been updated to allow for smaller code generation using ASCII 'half blocks'

Example

Full size ASCII block QR Code:
alt text

Smaller 'half blocks' in the terminal:
alt text

Install

go get github.com/mdp/qrterminal

Usage

import (
    "github.com/mdp/qrterminal"
    "os"
    )

func main() {
  // Generate a 'dense' qrcode with the 'Low' level error correction and write it to Stdout
  qrterminal.Generate("https://github.com/mdp/qrterminal", qrterminal.L, os.Stdout)
}
More complicated

Large Inverted barcode with medium redundancy and a 1 pixel border

import (
    "github.com/mdp/qrterminal"
    "os"
    )

func main() {
  config := qrterminal.Config{
      Level: qrterminal.M,
      Writer: os.Stdout,
      BlackChar: qrterminal.WHITE,
      WhiteChar: qrterminal.BLACK,
      QuietZone: 1,
  }
  qrterminal.GenerateWithConfig("https://github.com/mdp/qrterminal", config)
}

HalfBlock barcode with medium redundancy

import (
    "github.com/mdp/qrterminal"
    "os"
    )

func main() {
  config := qrterminal.Config{
      HalfBlocks: true,
      Level: qrterminal.M,
      Writer: os.Stdout,
  }
  qrterminal.Generate("https://github.com/mdp/qrterminal", config)
}

Credits:

Mark Percival m@mdp.im
Matthew Kennerly
Viric
WindomZ
mattn

Documentation

Index

Constants

View Source
const BLACK = "\033[40m  \033[0m"
View Source
const BLACK_BLACK = " "
View Source
const BLACK_WHITE = "▄"

Use ascii blocks to form the QR Code

View Source
const H = qr.H

Level - the QR Code's redundancy level

View Source
const L = qr.L
View Source
const M = qr.M
View Source
const QUIET_ZONE = 4

default is 4-pixel-wide white quiet zone

View Source
const WHITE = "\033[47m  \033[0m"
View Source
const WHITE_BLACK = "▀"
View Source
const WHITE_WHITE = "█"

Variables

This section is empty.

Functions

func Generate

func Generate(text string, l qr.Level, w io.Writer)

Generate a QR Code and write it out to io.Writer

func GenerateHalfBlock

func GenerateHalfBlock(text string, l qr.Level, w io.Writer)

Generate a QR Code with half blocks and write it out to io.Writer

func GenerateWithConfig

func GenerateWithConfig(text string, config Config)

GenerateWithConfig expects a string to encode and a config

Types

type Config

type Config struct {
	Level          qr.Level
	Writer         io.Writer
	HalfBlocks     bool
	BlackChar      string
	BlackWhiteChar string
	WhiteChar      string
	WhiteBlackChar string
	QuietZone      int
}

Config for generating a barcode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL