Documentation ¶
Overview ¶
Package qrcode ... encoder.go working for data encoding
Index ¶
- Constants
- func SetDebugMode()
- type DrawContext
- type IShape
- type ImageEncoder
- type ImageOption
- func WithBgColor(c color.Color) ImageOption
- func WithBgColorRGBHex(hex string) ImageOption
- func WithBuiltinImageEncoder(format formatTyp) ImageOption
- func WithCircleShape() ImageOption
- func WithCustomImageEncoder(encoder ImageEncoder) ImageOption
- func WithCustomShape(shape IShape) ImageOption
- func WithFgColor(c color.Color) ImageOption
- func WithFgColorRGBHex(hex string) ImageOption
- func WithLogoImage(img image.Image) ImageOption
- func WithLogoImageFileJPEG(f string) ImageOption
- func WithLogoImageFilePNG(f string) ImageOption
- func WithQRWidth(width uint8) ImageOption
- type QRCode
Constants ¶
const ( // JPEG_FORMAT as default output file format. JPEG_FORMAT formatTyp = iota // PNG_FORMAT . PNG_FORMAT )
const ( // Low :Level L: 7% error recovery. Low ecLevel = iota + 1 // Medium :Level M: 15% error recovery. Good default choice. Medium // Quart :Level Q: 25% error recovery. Quart // Highest :Level H: 30% error recovery. Highest )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DrawContext ¶
type DrawContext struct { *gg.Context UpperLeft image.Point // (x1, y1) W, H int MatrixW, MatrixH int CursorX, CursorY int Color color.Color }
DrawContext is a rectangle area
type IShape ¶
type IShape interface { // draw to fill the IShape Draw(ctx *DrawContext) }
type ImageEncoder ¶
type ImageEncoder interface { // Encode specify which format to encode image into w io.Writer. Encode(w io.Writer, img image.Image) error }
ImageEncoder is an interface which describes the rule how to encode image.Image into io.Writer
type ImageOption ¶
type ImageOption interface {
// contains filtered or unexported methods
}
func WithBgColorRGBHex ¶
func WithBgColorRGBHex(hex string) ImageOption
WithBgColorRGBHex background color
func WithBuiltinImageEncoder ¶
func WithBuiltinImageEncoder(format formatTyp) ImageOption
WithBuiltinImageEncoder option includes: JPEG_FORMAT as default, PNG_FORMAT. This works like WithBuiltinImageEncoder, the different between them is formatTyp is enumerated in (JPEG_FORMAT, PNG_FORMAT)
func WithCircleShape ¶
func WithCircleShape() ImageOption
WithCircleShape use circle shape as rectangle(default)
func WithCustomImageEncoder ¶
func WithCustomImageEncoder(encoder ImageEncoder) ImageOption
WithBuiltinImageEncoder to use custom image encoder to encode image.Image into io.Writer
func WithCustomShape ¶
func WithCustomShape(shape IShape) ImageOption
WithCustomShape use custom shape as rectangle(default)
func WithFgColorRGBHex ¶
func WithFgColorRGBHex(hex string) ImageOption
WithFgColorRGBHex Hex string to set QR Color
func WithLogoImage ¶
func WithLogoImage(img image.Image) ImageOption
WithLogoImage image should only has 1/5 width of QRCode at most
func WithLogoImageFileJPEG ¶
func WithLogoImageFileJPEG(f string) ImageOption
WithLogoImageFileJPEG load image from file, jpeg is required. image should only has 1/5 width of QRCode at most
func WithLogoImageFilePNG ¶
func WithLogoImageFilePNG(f string) ImageOption
WithLogoImageFilePNG load image from file, PNG is required. image should only has 1/5 width of QRCode at most
func WithQRWidth ¶
func WithQRWidth(width uint8) ImageOption
WithQRWidth specify width of each qr block
type QRCode ¶
type QRCode struct {
// contains filtered or unexported fields
}
QRCode contains fields to generate QRCode matrix, outputImageOptions to Draw image, and etc.
func New ¶
func New(text string, opts ...ImageOption) (*QRCode, error)
New generate a QRCode struct to create
func NewWithSpecV ¶
func NewWithSpecV(text string, ver int, ecLv ecLevel, opts ...ImageOption) (*QRCode, error)
NewWithSpecV generate a QRCode struct with specified `ver`(QR version) and `ecLv`(Error Correction level)