Documentation ¶
Overview ¶
Package qrcode ... encoder.go working for data encoding
Index ¶
- Constants
- Variables
- func DefaultEncodingOption() *encodingOption
- func SetDebugMode()
- type EncodeOption
- type ErrorCorrectionLevel
- type Matrix
- func (m *Matrix) Col(cur int) []qrvalue
- func (m *Matrix) Copy() *Matrix
- func (m *Matrix) Height() int
- func (m *Matrix) Iterate(direction iterDirection, fn func(x, y int, s QRValue))
- func (m *Matrix) Row(cur int) []qrvalue
- func (m *Matrix) Set(w, h int, c qrvalue) error
- func (m *Matrix) ValueAtClamped(w, h int) QRValue
- func (m *Matrix) Width() int
- type QRType
- type QRValue
Constants ¶
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 )
const ( // IterDirection_ROW for row first IterDirection_ROW iterDirection = iota + 1 // IterDirection_COLUMN for column first IterDirection_COLUMN )
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 )
const FINDER_SIZE = 7
FINDER_SIZE size of finder in modules
Variables ¶
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") )
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 NewWith ¶
func NewWith(text string, opts ...EncodeOption) (*Matrix, error)
NewWith generates Matrix that contains QR code with supplied data
func (*Matrix) Iterate ¶
Iterate the Matrix with loop direction IterDirection_ROW major or IterDirection_COLUMN major. IterDirection_COLUMN is recommended.