maxicode

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 7 Imported by: 2

README

maxicode

Library for creating UPS MaxiCodes written in pure Go

Usage


inputData := "[)>" + RS + "01" + GS + "09651147" + GS + "276" + GS + "066" + GS + "1Z12345677" + GS + "UPSN" + GS + "1X2X3X" + GS + "187" + GS + "" + GS + "1/1" + GS + "10" + GS + "N" + GS + "5 WALDSTRASSE" + GS + "COLOGNE" + GS + "" + RS + "" + EOT
mode := 3
eci := 0
scaleFactor := 35.0

grid, err := maxicode.Encode(mode, eci, inputData)
if grid != nil {
    t.Fatalf(err.Error())
}

err = grid.Draw(scaleFactor).SavePNG("maxicode.png")
if err != nil {
    t.Fatalf(err.Error())
}

Above code will produce the following image:

MaxiCode Mode 3

You can use different scaleFactors to scale maxicodes up/down. Normally scaleFactors should depend on your dpi/dpmm

Contributors

Special thanks for:

Documentation

Index

Constants

View Source
const (
	RS  = string(rune(30))
	GS  = string(rune(29))
	EOT = string(rune(4))
)

special characters

Variables

This section is empty.

Functions

This section is empty.

Types

type SymbolGrid

type SymbolGrid [30 * 33]bool

func Encode

func Encode(mode, eci int, inputData string) (*SymbolGrid, error)

func (*SymbolGrid) Draw

func (s *SymbolGrid) Draw(multiplier float64) *gg.Context

func (*SymbolGrid) GetModule

func (s *SymbolGrid) GetModule(row, column int) bool

func (*SymbolGrid) SaveToPNG

func (s *SymbolGrid) SaveToPNG(multiplier float64, path string) error

func (*SymbolGrid) SetModule

func (s *SymbolGrid) SetModule(row, column int, value bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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