Documentation ¶
Index ¶
- Constants
- Variables
- type BaseOutput
- func (out *BaseOutput) AddOption(options ...*Option)
- func (out *BaseOutput) EvalMicroQRCodePenalty(moduleSize int) uint
- func (out *BaseOutput) EvalPenalty(moduleSize int) uint
- func (out *BaseOutput) GetModule(x int, y int) bool
- func (out *BaseOutput) GetRecommendSize(moduleSize int) []int
- func (out *BaseOutput) IsModuleSet(x int, y int) bool
- type CodeColor
- type ImageOutput
- func (out *ImageOutput) Clone() Output
- func (out *ImageOutput) GetBaseOutput() *BaseOutput
- func (out *ImageOutput) GetColor() CodeColor
- func (out *ImageOutput) GetImage() *image.NRGBA
- func (out *ImageOutput) GetModule(x int, y int) bool
- func (out *ImageOutput) Init(version *model.Version, qz *model.QuietZone)
- func (out *ImageOutput) IsModuleSet(x int, y int) bool
- func (out *ImageOutput) ResizeToFit(moduleSize int, quietZoneSize int, pixelSize int)
- func (out *ImageOutput) Save(fileName string) error
- func (out *ImageOutput) SaveToBase64() (base64Str string, err error)
- func (out *ImageOutput) SaveToWriter(writer io.Writer) error
- func (out *ImageOutput) Write(x int, y int, black bool)
- func (out *ImageOutput) WriteModule(x int, y int, black bool, pixelSize int, part cons.QRCodeStructPart)
- func (out *ImageOutput) WriteModuleColor(x int, y int, dark bool, setColor color.Color, pixelSize int)
- type Option
- type OptionName
- type Output
- type Type
Constants ¶
const ( JPG Type = iota // 0 PNG // 1 GIF // 2 SVG // 3 // AUTO_SIZE : set auto size for qrcode , per module fill by 4 pixels AUTO_SIZE = 0 LogoOptionName OptionName = "logo" )
defined OutputType constants
Variables ¶
var ( BlackColor = image.Black BlueColor = color.NRGBA{0, 127, 255, 255} RedCode = color.NRGBA{255, 82, 25, 255} OrangeCode = color.NRGBA{255, 146, 0, 255} GreenCode = color.NRGBA{0, 176, 66, 255} // DefaultCodeColor default color is black for QRCode DefaultCodeColor = CodeColor{BlackColor, BlackColor, BlackColor, image.White, BlackColor, BlackColor, BlackColor} // BlueCodeColor #007FFF/rgba(0,127,255,1) BlueCodeColor = CodeColor{BlueColor, BlueColor, BlueColor, image.White, BlueColor, BlueColor, BlueColor} // RedCodeColor #FF5219/rgba(255,82,25,1) RedCodeColor = CodeColor{RedCode, RedCode, RedCode, image.White, RedCode, RedCode, RedCode} // OrangeCodeColor #FF9200/rgba(255,146,0,1) OrangeCodeColor = CodeColor{OrangeCode, OrangeCode, OrangeCode, image.White, OrangeCode, OrangeCode, OrangeCode} // GreenCodeColor #00B042/rgba(0,176,66,1) GreenCodeColor = CodeColor{GreenCode, GreenCode, GreenCode, image.White, GreenCode, GreenCode, GreenCode} // ColorfulCodeColor MultiColor for QRCodeStruct Part ColorfulCodeColor = CodeColor{DefaultCodeColor.DataColor, RedCodeColor.DataColor, GreenCodeColor.DataColor, image.White, BlueCodeColor.DataColor, OrangeCodeColor.DataColor, DefaultCodeColor.DataColor} )
Functions ¶
This section is empty.
Types ¶
type BaseOutput ¶
type BaseOutput struct { // image type Type Type // image width/height Size int Options []*Option CodeColor CodeColor // contains filtered or unexported fields }
func (*BaseOutput) AddOption ¶
func (out *BaseOutput) AddOption(options ...*Option)
func (*BaseOutput) EvalMicroQRCodePenalty ¶
func (out *BaseOutput) EvalMicroQRCodePenalty(moduleSize int) uint
EvalMicroQRCodePenalty :Evaluate Penalty for Micro QRCode. Page 62, 7.8.3.2 Evaluation of Micro QRCode Symbols. if SUM1 <= SUM2
Evaluation Score = SUM1 x 16 + SUM2
if SUM1 > SUM2
Evaluation Score = SUM2 x 16 + SUM2
where:
SUM1 number of dark modules in right side edge SUM2 number of dark modules in lower side edge
func (*BaseOutput) EvalPenalty ¶
func (out *BaseOutput) EvalPenalty(moduleSize int) uint
EvalPenalty :Evaluate Penalty for QRCode. param: moduleSize, not contains quiet zone size.
func (*BaseOutput) GetRecommendSize ¶
func (out *BaseOutput) GetRecommendSize(moduleSize int) []int
GetRecommendSize :Get recommend size for QRCode return: the array of two recommend sizes
func (*BaseOutput) IsModuleSet ¶
func (out *BaseOutput) IsModuleSet(x int, y int) bool
type CodeColor ¶
type CodeColor struct { FinderPatternColor color.Color AlignmentPatternColor color.Color TimingPatternColor color.Color QuietZoneColor color.Color DataColor color.Color FormatColor color.Color VersionColor color.Color }
CodeColor color for qrcode
type ImageOutput ¶
type ImageOutput struct { *BaseOutput // contains filtered or unexported fields }
func NewGIFOutput ¶
func NewGIFOutput(size int) *ImageOutput
func NewGIFOutput0 ¶
func NewGIFOutput0() *ImageOutput
NewGIFOutput0 :Output a new GIF image by auto size.
func NewJPGOutput ¶
func NewJPGOutput(size int) *ImageOutput
func NewJPGOutput0 ¶
func NewJPGOutput0() *ImageOutput
NewJPGOutput0 :Output a new JPG image by auto size.
func NewOutput ¶
func NewOutput(output *BaseOutput) *ImageOutput
func NewPNGOutput ¶
func NewPNGOutput(size int) *ImageOutput
func NewPNGOutput0 ¶
func NewPNGOutput0() *ImageOutput
NewPNGOutput0 :Output a new PNG image by auto size.
func (*ImageOutput) Clone ¶
func (out *ImageOutput) Clone() Output
Clone : Shallow copy BaseOutput and modules from output, init new image instance
func (*ImageOutput) GetBaseOutput ¶
func (out *ImageOutput) GetBaseOutput() *BaseOutput
func (*ImageOutput) GetColor ¶
func (out *ImageOutput) GetColor() CodeColor
func (*ImageOutput) GetImage ¶
func (out *ImageOutput) GetImage() *image.NRGBA
func (*ImageOutput) Init ¶
func (out *ImageOutput) Init(version *model.Version, qz *model.QuietZone)
Init :init for output when size is AUTO_SIZE
func (*ImageOutput) IsModuleSet ¶
func (out *ImageOutput) IsModuleSet(x int, y int) bool
func (*ImageOutput) ResizeToFit ¶
func (out *ImageOutput) ResizeToFit(moduleSize int, quietZoneSize int, pixelSize int)
func (*ImageOutput) SaveToBase64 ¶
func (out *ImageOutput) SaveToBase64() (base64Str string, err error)
SaveToBase64 : save image to base64 string
func (*ImageOutput) SaveToWriter ¶
func (out *ImageOutput) SaveToWriter(writer io.Writer) error
SaveToWriter : save to any io.Writer
func (*ImageOutput) Write ¶
func (out *ImageOutput) Write(x int, y int, black bool)
Write : write data
func (*ImageOutput) WriteModule ¶
func (out *ImageOutput) WriteModule(x int, y int, black bool, pixelSize int, part cons.QRCodeStructPart)
WriteModule : write data
func (*ImageOutput) WriteModuleColor ¶
type Option ¶
type Option struct { Name OptionName Value string }
Option : Output Option
func LogoOption ¶
LogoOption : Option for add logo image at center of QRCode
type OptionName ¶
type OptionName = string
type Output ¶
type Output interface { GetBaseOutput() *BaseOutput // Init :init for output when size is AUTO_SIZE Init(version *model.Version, qz *model.QuietZone) Write(x int, y int, black bool) // WriteModule :write per module by pixelSize WriteModule(x int, y int, black bool, pixelSize int, part cons.QRCodeStructPart) WriteModuleColor(x int, y int, dark bool, setColor color.Color, pixelSize int) // IsModuleSet : check the module whether or not be set IsModuleSet(x int, y int) bool // GetModule : x,y is module axes , not pixel axes. GetModule(x int, y int) bool GetImage() *image.NRGBA Clone() Output ResizeToFit(moduleSize int, quietZoneSize int, pixelSize int) Save(fileName string) error SaveToWriter(w io.Writer) error SaveToBase64() (string, error) GetColor() CodeColor }
Output : the output interface for qrcode print