qr

package
v0.0.0-...-01c468f Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

nolint:dupl

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVersionNotFound qr version not found
	ErrVersionNotFound = errors.New("version not found")

	// ErrTooLargeSize input text is too large to encode
	ErrTooLargeSize = errors.New("data is too large to encode")

	// ErrTooSmallImageSize size of a module cannot be smaller than one pixel
	ErrTooSmallImageSize = errors.New("image size is too small for this qr code")
)

Functions

This section is empty.

Types

type Code

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

Code stores all metadata as well as data itself about produced QR

func (*Code) GetImage

func (c *Code) GetImage(imageSize int) (image.Image, error)

GetImage generates an image representation of the QR code using default colors (black and white)

func (*Code) GetImageWithColors

func (c *Code) GetImageWithColors(imageSize int, colorOne, colorTwo color.RGBA) (image.Image, error)

func (*Code) String

func (c *Code) String() string

type Correction

type Correction int

Correction is the level of QR code correction: L, M, Q, H

const (
	L Correction = iota
	M
	Q
	H
)

type Encoder

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

Encoder encodes input data into a QR code

func NewEncoder

func NewEncoder(options ...EncoderOptions) *Encoder

NewEncoder returns a new Encoder with default options if none are provided

func (*Encoder) Encode

func (e *Encoder) Encode(text string) (*Code, error)

Encode encodes the given text into a QR code

type EncoderOptions

type EncoderOptions func(*Encoder)

EncoderOptions is a functional object that can be provided to NewEncoder to specify parameters of Encoder

func WithCorrectionLevel

func WithCorrectionLevel(level Correction) EncoderOptions

WithCorrectionLevel is an Encoder option that allows to specify a level of correction to be used in QR

func WithMaskRange

func WithMaskRange(minMask, maxMask int) EncoderOptions

WithMaskRange is an Encoder option that allows to specify a range of mask can be used to optimize mask

func WithVersionRange

func WithVersionRange(minVersion, maxVersion int) EncoderOptions

WithVersionRange is an Encoder option that allows to specify a range of versions can be used to encode data

Jump to

Keyboard shortcuts

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