gerber

package module
v0.0.0-...-91a30e5 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Gerber parser Go Reference

Documentation

Overview

Package gerber provides a parser for Gerber files.

Index

Constants

View Source
const (
	// Linear interpolation.
	InterpolationLinear Interpolation = iota
	// Clockwise arc interpolation
	InterpolationClockwise
	// Counter clockwise arc interpolation.
	InterpolationCCW

	// LineCapButt strokes do not extend beyond a line's two endpoints.
	LineCapButt LineCap = "butt"
	// LineCapRound strokes will be extended by a half circle with a diameter equal to the stroke width.
	LineCapRound LineCap = "round"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Contour

type Contour struct {
	Line     int
	X        int
	Y        int
	Segments []Segment
	Polarity bool
}

A Contour is a closed sequence of connected linear or circular segments.

type Interpolation

type Interpolation int

An Interpolation is a Gerber interpolation method.

type LineCap

type LineCap string

A LineCap is the shape at the endpoints of a line.

type LinePrimitiveNotClosedError

type LinePrimitiveNotClosedError struct {
	Line     int
	First    [2]float64
	Last     [2]float64
	FirstStr [2]string
	LastStr  [2]string
}

func (LinePrimitiveNotClosedError) Error

func (err LinePrimitiveNotClosedError) Error() string

type Parser

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

A Parser is a Gerber format parser. For each graphical operation parsed from an input stream, Parser calls the corresponding method of its Processor.

func NewParser

func NewParser(pc Processor) *Parser

NewParser creates a Parser.

func (*Parser) Parse

func (parser *Parser) Parse(r io.Reader) error

Parse parses the Gerber format stream.

type Processor

type Processor interface {
	// SetDecimal sets the multiplier to convert from millimeters to Gerber units..
	SetDecimal(decimal float64)

	// Circle draws a circle.
	Circle(lineIdx, x, y, diameter int, polarity bool)

	// Rectangle draws a rectangle.
	Rectangle(lineIdx, x, y, width, height int, polarity bool)

	// Obround draws an obround.
	Obround(lineIdx, x, y, width, height int, polarity bool)

	// Contour draws a contour.
	Contour(Contour) error

	// Line draws a line.
	Line(lineIdx, x0, y0, x1, y1, diameter int, linecap LineCap)

	// Arc draws an arc.
	Arc(lineIdx, xs, ys, xe, ye, xc, yc int, interpolation Interpolation, diameter int) error

	// SetViewbox sets the viewbox of the Gerber image.
	// It is called by the Parser when parsing has completed.
	SetViewbox(minX, maxX, minY, maxY int)
}

A Processor performs Gerber graphic operations. For an example implementation, visit https://pkg.go.dev/github.com/fumin/gerber/svg .

type Segment

type Segment struct {
	Interpolation Interpolation
	X             int
	Y             int
	CenterX       int
	CenterY       int
}

A Segment is a stroked line.

Directories

Path Synopsis
Package svg parses Gerber to SVG.
Package svg parses Gerber to SVG.

Jump to

Keyboard shortcuts

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