gerber

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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

	InterpolationSingleQuadrantClockwise = 11
	InterpolationSingleQuadrantCCCW      = 12
	InterpolationMultiQuadrantClockwise  = 13
	InterpolationMultiQuadrantCCW        = 14

	InterpolationCircularFlag  = 1
	InterpolationDirectionFlag = 2
	InterpolationQuadrantFlag  = 3

	// 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 Arc

type Arc struct {
	Line int
	geom.CircularArc2
	StrokeWidth float64
	Interpolation
}

func (*Arc) Bounds

func (e *Arc) Bounds() *geom.Bounds

Bounds returns the result.

type Circle

type Circle struct {
	Line     int
	Polarity bool
	geom.Circle
}

func (*Circle) Bounds

func (e *Circle) Bounds() *geom.Bounds

Bounds returns the result.

type Contour

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

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

func (*Contour) Bounds

func (e *Contour) Bounds() *geom.Bounds

Bounds returns the result.

type Interpolation

type Interpolation int

An Interpolation is a Gerber interpolation method.

type Line

type Line struct {
	LineNo int
	geom.LineSegment
	StrokeWidth float64
	Cap         LineCap
}

func (*Line) Bounds

func (e *Line) Bounds() *geom.Bounds

Bounds returns the result.

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

Error returns the error message string.

type Loayer

type Loayer string
const (
	GTL Loayer = "GTL" //top copper
	GBL Loayer = "GBL" //bottom copper
	GTO Loayer = "GTO" //top silkscreen
	GBO Loayer = "GBO" //bottom silkscreen
	GTS Loayer = "GTS" // top solder mask
	GBS Loayer = "GBS" //bottom solder mask
	GPT Loayer = "GPT" //top paste
	GPB Loayer = "GPB" //bottom paste
	G1  Loayer = "G1"  //inner copper 1
	G2  Loayer = "G2"  //inner copper 2
	G3  Loayer = "G3"  //inner copper 3
	G4  Loayer = "G4"  //inner copper 4
	GP1 Loayer = "GP1" //inner plane 1 (negative)
	GP2 Loayer = "GP2" //inner plane 2 (negative)
	GM1 Loayer = "GM1" //mechanical 1
	GM2 Loayer = "GM2" //mechanical 2
	GM3 Loayer = "GM3" //mechanical 3
	GM4 Loayer = "GM4" //mechanical 4
	GKO Loayer = "GKO" //keep-out / board outline
)

type LogProcessor

type LogProcessor struct {
}

func (LogProcessor) Arc

func (l LogProcessor) Arc(arc *Arc)

Arc performs the operation.

func (LogProcessor) Circle

func (l LogProcessor) Circle(circle *Circle)

Circle performs the operation.

func (LogProcessor) Contour

func (l LogProcessor) Contour(contour *Contour)

Contour performs the operation.

func (LogProcessor) Line

func (l LogProcessor) Line(line *Line)

Line performs the operation.

func (LogProcessor) Obround

func (l LogProcessor) Obround(obround *Obround)

Obround performs the operation.

func (LogProcessor) Rectangle

func (l LogProcessor) Rectangle(rectangle *Rectangle)

Rectangle performs the operation.

func (LogProcessor) SetViewBox

func (l LogProcessor) SetViewBox(box *ViewBox)

SetViewBox updates or inserts a value.

type Obround

type Obround struct {
	Line     int
	Polarity bool
	geom.Rectangle
}

func (*Obround) Bounds

func (e *Obround) Bounds() *geom.Bounds

Bounds returns the result.

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 {
	// Circle draws a circle.
	Circle(*Circle)

	// Rectangle draws a rectangle.
	Rectangle(*Rectangle)

	// Obround(oval) draws an olav.
	Obround(*Obround)

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

	// Line draws a line.
	Line(*Line)

	// Arc draws an arc.
	Arc(*Arc)

	// SetViewbox sets the viewbox of the Gerber image.
	// It is called by the Parser when parsing has completed.
	SetViewBox(*ViewBox)
}

type Rectangle

type Rectangle struct {
	Line     int
	Polarity bool
	geom.Rectangle
}

func (*Rectangle) Bounds

func (e *Rectangle) Bounds() *geom.Bounds

Bounds returns the result.

type Segment

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

A Segment is a stroked line.

type StoreProcessor

type StoreProcessor struct {
	Circles  []*Circle
	Rects    []*Rectangle
	Obrounds []*Obround
	Lines    []*Line
	Contours []*Contour
	Arcs     []*Arc
	ViewBox  *ViewBox
}

func (*StoreProcessor) Arc

func (s *StoreProcessor) Arc(arc *Arc)

Arc performs the operation.

func (*StoreProcessor) Circle

func (s *StoreProcessor) Circle(circle *Circle)

Circle performs the operation.

func (*StoreProcessor) Contour

func (s *StoreProcessor) Contour(contour *Contour)

Contour performs the operation.

func (*StoreProcessor) Line

func (s *StoreProcessor) Line(line *Line)

Line performs the operation.

func (*StoreProcessor) Obround

func (s *StoreProcessor) Obround(obround *Obround)

Obround performs the operation.

func (*StoreProcessor) Rectangle

func (s *StoreProcessor) Rectangle(rectangle *Rectangle)

Rectangle performs the operation.

func (*StoreProcessor) SetViewBox

func (s *StoreProcessor) SetViewBox(box *ViewBox)

SetViewBox updates or inserts a value.

type Unit

type Unit string
const (
	UnitMillimeter Unit = "mm"
	UnitInch       Unit = "inch"
)

type ViewBox

type ViewBox = geom.Bounds

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