plot

package
v0.0.0-...-9d211eb Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var A4 = XY{210, 297}

Functions

func JsonPlotter

func JsonPlotter(out io.Writer, p Canvas, d Drawing) error

func Run

func Run(p Canvas, d DrawFunc)

Run executes a drawing - use this as entry point for all "sketches"

Types

type Arc

type Arc struct {
	P      XY
	Radius int
}

Arc draws an arc

type BezierCurve

type BezierCurve struct {
	ControlPoints []XY
}

BezierCurve is a drawable bezier curve

type Canvas

type Canvas struct {
	Size  XY
	DPI   int
	Bleed XY
}

Canvas describes the canvas on which we'll draw

func (Canvas) Frame

func (p Canvas) Frame() []Drawable

Frame returns a frame around the canvas

func (Canvas) FrameBleed

func (p Canvas) FrameBleed() []Drawable

Frame returns a frame around the canvas respecting the bleed

func (Canvas) Inner

func (p Canvas) Inner() XY

Inner returns the plot size - 2*bleed

func (Canvas) Middle

func (p Canvas) Middle() XY

Middle returns the middle point of the canvas

func (Canvas) Up

func (p Canvas) Up() XY

Up returns the upper right corner respecting the bleed

func (Canvas) Zero

func (p Canvas) Zero() XY

Zero returns the zero point respecting the bleed

type Debug

type Debug struct {
	D Drawable
}

Debug helps debugging other drawables. Use `AsDebug()`.

type DrawFunc

type DrawFunc func(p Canvas, args map[string]string) (d Drawing, err error)

DrawFunc produces a new drawing

type Drawable

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

Drawable marks all drawable elements

func AsDebug

func AsDebug(ds ...Drawable) []Drawable

AsDebug decorates drawables for debugging

func AsDrawable

func AsDrawable(ls ...Line) []Drawable

AsDrawable convers lines to drawables

type Drawing

type Drawing []Drawable

func OptimiseLinearLineOrder

func OptimiseLinearLineOrder(p Canvas, d Drawing) (Drawing, error)

type GCodeCommand

type GCodeCommand interface {
	fmt.Stringer
	ModifyState(*gcodeState)
}

type GCodeLift

type GCodeLift struct {
	Height   int
	Feedrate int
}

func (GCodeLift) ModifyState

func (l GCodeLift) ModifyState(s *gcodeState)

func (GCodeLift) String

func (l GCodeLift) String() string

type GCodeLinearMoveXY

type GCodeLinearMoveXY struct {
	P        XY
	Feedrate int
	Scale    float64
}

func (GCodeLinearMoveXY) ModifyState

func (l GCodeLinearMoveXY) ModifyState(s *gcodeState)

func (GCodeLinearMoveXY) String

func (l GCodeLinearMoveXY) String() string

type GCodeOpts

type GCodeOpts struct {
	DrawFeed   int     `json:"drawFeed"`
	DrawLift   int     `json:"drawLift"`
	TravelFeed int     `json:"travelFeed"`
	TravelLift int     `json:"travelLift"`
	Scale      float64 `json:"scale"`
	Offset     XY      `json:"offset"`
}

func NewDefaultGCodeOpts

func NewDefaultGCodeOpts() *GCodeOpts

type Line

type Line struct {
	Start XY
	End   XY
}

Line is a drawable line

func (Line) Offset

func (l Line) Offset(p XY) Line

Offset adds the point to start and end point

type OptimisationFunc

type OptimisationFunc func(p Canvas, d Drawing) (Drawing, error)

type PlotFunc

type PlotFunc func(out io.Writer, p Canvas, d Drawing) error

PlotFunc plots a drawing to some output device

func NewGCodePlotter

func NewGCodePlotter(optFN string) (PlotFunc, error)

func NewPNGPlotter

func NewPNGPlotter() PlotFunc

type XY

type XY struct {
	X int
	Y int
}

XY represents XY coordinates

func (XY) Add

func (xy XY) Add(x, y int) XY

Add adds to the coordinates

func (XY) AddF

func (xy XY) AddF(x, y float64) XY

AddF adds floats which are cast to int beforehand

func (XY) AddXY

func (xy XY) AddXY(other XY) XY

AddXY adds another XY pair

func (XY) Div

func (xy XY) Div(f int) XY

Div divides coordinates

func (XY) IsZero

func (xy XY) IsZero() bool

IsZero returns true if the XY is the zero value

func (XY) Mult

func (xy XY) Mult(f int) XY

Mult multiplies coordinates

Jump to

Keyboard shortcuts

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