image

package module
v0.0.0-...-fe0a03f Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 8 Imported by: 0

README

Image Exporter

This exporter accepts QR code matrix and exports it to image.Image

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultImageOptions = imageOptions{
	// contains filtered or unexported fields
}

Functions

func ParseFromHex

func ParseFromHex(s string) color.RGBA

ParseFromHex convert hex string into color.RGBA

Types

type Exporter

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

Exporter exports gqr.Matrix to image.Image

func NewExporter

func NewExporter(opts ...ImageOption) Exporter

NewExporter creates new Exporter. (see DefaultImageOptions)

func (Exporter) Export

func (e Exporter) Export(mat gqr.Matrix) image.Image

Export QR to Image.image

type GradientConfig

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

type GradientDirection

type GradientDirection = int
const (
	// GradientDirectionTLBR - Top Left -> Bottom Right
	GradientDirectionTLBR GradientDirection = iota
	// GradientDirectionTRBL - Top Right -> Bottom Left
	GradientDirectionTRBL GradientDirection = iota
)

type ImageOption

type ImageOption interface {
	// contains filtered or unexported methods
}

func WithBgColor

func WithBgColor(c color.Color) ImageOption

WithBgColor background color

func WithBgColorHex

func WithBgColorHex(hex string) ImageOption

WithBgColorHex background color

func WithFgColor

func WithFgColor(c color.Color) ImageOption

WithFgColor sets color that is used to draw modules (ignored if gradient is set)

func WithFgColorHex

func WithFgColorHex(hex string) ImageOption

WithFgColorHex Hex string to set QR Color

func WithFinderShape

func WithFinderShape(c shapes.FinderDrawConfig) ImageOption

WithFinderShape sets config for drawing 3 finders in corners of QR code. See: shapes.SquareFinderShape, shapes.RoundedFinderShape.

func WithGradient

func WithGradient(d GradientDirection, colors ...color.Color) ImageOption

WithGradient will use gradient to paint modules instead of foregroundColor (if set by WithFgColor or WithFgColorHex)

func WithImageSize

func WithImageSize(size int) ImageOption

WithImageSize sets size of outputted image in pixels Values less than 1 are ignored

func WithLogo(img image.Image) ImageOption

WithLogo embeds image at the center of the QR

func WithModuleGap

func WithModuleGap(gap float64) ImageOption

WithModuleGap will set gaps between modules in percents relative to dynamic module size (determined by quiet zone and image size)

Note: gap should be in range [0; 1). Other values are ignored

func WithModuleShape

func WithModuleShape(drawer shapes.ModuleDrawer) ImageOption

WithModuleShape sets function that will draw modules on the image See: shapes.SquareModuleShape, shapes.RoundedModuleShape.

func WithQuietZone

func WithQuietZone(size int) ImageOption

WithQuietZone set padding around QR code. Note: actual size of the QR code is equal to size - quietZone * 2 (padding applied on every side )

func WithSpaceAroundLogo() ImageOption

WithSpaceAroundLogo adds empty space behind logo, so it's not drawn on top of modules

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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