Documentation ¶
Overview ¶
Package qrcode ... encoder.go working for data encoding
Index ¶
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 ( // ErrorCorrectionLow :Level L: 7% error recovery. ErrorCorrectionLow ecLevel = iota + 1 // ErrorCorrectionMedium :Level M: 15% error recovery. Good default choice. ErrorCorrectionMedium // ErrorCorrectionQuart :Level Q: 25% error recovery. ErrorCorrectionQuart // ErrorCorrectionHighest :Level H: 30% error recovery. ErrorCorrectionHighest )
Variables ¶
var ( // ErrorOutRangeOfW x out of range of Width 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_INIT_V0 = qrvalue(QRType_INIT | 0) // QRValue_DATA_V0 represents the block has been set to false QRValue_DATA_V0 = qrvalue(QRType_DATA | 0) // 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_VERSION_V0 = qrvalue(QRType_VERSION | 0) // 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_FORMAT_V0 = qrvalue(QRType_FORMAT | 0) // 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_FINDER_V0 = qrvalue(QRType_FINDER | 0) // 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_DARK_V0 = qrvalue(QRType_DARK | 0) // 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_SPLITTER_V0 = qrvalue(QRType_SPLITTER | 0) // 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_TIMING_V0 = qrvalue(QRType_TIMING | 0) // 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 ecLevel) EncodeOption
WithErrorCorrectionLevel sets the error correction level.
func WithVersion ¶
func WithVersion(version int) EncodeOption
WithVersion sets the version of target QR code.
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 (*Matrix) Iterate ¶
Iterate the Matrix with loop direction IterDirection_ROW major or IterDirection_COLUMN major. IterDirection_COLUMN is recommended.
type QRCode ¶
type QRCode struct {
// contains filtered or unexported fields
}
QRCode contains fields to generate QRCode matrix, outputImageOptions to Draw image, etc.
type Writer ¶
type Writer interface { // Write writes the code image into itself stream, such as io.Writer, // terminal output stream, and etc Write(mat Matrix) error // Close the writer stream if it exists after QRCode.Save() is called. Close() error }
Writer is the interface of a QR code writer, it defines the rule of how to `print` the code image from matrix. There's built-in writer to output into file, terminal.