image

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 9 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 = exportOptions{
	// contains filtered or unexported fields
}

Functions

func ParseFromHex

func ParseFromHex(s string) color.RGBA

ParseFromHex convert hex string into color.RGBA

Types

type ExportOption

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

func WithBgColor

func WithBgColor(c color.Color) ExportOption

WithBgColor background color

func WithBgColorHex

func WithBgColorHex(hex string) ExportOption

WithBgColorHex background color

func WithFgColor

func WithFgColor(c color.Color) ExportOption

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

func WithFgColorHex

func WithFgColorHex(hex string) ExportOption

WithFgColorHex Hex string to set QR Color

func WithFinderShape

func WithFinderShape(c shapes.FinderDrawConfig) ExportOption

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) ExportOption

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

func WithImageSize

func WithImageSize(size int) ExportOption

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

func WithLogo(img image.Image) ExportOption

WithLogo embeds image at the center of the QR

func WithLogoScale added in v0.3.1

func WithLogoScale(scale float64) ExportOption

WithLogoScale allows to resize logo image relative to the space it clears if WithSpaceAroundLogo is applied.

Allowed values are from 0.5 to 1 (inclusively)

func WithModuleGap

func WithModuleGap(gap float64) ExportOption

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) ExportOption

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

func WithQuietZone

func WithQuietZone(size int) ExportOption

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() ExportOption

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

type Exporter

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

Exporter exports gqr.Matrix to image.Image

func NewExporter

func NewExporter(opts ...ExportOption) 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 (
	// GradientDirectionLTR - Top Left -> Bottom Right
	GradientDirectionLTR GradientDirection = iota
	// GradientDirectionRTL - Top Right -> Bottom Left
	GradientDirectionRTL GradientDirection = iota
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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