utils

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntToRune

func IntToRune(i int) rune

IntToRune converts a digit 0 - 9 to the rune '0' - '9'. If the given int is outside of this range 'F' is returned!

func RuneToInt

func RuneToInt(r rune) int

RuneToInt converts a rune between '0' and '9' to an integer between 0 and 9 If the rune is outside of this range -1 is returned.

Types

type BitArray

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

func NewBitArray

func NewBitArray(size int) *BitArray

func NewEmptyBitArray

func NewEmptyBitArray() *BitArray

func (*BitArray) AppendBit

func (b *BitArray) AppendBit(bit bool)

func (*BitArray) AppendBitArray

func (b *BitArray) AppendBitArray(other *BitArray)

func (*BitArray) AppendBits

func (b *BitArray) AppendBits(value int, numBits int) error

func (*BitArray) Clear

func (b *BitArray) Clear()

func (*BitArray) Flip

func (b *BitArray) Flip(i int)

func (*BitArray) Get

func (b *BitArray) Get(i int) bool

func (*BitArray) GetBitArray

func (b *BitArray) GetBitArray() []uint32

func (*BitArray) GetNextSet

func (b *BitArray) GetNextSet(from int) int

func (*BitArray) GetNextUnset

func (b *BitArray) GetNextUnset(from int) int

func (*BitArray) GetSize

func (b *BitArray) GetSize() int

func (*BitArray) GetSizeInBytes

func (b *BitArray) GetSizeInBytes() int

func (*BitArray) IsRange

func (b *BitArray) IsRange(start, end int, value bool) (bool, error)

func (*BitArray) Reverse

func (b *BitArray) Reverse()

func (*BitArray) Set

func (b *BitArray) Set(i int)

func (*BitArray) SetBulk

func (b *BitArray) SetBulk(i int, newBits uint32)

func (*BitArray) SetRange

func (b *BitArray) SetRange(start, end int) error

func (*BitArray) String

func (b *BitArray) String() string

func (*BitArray) ToBytes

func (b *BitArray) ToBytes(bitOffset int, array []byte, offset, numBytes int)

func (*BitArray) Xor

func (b *BitArray) Xor(other *BitArray) error

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

func (*BitList) ToImageWithBarsRatio

func (resBits *BitList) ToImageWithBarsRatio(width, height int, widthRatio float64) image.Image

func (*BitList) ToWideNarrowList

func (resBits *BitList) ToWideNarrowList(wideBarWidth, narrowBarWidth int) *WideNarrowList

Converts BitList to useful representation for barcodes that have narrow / wide bars with variable bar ratio

type BitMatrix

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

func NewBitMatrix

func NewBitMatrix(width, height int) (*BitMatrix, error)

func NewSquareBitMatrix

func NewSquareBitMatrix(dimension int) (*BitMatrix, error)

func ParseBoolMapToBitMatrix

func ParseBoolMapToBitMatrix(image [][]bool) (*BitMatrix, error)

func ParseStringToBitMatrix

func ParseStringToBitMatrix(stringRepresentation, setString, unsetString string) (*BitMatrix, error)

func (*BitMatrix) At

func (b *BitMatrix) At(x, y int) color.Color

func (*BitMatrix) Bounds

func (b *BitMatrix) Bounds() image.Rectangle

func (*BitMatrix) Clear

func (b *BitMatrix) Clear()

func (*BitMatrix) ColorModel

func (b *BitMatrix) ColorModel() color.Model

func (*BitMatrix) Flip

func (b *BitMatrix) Flip(x, y int)

func (*BitMatrix) FlipAll

func (b *BitMatrix) FlipAll()

func (*BitMatrix) Get

func (b *BitMatrix) Get(x, y int) bool

func (*BitMatrix) GetBottomRightOnBit

func (b *BitMatrix) GetBottomRightOnBit() []int

func (*BitMatrix) GetEnclosingRectangle

func (b *BitMatrix) GetEnclosingRectangle() []int

func (*BitMatrix) GetHeight

func (b *BitMatrix) GetHeight() int

func (*BitMatrix) GetRow

func (b *BitMatrix) GetRow(y int, row *BitArray) *BitArray

func (*BitMatrix) GetRowSize

func (b *BitMatrix) GetRowSize() int

func (*BitMatrix) GetTopLeftOnBit

func (b *BitMatrix) GetTopLeftOnBit() []int

func (*BitMatrix) GetWidth

func (b *BitMatrix) GetWidth() int

func (*BitMatrix) Rotate90

func (b *BitMatrix) Rotate90()

func (*BitMatrix) Rotate180

func (b *BitMatrix) Rotate180()

func (*BitMatrix) Set

func (b *BitMatrix) Set(x, y int)

func (*BitMatrix) SetRegion

func (b *BitMatrix) SetRegion(left, top, width, height int) error

func (*BitMatrix) SetRow

func (b *BitMatrix) SetRow(y int, row *BitArray)

func (*BitMatrix) String

func (b *BitMatrix) String() string

func (*BitMatrix) ToString

func (b *BitMatrix) ToString(setString, unsetString string) string

func (*BitMatrix) ToStringWithLineSeparator

func (b *BitMatrix) ToStringWithLineSeparator(setString, unsetString, lineSeparator string) string

func (*BitMatrix) Unset

func (b *BitMatrix) Unset(x, y int)

func (*BitMatrix) Xor

func (b *BitMatrix) Xor(mask *BitMatrix) error

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 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

type WideNarrowList

type WideNarrowList struct {
	Data [][2]bool
	// contains filtered or unexported fields
}

func (*WideNarrowList) GetBarWidth

func (list *WideNarrowList) GetBarWidth(idx int) int

func (*WideNarrowList) GetTotalWidth

func (list *WideNarrowList) GetTotalWidth() int

Jump to

Keyboard shortcuts

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