qrcode

package module
v0.0.0-...-9bcba0b Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: MIT Imports: 14 Imported by: 0

README

siot-qrcode

A qrcode generate by golang

Documentation

Index

Constants

View Source
const (
	// Level L: 7% error recovery.
	Low = qrcode.Low

	// Level M: 15% error recovery. Good default choice.
	Medium = qrcode.Medium

	// Level Q: 25% error recovery.
	High = qrcode.High

	// Level H: 30% error recovery.
	Highest = qrcode.Highest
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Avatar

type Avatar struct {
	Src    string // 头像地址
	Width  int    // 头像宽度
	Height int    // 头像高度
	Round  int    // 头像圆角
}

func (*Avatar) Create

func (a *Avatar) Create(qr *qrcode.QRCode, img image.Image) (image.Image, error)

type BackgroundImage

type BackgroundImage struct {
	Src    string
	X      int
	Y      int
	Width  int
	Height int
}

func (*BackgroundImage) Create

func (a *BackgroundImage) Create(qr *qrcode.QRCode, img image.Image) (image.Image, error)

type CircleMask

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

func DefaultCircleMask

func DefaultCircleMask(img image.Image) CircleMask

func NewCircleMask

func NewCircleMask(img image.Image, p image.Point, d int) CircleMask

func (CircleMask) At

func (ci CircleMask) At(x, y int) color.Color

func (CircleMask) Bounds

func (ci CircleMask) Bounds() image.Rectangle

func (CircleMask) ColorModel

func (ci CircleMask) ColorModel() color.Model

type ForegroundImage

type ForegroundImage struct {
	Src string
}

func (*ForegroundImage) Create

func (a *ForegroundImage) Create(qr *qrcode.QRCode, img image.Image) (image.Image, error)

type IImage

type IImage interface {
	Create(*qrcode.QRCode, image.Image) (image.Image, error)
}

type IQrCode

type IQrCode interface {
	// 设置生成图像圆角
	SetRound(int)

	// 设置头像
	SetAvatar(IImage)

	// 设置背景图
	SetBackgroundImage(IImage)

	// 设置背景颜色
	SetBackgroundColor(color.Color)

	// 设置前景图
	SetForegroundImage(IImage)

	// 设置前景颜色
	SetForegroundColor(color.Color)

	DisableBorder(bool)

	// 返回生成的二维码图片字节数组
	Bytes(size int) ([]byte, error)

	// 返回生成的二维码图片
	Image(size int) (image.Image, error)

	// 将二维码以PNG写入io.Writer
	Write(size int, out io.Writer) error

	// 将二维码以PNG写入指定的文件
	WriteFile(size int, filename string) error
}

func New

func New(content string, level qrcode.RecoveryLevel) (IQrCode, error)

type QrCode

type QrCode struct {
	Avatar          IImage
	ForegroundImage IImage
	BackgroundImage IImage
	// contains filtered or unexported fields
}

func (*QrCode) Bytes

func (q *QrCode) Bytes(size int) ([]byte, error)

返回 png 二维码图片

func (*QrCode) DisableBorder

func (q *QrCode) DisableBorder(disable bool)

func (*QrCode) Image

func (q *QrCode) Image(size int) (image.Image, error)

返回生成的二维码图片

func (*QrCode) SetAvatar

func (q *QrCode) SetAvatar(avatar IImage)

设置头像

func (*QrCode) SetBackgroundColor

func (q *QrCode) SetBackgroundColor(color color.Color)

设置背景颜色

func (*QrCode) SetBackgroundImage

func (q *QrCode) SetBackgroundImage(img IImage)

设置背景图

func (*QrCode) SetForegroundColor

func (q *QrCode) SetForegroundColor(color color.Color)

设置前景颜色

func (*QrCode) SetForegroundImage

func (q *QrCode) SetForegroundImage(img IImage)

设置前景图

func (*QrCode) SetRound

func (q *QrCode) SetRound(r int)

设置生成图像圆角

func (*QrCode) Write

func (q *QrCode) Write(size int, out io.Writer) error

将二维码以PNG写入io.Writer

func (*QrCode) WriteFile

func (q *QrCode) WriteFile(size int, filename string) error

将二维码以PNG写入指定的文件

type RoundMask

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

func NewRoundMask

func NewRoundMask(img image.Image, r int) RoundMask

func (RoundMask) At

func (ri RoundMask) At(x, y int) color.Color

func (RoundMask) Bounds

func (ri RoundMask) Bounds() image.Rectangle

func (RoundMask) ColorModel

func (ri RoundMask) ColorModel() color.Model

Jump to

Keyboard shortcuts

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