Documentation
¶
Index ¶
- Constants
- Variables
- type Barcode
- func Encode(content string, level ErrorCorrectionLevel, mode Encoding) (Barcode, error)
- func EncodeWithColor(content string, level ErrorCorrectionLevel, mode Encoding, color ColorScheme) (Barcode, error)
- func Scale(bc Barcode, width, height int) (Barcode, error)
- func ScaleWithFill(bc Barcode, width, height int, fill color.Color) (Barcode, error)
- type BarcodeColor
- type BarcodeIntCS
- type BitList
- func (bl *BitList) AddBit(bits ...bool)
- func (bl *BitList) AddBits(b int, count byte)
- func (bl *BitList) AddByte(b byte)
- func (bl *BitList) GetBit(index int) bool
- func (bl *BitList) GetBytes() []byte
- func (bl *BitList) IterateBytes() <-chan byte
- func (bl *BitList) Len() int
- func (bl *BitList) SetBit(index int, value bool)
- type ColorScheme
- type Encoding
- type ErrorCorrectionLevel
- type GFPoly
- func (gp *GFPoly) AddOrSubstract(other *GFPoly) *GFPoly
- func (gp *GFPoly) Degree() int
- func (gp *GFPoly) Divide(other *GFPoly) (quotient *GFPoly, remainder *GFPoly)
- func (gp *GFPoly) GetCoefficient(degree int) int
- func (gp *GFPoly) MultByMonominal(degree int, coeff int) *GFPoly
- func (gp *GFPoly) Multiply(other *GFPoly) *GFPoly
- func (gp *GFPoly) Zero() bool
- type GaloisField
- type Metadata
- type ReedSolomonEncoder
Constants ¶
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 ¶
var ColorScheme16 = ColorScheme{ Model: color.Gray16Model, Background: color.White, Foreground: color.Black, }
ColorScheme16 represents a color scheme with 16-bit grayscale colors.
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.
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.
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
type BarcodeColor ¶
type BarcodeColor interface {
ColorScheme() ColorScheme
}
type BarcodeIntCS ¶
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 ¶
NewBitList returns a new BitList with the given length all bits are initialize with false
func (*BitList) AddBits ¶
AddBits appends the last (LSB) 'count' bits of 'b' the the end of the list
func (*BitList) IterateBytes ¶
IterateBytes iterates through all bytes contained in the BitList
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 )
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 (*GFPoly) GetCoefficient ¶
GetCoefficient returns the coefficient of x ^ degree
type GaloisField ¶
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) 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