gerber

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package gerber writes Gerber RS274X files (for PCBs).

Index

Constants

View Source
const (
	XLeft   = fonts.XLeft
	XCenter = fonts.XCenter
	XRight  = fonts.XRight
	YBottom = fonts.YBottom
	YCenter = fonts.YCenter
	YTop    = fonts.YTop
)

Variables

View Source
var (
	BottomLeft   = fonts.BottomLeft
	BottomCenter = fonts.BottomCenter
	BottomRight  = fonts.BottomRight
	CenterLeft   = fonts.CenterLeft
	Center       = fonts.Center
	CenterRight  = fonts.CenterRight
	TopLeft      = fonts.TopLeft
	TopCenter    = fonts.TopCenter
	TopRight     = fonts.TopRight
)

Functions

This section is empty.

Types

type Aperture

type Aperture struct {
	Shape Shape
	Size  float64
}

Aperture represents the nature of the primitive and satisfies the Primitive interface.

func (*Aperture) Aperture

func (a *Aperture) Aperture() *Aperture

Aperture is defined to implement the Primitive interface.

func (*Aperture) ID

func (a *Aperture) ID() string

ID returns a unique ID for the Aperture.

func (*Aperture) MBB

func (a *Aperture) MBB() MBB

func (*Aperture) WriteGerber

func (a *Aperture) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the aperture to the Gerber file.

type ArcT

type ArcT struct {
	Center     Pt
	Radius     float64
	Shape      Shape
	XScale     float64
	YScale     float64
	StartAngle float64
	EndAngle   float64
	Thickness  float64
	// contains filtered or unexported fields
}

ArcT represents an arc and satisfies the Primitive interface.

func Arc

func Arc(
	center Pt,
	radius float64,
	shape Shape,
	xScale, yScale, startAngle, endAngle float64,
	thickness float64) *ArcT

Arc returns an arc primitive. All dimensions are in millimeters. Angles are specified in degrees (and stored as radians).

func (*ArcT) Aperture

func (a *ArcT) Aperture() *Aperture

Aperture returns the primitive's desired aperture.

func (*ArcT) MBB

func (a *ArcT) MBB() MBB

func (*ArcT) WriteGerber

func (a *ArcT) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the primitive to the Gerber file.

type CircleT

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

CircleT represents a circle and satisfies the Primitive interface.

func Circle

func Circle(center Pt, thickness float64) *CircleT

Circle returns a circle primitive. All dimensions are in millimeters.

func (*CircleT) Aperture

func (c *CircleT) Aperture() *Aperture

Aperture returns the primitive's desired aperture.

func (*CircleT) MBB

func (c *CircleT) MBB() MBB

func (*CircleT) WriteGerber

func (c *CircleT) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the primitive to the Gerber file.

type Gerber

type Gerber struct {
	// FilenamePrefix is the filename prefix for the Gerber design files.
	FilenamePrefix string
	// Layers represents the layers making up the Gerber design.
	Layers []*Layer
	// contains filtered or unexported fields
}

Gerber represents the layers needed to build a PCB.

func New

func New(filenamePrefix string) *Gerber

New returns a new Gerber design. filenamePrefix is the base filename for all gerber files (e.g. "bifilar-coil").

func (*Gerber) BottomCopper

func (g *Gerber) BottomCopper() *Layer

BottomCopper adds a bottom copper layer to the design and returns the layer.

func (*Gerber) BottomSilkscreen

func (g *Gerber) BottomSilkscreen() *Layer

BottomSilkscreen adds a bottom silkscreen layer to the design and returns the layer.

func (*Gerber) BottomSolderMask

func (g *Gerber) BottomSolderMask() *Layer

BottomSolderMask adds a bottom solder mask layer to the design and returns the layer.

func (*Gerber) Drill

func (g *Gerber) Drill() *Layer

Drill adds a drill layer to the design and returns the layer.

func (*Gerber) LayerN

func (g *Gerber) LayerN(n int) *Layer

LayerN adds a layer-n copper layer to a multi-layer design and returns the layer.

func (*Gerber) MBB

func (g *Gerber) MBB() MBB

MBB returns the minimum bounding box of the design in millimeters.

func (*Gerber) Outline

func (g *Gerber) Outline() *Layer

Outline adds an outline layer to the design and returns the layer.

func (*Gerber) TopCopper

func (g *Gerber) TopCopper() *Layer

TopCopper adds a top copper layer to the design and returns the layer.

func (*Gerber) TopSilkscreen

func (g *Gerber) TopSilkscreen() *Layer

TopSilkscreen adds a top silkscreen layer to the design and returns the layer.

func (*Gerber) TopSolderMask

func (g *Gerber) TopSolderMask() *Layer

TopSolderMask adds a top solder mask layer to the design and returns the layer.

func (*Gerber) WriteGerber

func (g *Gerber) WriteGerber() error

WriteGerber writes all the Gerber layers to their respective files then zips them all together into a ZIP file with the same prefix for sending to PCB manufacturers.

type Layer

type Layer struct {
	// Filename is the filename of the Gerber layer.
	Filename string
	// Primitives represents the collection of primitives.
	Primitives []Primitive
	// Apertures represents the apertures used in the layer.
	Apertures []*Aperture
	// contains filtered or unexported fields
}

Layer represents a printed circuit board layer.

func (*Layer) Add

func (l *Layer) Add(primitives ...Primitive)

Add adds primitives to a layer. It generates new apertures as necessary.

func (*Layer) MBB

func (l *Layer) MBB() MBB

MBB returns the minimum bounding box of the layer in millimeters.

func (*Layer) WriteGerber

func (l *Layer) WriteGerber(w io.Writer) error

WriteGerber writes a layer to its corresponding Gerber layer file.

type LineT

type LineT struct {
	P1, P2    Pt
	Shape     Shape
	Thickness float64
	// contains filtered or unexported fields
}

LineT represents a line and satisfies the Primitive interface.

func Line

func Line(x1, y1, x2, y2 float64, shape Shape, thickness float64) *LineT

Line returns a line primitive. All dimensions are in millimeters.

func (*LineT) Aperture

func (l *LineT) Aperture() *Aperture

Aperture returns the primitive's desired aperture.

func (*LineT) MBB

func (l *LineT) MBB() MBB

func (*LineT) WriteGerber

func (l *LineT) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the primitive to the Gerber file.

type MBB

type MBB = vec2.Rect

MBB represents a minimum bounding box.

type PolygonT

type PolygonT struct {
	Offset Pt
	Points []Pt
	// contains filtered or unexported fields
}

PolygonT represents a polygon and satisfies the Primitive interface.

func Polygon

func Polygon(offset Pt, filled bool, points []Pt, thickness float64) *PolygonT

Polygon returns a polygon primitive. All dimensions are in millimeters.

func (*PolygonT) Aperture

func (p *PolygonT) Aperture() *Aperture

Aperture returns nil for PolygonT because it uses the default aperture.

func (*PolygonT) MBB

func (p *PolygonT) MBB() MBB

func (*PolygonT) WriteGerber

func (p *PolygonT) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the primitive to the Gerber file.

type Primitive

type Primitive interface {
	WriteGerber(w io.Writer, apertureIndex int) error
	Aperture() *Aperture
	// MBB returns the minimum bounding box in millimeters.
	MBB() MBB
}

Primitive is a Gerber primitive.

type Pt

type Pt = vec2.T

Pt represents a 2D Point.

func Point

func Point(x, y float64) Pt

Point is a simple convenience function that keeps the code easy to read. All dimensions are in millimeters.

type Shape

type Shape string

Shape represents the type of shape the apertures use.

const (
	// RectShape uses rectangles for the aperture.
	RectShape Shape = "R"
	// CircleShape uses circles for the aperture.
	CircleShape Shape = "C"
)

type TextOpts

type TextOpts = fonts.TextOpts

TextOpts provides options for positioning (aligning) the text based on its minimum bounding box.

type TextT

type TextT struct {
	Render *fonts.Render
	// contains filtered or unexported fields
}

TextT represents text and satisfies the Primitive interface.

func Text

func Text(x, y, xScale float64, message, fontName string, pts float64, opts *TextOpts) *TextT

Text returns a text primitive. All dimensions are in millimeters. xScale is 1.0 for top silkscreen and -1.0 for bottom silkscreen.

func TextBox

func TextBox(mbb MBB, xScale float64, message, fontName string, opts *TextOpts) *TextT

TextBox returns a text primitive where the text fills the MBB and aligns the text according to TextOpts. All dimensions are in millimeters. xScale is 1.0 for top silkscreen and -1.0 for bottom silkscreen.

func (*TextT) Aperture

func (t *TextT) Aperture() *Aperture

Aperture returns nil for TextT because it uses the default aperture.

func (*TextT) Height

func (t *TextT) Height() float64

Height returns the height of the text in millimeters

func (*TextT) MBB

func (t *TextT) MBB() MBB

func (*TextT) Width

func (t *TextT) Width() float64

Width returns the width of the text in millimeters.

func (*TextT) WriteGerber

func (t *TextT) WriteGerber(w io.Writer, apertureIndex int) error

WriteGerber writes the primitive to the Gerber file.

Directories

Path Synopsis
Package viewer views a Gerber design using Fyne.
Package viewer views a Gerber design using Fyne.

Jump to

Keyboard shortcuts

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