gqr

package module
v0.1.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 13 Imported by: 1

README

gqr [WORK IN PROGRESS]

gqr is a QR code generation library focused on high customization.

This project is a fork of github.com/yeqown/go-qrcode with updated API.
So big thanks to the initial project!

Documentation

Overview

Package qrcode ... encoder.go working for data encoding

Index

Constants

View Source
const (
	// a qrbool of EncModeAuto will trigger a detection of the letter set from the input data,
	EncModeAuto = 0
	// EncModeNone mode ...
	EncModeNone encMode = 1 << iota
	// EncModeNumeric mode ...
	EncModeNumeric
	// EncModeAlphanumeric mode ...
	EncModeAlphanumeric
	// EncModeByte mode ...
	EncModeByte
	// EncModeJP mode ...
	EncModeJP
)
View Source
const (
	// IterDirection_ROW for row first
	IterDirection_ROW iterDirection = iota + 1

	// IterDirection_COLUMN for column first
	IterDirection_COLUMN
)
View Source
const (
	// QRType_INIT represents the initial block state of the matrix
	QRType_INIT qrtype = 1 << 1
	// QRType_DATA represents the data block state of the matrix
	QRType_DATA qrtype = 2 << 1
	// QRType_VERSION indicates the version block of matrix
	QRType_VERSION qrtype = 3 << 1
	// QRType_FORMAT indicates the format block of matrix
	QRType_FORMAT qrtype = 4 << 1
	// QRType_FINDER indicates the finder block of matrix
	QRType_FINDER qrtype = 5 << 1
	// QRType_DARK ...
	QRType_DARK     qrtype = 6 << 1
	QRType_SPLITTER qrtype = 7 << 1
	QRType_TIMING   qrtype = 8 << 1
)
View Source
const FINDER_SIZE = 7

FINDER_SIZE size of finder in modules

Variables

View Source
var (
	// ErrorOutRangeOfW x out of range of ModSize
	ErrorOutRangeOfW = errors.New("out of range of width")

	// ErrorOutRangeOfH y out of range of Height
	ErrorOutRangeOfH = errors.New("out of range of height")
)
View Source
var (
	// QRValue_INIT_V0 represents the value 0 qrvalue(QRType_INIT | 0)
	QRValue_INIT_V0 = qrvalue(QRType_INIT)

	// QRValue_DATA_V0 represents the block has been set to false qrvalue(QRType_DATA | 0)
	QRValue_DATA_V0 = qrvalue(QRType_DATA)
	// QRValue_DATA_V1 represents the block has been set to TRUE
	QRValue_DATA_V1 = qrvalue(QRType_DATA | 1)

	// QRValue_VERSION_V0 represents the block has been set to false qrvalue(QRType_VERSION | 0)
	QRValue_VERSION_V0 = qrvalue(QRType_VERSION)
	// QRValue_VERSION_V1 represents the block has been set to TRUE
	QRValue_VERSION_V1 = qrvalue(QRType_VERSION | 1)

	// QRValue_FORMAT_V0 represents the block has been set to false qrvalue(QRType_FORMAT | 0)
	QRValue_FORMAT_V0 = qrvalue(QRType_FORMAT)
	// QRValue_FORMAT_V1 represents the block has been set to TRUE
	QRValue_FORMAT_V1 = qrvalue(QRType_FORMAT | 1)

	// QRValue_FINDER_V0 represents the block has been set to false qrvalue(QRType_FINDER | 0)
	QRValue_FINDER_V0 = qrvalue(QRType_FINDER)
	// QRValue_FINDER_V1 represents the block has been set to TRUE
	QRValue_FINDER_V1 = qrvalue(QRType_FINDER | 1)

	// QRValue_DARK_V0 represents the block has been set to false qrvalue(QRType_DARK | 0)
	QRValue_DARK_V0 = qrvalue(QRType_DARK)
	// QRValue_DARK_V1 represents the block has been set to TRUE
	QRValue_DARK_V1 = qrvalue(QRType_DARK | 1)

	// QRValue_SPLITTER_V0 represents the block has been set to false qrvalue(QRType_SPLITTER | 0)
	QRValue_SPLITTER_V0 = qrvalue(QRType_SPLITTER)
	// QRValue_SPLITTER_V1 represents the block has been set to TRUE
	QRValue_SPLITTER_V1 = qrvalue(QRType_SPLITTER | 1)

	// QRValue_TIMING_V0 represents the block has been set to false qrvalue(QRType_TIMING | 0)
	QRValue_TIMING_V0 = qrvalue(QRType_TIMING)
	// QRValue_TIMING_V1 represents the block has been set to TRUE
	QRValue_TIMING_V1 = qrvalue(QRType_TIMING | 1)
)

Functions

func DefaultEncodingOption

func DefaultEncodingOption() *encodingOption

DefaultEncodingOption with EncMode = EncModeAuto, EcLevel = ErrorCorrectionQuart

func SetDebugMode

func SetDebugMode()

SetDebugMode open debug switch, you can also enable debug by runtime environments variables: QRCODE_DEBUG=1 [1, true, TRUE, enabled, ENABLED] which is recommended.

Types

type EncodeOption

type EncodeOption interface {
	// contains filtered or unexported methods
}

func WithEncodingMode

func WithEncodingMode(mode encMode) EncodeOption

WithEncodingMode sets the encoding mode.

func WithErrorCorrectionLevel

func WithErrorCorrectionLevel(ecLevel ErrorCorrectionLevel) EncodeOption

WithErrorCorrectionLevel sets the error correction level.

func WithVersion

func WithVersion(version int) EncodeOption

WithVersion sets the version of target QR code.

type ErrorCorrectionLevel

type ErrorCorrectionLevel int

ErrorCorrectionLevel error correction level

const (
	// ErrorCorrectionLow :Level L: 7% error recovery.
	ErrorCorrectionLow ErrorCorrectionLevel = iota + 1

	// ErrorCorrectionMedium :Level M: 15% error recovery. Good default choice.
	ErrorCorrectionMedium

	// ErrorCorrectionQuart :Level Q: 25% error recovery.
	ErrorCorrectionQuart

	// ErrorCorrectionHighest :Level Height: 30% error recovery.
	ErrorCorrectionHighest
)

type Matrix

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

Matrix is a matrix data type width:3 height: 4 for [3][4]int

func New

func New(text string) (*Matrix, error)

New generate a qrcode struct to create

func NewWith

func NewWith(text string, opts ...EncodeOption) (*Matrix, error)

NewWith generates Matrix that contains QR code with supplied data

func (*Matrix) Col

func (m *Matrix) Col(cur int) []qrvalue

Col return a slice of column, cur should be x dimension.

func (*Matrix) Copy

func (m *Matrix) Copy() *Matrix

Copy matrix into a new Matrix

func (*Matrix) Height

func (m *Matrix) Height() int

Height ... height

func (*Matrix) Iterate

func (m *Matrix) Iterate(direction iterDirection, fn func(x, y int, s QRValue))

Iterate the Matrix with loop direction IterDirection_ROW major or IterDirection_COLUMN major. IterDirection_COLUMN is recommended.

func (*Matrix) Row

func (m *Matrix) Row(cur int) []qrvalue

Row return a row of matrix, cur should be y dimension.

func (*Matrix) Width

func (m *Matrix) Width() int

Width ... width

type QRType

type QRType = qrtype

type QRValue

type QRValue = qrvalue

func (QRValue) IsSet

func (v QRValue) IsSet() bool

func (QRValue) Type

func (v QRValue) Type() qrtype

Directories

Path Synopsis
export
image Module
Package reedsolomon ...
Package reedsolomon ...
binary
Package binary ...
Package binary ...

Jump to

Keyboard shortcuts

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