polishedqr

package module
v0.0.0-...-86454ad Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 10 Imported by: 0

README

polishedqr

A CLI and library for creating and reading QR codes written from scratch in Go

Install as CLI

go install github.com/superkooks/polishedqr/cmd/polishedqr@latest

Use as library

import "github.com/superkooks/polishedqr"

Documentation

Index

Constants

View Source
const (
	Numeric = iota
	Alphanumeric
	Bytes
)

Variables

View Source
var BLACK = color.RGBA{0, 0, 0, 255}
View Source
var BLUE = color.RGBA{0, 0, 255, 255}
View Source
var GREEN = color.RGBA{0, 255, 0, 255}
View Source
var Masks = []func(int, int) bool{mask1, mask2, mask3, mask4, mask5, mask6, mask7, mask8}
View Source
var RED = color.RGBA{255, 0, 0, 255}
View Source
var WHITE = color.RGBA{255, 255, 255, 255}

Functions

func CharacterCountBitCapacity

func CharacterCountBitCapacity(mode CharacterSet, version int) (bitCapacity int)

func CreateQRCode

func CreateQRCode(data []byte, opts *CreateOptions) *image.RGBA

Create a qr code from data with options, which may be nil. Data that is numeric or alphanumeric should be passed in their ascii form

Types

type Bits

type Bits []uint8

func CharacterCount

func CharacterCount(count int, mode CharacterSet, version int) Bits

func ConvertToAlphanumeric

func ConvertToAlphanumeric(data []byte, version int) Bits

func ConvertToBytes

func ConvertToBytes(data []byte, version int) Bits

func ConvertToNumeric

func ConvertToNumeric(data []byte, version int) Bits

type CharacterSet

type CharacterSet int

func AutodetectCharacterSet

func AutodetectCharacterSet(data []byte) CharacterSet

type CreateOptions

type CreateOptions struct {
	// Selects the level of error correction to use.
	// "L": recover 7% of codewords
	// "M": recover 15%
	// "Q": recover 25%
	// "H": recover 30%
	// If unset, defaults to "M"
	ErrorCorrectionLevel string

	// The character set to encode the data with.
	// If unset, the character set will be chosen automatically,
	// however, encoding formats will not be mixed on the same code.
	CharacterSet *CharacterSet

	// The version (size) of the qr code.
	// If unset, the version will be the smallest that can fit the data
	Version int
}

type QRCodeResult

type QRCodeResult struct {
	ErrorCorrectionLevel string
	CharacterSet         CharacterSet
	Version              int
	Data                 []byte
}

func ReadFromImage

func ReadFromImage(img *image.RGBA) (QRCodeResult, error)

func ReadFromWebcam

func ReadFromWebcam(displayIntermediates bool) (QRCodeResult, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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