qr_code

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	TypeAztec           = "Aztec"
	TypeCodabar         = "Codabar"
	TypeCode128         = "Code 128"
	TypeCode39          = "Code 39"
	TypeCode93          = "Code 93"
	TypeDataMatrix      = "DataMatrix"
	TypeEAN8            = "EAN 8"
	TypeEAN13           = "EAN 13"
	TypePDF             = "PDF417"
	TypeQR              = "QR Code"
	Type2of5            = "2 of 5"
	Type2of5Interleaved = "2 of 5 (interleaved)"
)

Variables

View Source
var ColorScheme16 = ColorScheme{
	Model:      color.Gray16Model,
	Background: color.White,
	Foreground: color.Black,
}

ColorScheme16 represents a color scheme with 16-bit grayscale colors.

View Source
var ColorScheme24 = ColorScheme{
	Model:      color.RGBAModel,
	Background: color.RGBA{255, 255, 255, 255},
	Foreground: color.RGBA{0, 0, 0, 255},
}

ColorScheme24 represents a color scheme with 24-bit RGB colors.

View Source
var ColorScheme32 = ColorScheme{
	Model:      color.RGBAModel,
	Background: color.RGBA{255, 255, 255, 255},
	Foreground: color.RGBA{0, 0, 0, 255},
}

ColorScheme32 represents a color scheme with 32-bit RGBA colors, which is similar to ColorScheme24 but typically includes alpha for transparency.

View Source
var ColorScheme8 = ColorScheme{
	Model:      color.GrayModel,
	Background: color.Gray{Y: 255},
	Foreground: color.Gray{Y: 0},
}

ColorScheme8 represents a color scheme with 8-bit grayscale colors.

Functions

This section is empty.

Types

type Barcode

type Barcode interface {
	image.Image
	// returns some meta information about the barcode
	Metadata() Metadata
	// the data that was encoded in this barcode
	Content() string
}

a rendered and encoded barcode

func Encode

func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (Barcode, error)

func EncodeWithColor

func EncodeWithColor(content string, level ErrorCorrectionLevel, mode Encoding, color ColorScheme) (Barcode, error)

Encode returns a QR barcode with the given content and color scheme, error correction level and uses the given encoding

func Scale

func Scale(bc Barcode, width, height int) (Barcode, error)

Scale returns a resized barcode with the given width and height.

func ScaleWithFill

func ScaleWithFill(bc Barcode, width, height int, fill color.Color) (Barcode, error)

Scale returns a resized barcode with the given width, height and fill color.

type BarcodeColor

type BarcodeColor interface {
	ColorScheme() ColorScheme
}

type BarcodeIntCS

type BarcodeIntCS interface {
	Barcode
	CheckSum() int
}

Additional interface that some barcodes might implement to provide the value of its checksum.

type BitList

type BitList struct {
	// contains filtered or unexported fields
}

BitList is a list that contains bits

func NewBitList

func NewBitList(capacity int) *BitList

NewBitList returns a new BitList with the given length all bits are initialize with false

func (*BitList) AddBit

func (bl *BitList) AddBit(bits ...bool)

AddBit appends the given bits to the end of the list

func (*BitList) AddBits

func (bl *BitList) AddBits(b int, count byte)

AddBits appends the last (LSB) 'count' bits of 'b' the the end of the list

func (*BitList) AddByte

func (bl *BitList) AddByte(b byte)

AddByte appends all 8 bits of the given byte to the end of the list

func (*BitList) GetBit

func (bl *BitList) GetBit(index int) bool

GetBit returns the bit at the given index

func (*BitList) GetBytes

func (bl *BitList) GetBytes() []byte

GetBytes returns all bits of the BitList as a []byte

func (*BitList) IterateBytes

func (bl *BitList) IterateBytes() <-chan byte

IterateBytes iterates through all bytes contained in the BitList

func (*BitList) Len

func (bl *BitList) Len() int

Len returns the number of contained bits

func (*BitList) SetBit

func (bl *BitList) SetBit(index int, value bool)

SetBit sets the bit at the given index to the given value

type ColorScheme

type ColorScheme struct {
	Model      color.Model // Color model to be used (e.g., grayscale, RGB, RGBA)
	Background color.Color // Color of the background
	Foreground color.Color // Color of the foreground (e.g., bars in a barcode)
}

ColorScheme defines a structure for color schemes used in barcode rendering. It includes the color model, background color, and foreground color.

type Encoding

type Encoding byte

Encoding mode for QR Codes.

const (
	// Auto will choose ths best matching encoding
	Auto Encoding = iota
	// Numeric encoding only encodes numbers [0-9]
	Numeric
	// AlphaNumeric encoding only encodes uppercase letters, numbers and  [Space], $, %, *, +, -, ., /, :
	AlphaNumeric
	// Unicode encoding encodes the string as utf-8
	Unicode
)

func (Encoding) String

func (e Encoding) String() string

type ErrorCorrectionLevel

type ErrorCorrectionLevel byte

ErrorCorrectionLevel indicates the amount of "backup data" stored in the QR code

const (
	// L recovers 7% of data
	L ErrorCorrectionLevel = iota
	// M recovers 15% of data
	M
	// Q recovers 25% of data
	Q
	// H recovers 30% of data
	H
)

func (ErrorCorrectionLevel) String

func (ecl ErrorCorrectionLevel) String() string

type GFPoly

type GFPoly struct {
	Coefficients []int
	// contains filtered or unexported fields
}

func NewGFPoly

func NewGFPoly(field *GaloisField, coefficients []int) *GFPoly

func NewMonominalPoly

func NewMonominalPoly(field *GaloisField, degree int, coeff int) *GFPoly

func (*GFPoly) AddOrSubstract

func (gp *GFPoly) AddOrSubstract(other *GFPoly) *GFPoly

func (*GFPoly) Degree

func (gp *GFPoly) Degree() int

func (*GFPoly) Divide

func (gp *GFPoly) Divide(other *GFPoly) (quotient *GFPoly, remainder *GFPoly)

func (*GFPoly) GetCoefficient

func (gp *GFPoly) GetCoefficient(degree int) int

GetCoefficient returns the coefficient of x ^ degree

func (*GFPoly) MultByMonominal

func (gp *GFPoly) MultByMonominal(degree int, coeff int) *GFPoly

func (*GFPoly) Multiply

func (gp *GFPoly) Multiply(other *GFPoly) *GFPoly

func (*GFPoly) Zero

func (gp *GFPoly) Zero() bool

type GaloisField

type GaloisField struct {
	Size    int
	Base    int
	ALogTbl []int
	LogTbl  []int
}

GaloisField encapsulates galois field arithmetics

func NewGaloisField

func NewGaloisField(pp, fieldSize, b int) *GaloisField

NewGaloisField creates a new galois field

func (*GaloisField) AddOrSub

func (gf *GaloisField) AddOrSub(a, b int) int

AddOrSub add or substract two numbers

func (*GaloisField) Divide

func (gf *GaloisField) Divide(a, b int) int

Divide divides two numbers

func (*GaloisField) Invers

func (gf *GaloisField) Invers(num int) int

func (*GaloisField) Multiply

func (gf *GaloisField) Multiply(a, b int) int

Multiply multiplys two numbers

func (*GaloisField) Zero

func (gf *GaloisField) Zero() *GFPoly

type Metadata

type Metadata struct {
	// the name of the barcode kind
	CodeKind string
	// contains 1 for 1D barcodes or 2 for 2D barcodes
	Dimensions byte
}

Contains some meta information about a barcode

type ReedSolomonEncoder

type ReedSolomonEncoder struct {
	// contains filtered or unexported fields
}

func NewReedSolomonEncoder

func NewReedSolomonEncoder(gf *GaloisField) *ReedSolomonEncoder

func (*ReedSolomonEncoder) Encode

func (rs *ReedSolomonEncoder) Encode(data []int, eccCount int) []int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳