engrave

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Unlicense Imports: 16 Imported by: 0

Documentation

Overview

package engrave transforms shapes such as text and QR codes into line and move commands for use with an engraver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ManhattanDist added in v1.3.0

func ManhattanDist(p1, p2 image.Point) int

func Measure added in v0.10.0

func Measure(c Plan) image.Rectangle

func NewBitmap added in v0.10.0

func NewBitmap(w, h int) bitmap

Types

type Command

type Command struct {
	Line  bool
	Coord image.Point
}

func Line added in v1.3.0

func Line(p image.Point) Command

func Move added in v1.3.0

func Move(p image.Point) Command

type ConstantStringer added in v0.10.0

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

ConstantStringer can engrave text in a timing insensitive way.

func NewConstantStringer added in v0.10.0

func NewConstantStringer(face *vector.Face, em int, shortest, longest int) *ConstantStringer

func (*ConstantStringer) String added in v0.10.0

func (c *ConstantStringer) String(txt string) Plan

type Params added in v1.3.0

type Params struct {
	// The StrokeWidth measured in machine units.
	StrokeWidth int
	// A Millimeter measured in machine units.
	Millimeter int
}

Params decribe the physical characteristics of an engraver.

func (Params) F added in v1.3.0

func (p Params) F(v float32) int

func (Params) I added in v1.3.0

func (p Params) I(v int) int

type Plan added in v1.3.0

type Plan func(yield func(Command))

Plan is an iterator over the commands of an engraving.

func Commands

func Commands(plans ...Plan) Plan

func ConstantQR added in v0.10.0

func ConstantQR(strokeWidth, scale int, level qr.Level, content []byte) (Plan, error)

ConstantQR is like QR that engraves the QR code in a pattern independent of content, except for the QR code version (size).

func DryRun added in v1.3.0

func DryRun(p Plan) Plan

func Offset

func Offset(x, y int, cmd Plan) Plan

func QR

func QR(strokeWidth int, scale int, level qr.Level, content []byte) (Plan, error)

func Rotate

func Rotate(radians float64, cmd Plan) Plan

type Rasterizer

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

func NewRasterizer

func NewRasterizer(img draw.Image, dr image.Rectangle, scale float32, strokeWidth int) *Rasterizer

func (*Rasterizer) Command added in v1.3.0

func (r *Rasterizer) Command(cmd Command)

func (*Rasterizer) Rasterize

func (r *Rasterizer) Rasterize()

type Rect added in v0.10.0

type Rect image.Rectangle

func (Rect) Engrave added in v0.10.0

func (r Rect) Engrave(yield func(Command))

type StringCmd

type StringCmd struct {
	LineHeight int
	// contains filtered or unexported fields
}

func String

func String(face *vector.Face, em int, txt string) *StringCmd

func (*StringCmd) Engrave

func (s *StringCmd) Engrave(yield func(Command))

func (*StringCmd) Measure added in v0.10.0

func (s *StringCmd) Measure() image.Point

Jump to

Keyboard shortcuts

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