label

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Width         = tspl.PrintWidthDots
	Margin        = 8
	CodeWidth     = Width - 2*Margin
	MaxHeightDots = 16000 // 2m of paper
	MaxBlocks     = 32
	MaxBannerDots = 2400 // 300mm, text or barcodes turned to run along the paper
	MaxPixels     = 50_000_000
)
View Source
const (
	KindText    = "text"
	KindImage   = "image"
	KindQR      = "qr"
	KindBarcode = "barcode"
	KindSpacer  = "spacer"
	KindLine    = "line"
)

Variables

View Source
var (
	ErrEmpty   = errors.New("the label has nothing on it")
	ErrTooTall = errors.New("label too tall")
)

Functions

func Kinds

func Kinds() []string

func Render

func Render(l *Label) (*raster.Bitmap, error)

Types

type Block

type Block struct {
	Kind string `json:"kind"`

	Text  string `json:"text,omitzero"`
	Data  string `json:"data,omitzero"`
	Image []byte `json:"image,omitzero"` // png, jpeg, gif, bmp, webp or tiff

	Font   string `json:"font,omitzero"`
	Size   int    `json:"size,omitzero"` // dots, text em size / qr side / spacer height / line thickness
	Align  string `json:"align,omitzero"`
	Rotate int    `json:"rotate,omitzero"` // clockwise
	Invert bool   `json:"invert,omitzero"`

	Fit        string `json:"fit,omitzero"` // "width" also enlarges narrow images
	Dither     string `json:"dither,omitzero"`
	Threshold  int    `json:"threshold,omitzero"`
	Brightness int    `json:"brightness,omitzero"`
	Contrast   int    `json:"contrast,omitzero"`

	Level     string `json:"level,omitzero"`
	Symbology string `json:"symbology,omitzero"`
	Height    int    `json:"height,omitzero"`
	HideText  bool   `json:"hide_text,omitzero"`
	Checksum  bool   `json:"checksum,omitzero"`
}

type BlockError

type BlockError struct {
	Index int
	Err   error
}

func (*BlockError) Error

func (e *BlockError) Error() string

func (*BlockError) Unwrap

func (e *BlockError) Unwrap() error

type Label

type Label struct {
	Blocks      []Block `json:"blocks"`
	Gap         int     `json:"gap,omitzero"` // dots
	MinLengthMM float64 `json:"min_length_mm,omitzero"`
}

Jump to

Keyboard shortcuts

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