primitive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Implementation of OpenSCAD primitives. Everything here mostly follows the naming and defaults as defined here: https://openscad.org/cheatsheet/ Additionally, the following new primitives have been added: Anchor, Custom, List, Nothing. These are documented here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor struct {
	ParentImpl
	// contains filtered or unexported fields
}

Anchor enables easy tracking of transforms and enables the alignment of reference frames. This is useful when you need to create or use complex objects that need to be put together in complex ways.

func NewAnchor

func NewAnchor() *Anchor

func (*Anchor) Disable

func (o *Anchor) Disable() Primitive

func (*Anchor) Highlight

func (o *Anchor) Highlight() Primitive

func (*Anchor) Prefix

func (o *Anchor) Prefix() string

func (*Anchor) Render

func (o *Anchor) Render(w *bufio.Writer)

func (*Anchor) ShowOnly

func (o *Anchor) ShowOnly() Primitive

func (*Anchor) Transform

func (o *Anchor) Transform() *Transform

func (*Anchor) Transparent

func (o *Anchor) Transparent() Primitive

type Circular

type Circular struct {
	Fa    float64
	Fs    float64
	Fn    uint16
	FaSet bool
	FsSet bool
	FnSet bool
}

func (*Circular) SetFa

func (o *Circular) SetFa(val float64)

func (*Circular) SetFn

func (o *Circular) SetFn(val uint16)

func (*Circular) SetFs

func (o *Circular) SetFs(val float64)

func (*Circular) String

func (o *Circular) String() string

type Color

type Color struct {
	ParentImpl
	Color string
	Items *List "forward:Add"
	// contains filtered or unexported fields
}

func NewColor

func NewColor(color string, items ...Primitive) *Color

func NewColorV

func NewColorV(r, g, b, a byte, items ...Primitive) *Color

func (*Color) Add

func (o *Color) Add(items ...Primitive) *Color

func (*Color) Disable

func (o *Color) Disable() Primitive

func (*Color) Highlight

func (o *Color) Highlight() Primitive

func (*Color) Prefix

func (o *Color) Prefix() string

func (*Color) Render

func (o *Color) Render(w *bufio.Writer)

func (*Color) ShowOnly

func (o *Color) ShowOnly() Primitive

func (*Color) Transparent

func (o *Color) Transparent() Primitive

type Cube

type Cube struct {
	ParentImpl
	Dims   Vec3
	Center bool "optional"
	// contains filtered or unexported fields
}

func NewCube

func NewCube(dims Vec3) *Cube

func (*Cube) Disable

func (o *Cube) Disable() Primitive

func (*Cube) Highlight

func (o *Cube) Highlight() Primitive

func (*Cube) Prefix

func (o *Cube) Prefix() string

func (*Cube) Render

func (o *Cube) Render(w *bufio.Writer)

func (*Cube) SetCenter

func (o *Cube) SetCenter(val bool) *Cube

func (*Cube) ShowOnly

func (o *Cube) ShowOnly() Primitive

func (*Cube) Transparent

func (o *Cube) Transparent() Primitive

type Custom

type Custom struct {
	ParentImpl
	Code string
	// contains filtered or unexported fields
}

Custom allows you to render arbitrary code in the filal SCAD file.

func NewCustom

func NewCustom(code string) *Custom

func (*Custom) Disable

func (o *Custom) Disable() Primitive

func (*Custom) Highlight

func (o *Custom) Highlight() Primitive

func (*Custom) Prefix

func (o *Custom) Prefix() string

func (*Custom) Render

func (o *Custom) Render(w *bufio.Writer)

func (*Custom) ShowOnly

func (o *Custom) ShowOnly() Primitive

func (*Custom) Transparent

func (o *Custom) Transparent() Primitive

type Cylinder

type Cylinder struct {
	ParentImpl
	H        float64
	RTop     float64
	RBottom  float64   "optional"
	Center   bool      "optional"
	Circular *Circular "forward:SetFa,SetFs,SetFn"
	// contains filtered or unexported fields
}

func NewCylinder

func NewCylinder(h, r float64) *Cylinder

func (*Cylinder) Disable

func (o *Cylinder) Disable() Primitive

func (*Cylinder) Highlight

func (o *Cylinder) Highlight() Primitive

func (*Cylinder) Prefix

func (o *Cylinder) Prefix() string

func (*Cylinder) Render

func (o *Cylinder) Render(w *bufio.Writer)

func (*Cylinder) SetCenter

func (o *Cylinder) SetCenter(val bool) *Cylinder

func (*Cylinder) SetFa

func (o *Cylinder) SetFa(val float64) *Cylinder

func (*Cylinder) SetFn

func (o *Cylinder) SetFn(val uint16) *Cylinder

func (*Cylinder) SetFs

func (o *Cylinder) SetFs(val float64) *Cylinder

func (*Cylinder) SetRBottom

func (o *Cylinder) SetRBottom(val float64) *Cylinder

func (*Cylinder) ShowOnly

func (o *Cylinder) ShowOnly() Primitive

func (*Cylinder) Transparent

func (o *Cylinder) Transparent() Primitive

type Import

type Import struct {
	ParentImpl
	File      string
	Convexity int    "optional"
	Layer     string "optional"
	// contains filtered or unexported fields
}

func NewImport

func NewImport(file string) *Import

func (*Import) Disable

func (o *Import) Disable() Primitive

func (*Import) Highlight

func (o *Import) Highlight() Primitive

func (*Import) Prefix

func (o *Import) Prefix() string

func (*Import) Render

func (o *Import) Render(w *bufio.Writer)

func (*Import) SetConvexity

func (o *Import) SetConvexity(val int) *Import

func (*Import) SetLayer

func (o *Import) SetLayer(val string) *Import

func (*Import) ShowOnly

func (o *Import) ShowOnly() Primitive

func (*Import) Transparent

func (o *Import) Transparent() Primitive

type LinearExtrusion

type LinearExtrusion struct {
	ParentImpl
	Height    float64
	Center    bool    "optional"
	Convexity uint16  "optional"
	Twist     uint16  "optional"
	Slices    uint16  "optional"
	Scale     float64 "optional"
	Fn        uint16  "optional"
	Items     *List   "forward:Add"
	// contains filtered or unexported fields
}

func NewLinearExtrusion

func NewLinearExtrusion(height float64, items ...Primitive) *LinearExtrusion

func (*LinearExtrusion) Add

func (o *LinearExtrusion) Add(items ...Primitive) *LinearExtrusion

func (*LinearExtrusion) Disable

func (o *LinearExtrusion) Disable() Primitive

func (*LinearExtrusion) Highlight

func (o *LinearExtrusion) Highlight() Primitive

func (*LinearExtrusion) Prefix

func (o *LinearExtrusion) Prefix() string

func (*LinearExtrusion) Render

func (o *LinearExtrusion) Render(w *bufio.Writer)

func (*LinearExtrusion) SetCenter

func (o *LinearExtrusion) SetCenter(val bool) *LinearExtrusion

func (*LinearExtrusion) SetConvexity

func (o *LinearExtrusion) SetConvexity(val uint16) *LinearExtrusion

func (*LinearExtrusion) SetFn

func (o *LinearExtrusion) SetFn(val uint16) *LinearExtrusion

func (*LinearExtrusion) SetScale

func (o *LinearExtrusion) SetScale(val float64) *LinearExtrusion

func (*LinearExtrusion) SetSlices

func (o *LinearExtrusion) SetSlices(val uint16) *LinearExtrusion

func (*LinearExtrusion) SetTwist

func (o *LinearExtrusion) SetTwist(val uint16) *LinearExtrusion

func (*LinearExtrusion) ShowOnly

func (o *LinearExtrusion) ShowOnly() Primitive

func (*LinearExtrusion) Transparent

func (o *LinearExtrusion) Transparent() Primitive

type List

type List struct {
	ParentImpl
	Items []Primitive
	// contains filtered or unexported fields
}

List groups operations. It renders curly brackets in the SCAD file.

func NewList

func NewList(items ...Primitive) *List

func (*List) Add

func (o *List) Add(items ...Primitive) *List

func (*List) Disable

func (o *List) Disable() Primitive

func (*List) Highlight

func (o *List) Highlight() Primitive

func (*List) Prefix

func (o *List) Prefix() string

func (*List) Render

func (o *List) Render(w *bufio.Writer)

func (*List) ShowOnly

func (o *List) ShowOnly() Primitive

func (*List) Transparent

func (o *List) Transparent() Primitive

type ListOp

type ListOp struct {
	ParentImpl
	Items *List "forward:Add"
	// contains filtered or unexported fields
}

func NewDifference

func NewDifference(items ...Primitive) *ListOp

func NewHull

func NewHull(items ...Primitive) *ListOp

func NewIntersection

func NewIntersection(items ...Primitive) *ListOp

func NewMinkowski

func NewMinkowski(items ...Primitive) *ListOp

func NewUnion

func NewUnion(items ...Primitive) *ListOp

func (*ListOp) Add

func (o *ListOp) Add(items ...Primitive) *ListOp

func (*ListOp) Disable

func (o *ListOp) Disable() Primitive

func (*ListOp) Highlight

func (o *ListOp) Highlight() Primitive

func (*ListOp) Prefix

func (o *ListOp) Prefix() string

func (*ListOp) Render

func (o *ListOp) Render(w *bufio.Writer)

func (*ListOp) ShowOnly

func (o *ListOp) ShowOnly() Primitive

func (*ListOp) Transparent

func (o *ListOp) Transparent() Primitive

type Nothing

type Nothing struct {
	ParentImpl
	// contains filtered or unexported fields
}

Nothing is a NULL node. It renders a comment in the SCAD file.

func NewNothing

func NewNothing() *Nothing

func (*Nothing) Disable

func (o *Nothing) Disable() Primitive

func (*Nothing) Highlight

func (o *Nothing) Highlight() Primitive

func (*Nothing) Prefix

func (o *Nothing) Prefix() string

func (*Nothing) Render

func (o *Nothing) Render(w *bufio.Writer)

func (*Nothing) ShowOnly

func (o *Nothing) ShowOnly() Primitive

func (*Nothing) Transparent

func (o *Nothing) Transparent() Primitive

type Offset

type Offset struct {
	ParentImpl
	R       float64 "optional"
	Delta   float64 "optional"
	Chamfer bool    "optional"
	Items   *List   "forward:Add"
	// contains filtered or unexported fields
}

func NewOffset

func NewOffset(items ...Primitive) *Offset

func (*Offset) Add

func (o *Offset) Add(items ...Primitive) *Offset

func (*Offset) Disable

func (o *Offset) Disable() Primitive

func (*Offset) Highlight

func (o *Offset) Highlight() Primitive

func (*Offset) Prefix

func (o *Offset) Prefix() string

func (*Offset) Render

func (o *Offset) Render(w *bufio.Writer)

func (*Offset) SetChamfer

func (o *Offset) SetChamfer(val bool) *Offset

func (*Offset) SetDelta

func (o *Offset) SetDelta(val float64) *Offset

func (*Offset) SetR

func (o *Offset) SetR(val float64) *Offset

func (*Offset) ShowOnly

func (o *Offset) ShowOnly() Primitive

func (*Offset) Transparent

func (o *Offset) Transparent() Primitive

type ParentImpl

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

func (*ParentImpl) Parent

func (o *ParentImpl) Parent() Primitive

func (*ParentImpl) SetParent

func (o *ParentImpl) SetParent(p Primitive)

type Polygon

type Polygon struct {
	ParentImpl
	Points    []Vec2
	Paths     [][]int "optional"
	Convexity int     "optional"
	// contains filtered or unexported fields
}

func NewPolygon

func NewPolygon(points []Vec2) *Polygon

func (*Polygon) Disable

func (o *Polygon) Disable() Primitive

func (*Polygon) Highlight

func (o *Polygon) Highlight() Primitive

func (*Polygon) Prefix

func (o *Polygon) Prefix() string

func (*Polygon) Render

func (o *Polygon) Render(w *bufio.Writer)

func (*Polygon) SetConvexity

func (o *Polygon) SetConvexity(val int) *Polygon

func (*Polygon) SetPaths

func (o *Polygon) SetPaths(val [][]int) *Polygon

func (*Polygon) ShowOnly

func (o *Polygon) ShowOnly() Primitive

func (*Polygon) Transparent

func (o *Polygon) Transparent() Primitive

type Polyhedron

type Polyhedron struct {
	ParentImpl
	Points    []Vec3
	Faces     []Vec3
	Convexity int "optional"
	// contains filtered or unexported fields
}

func NewPolyhedron

func NewPolyhedron(points []Vec3, faces []Vec3) *Polyhedron

func (*Polyhedron) Disable

func (o *Polyhedron) Disable() Primitive

func (*Polyhedron) Highlight

func (o *Polyhedron) Highlight() Primitive

func (*Polyhedron) Prefix

func (o *Polyhedron) Prefix() string

func (*Polyhedron) Render

func (o *Polyhedron) Render(w *bufio.Writer)

func (*Polyhedron) SetConvexity

func (o *Polyhedron) SetConvexity(val int) *Polyhedron

func (*Polyhedron) ShowOnly

func (o *Polyhedron) ShowOnly() Primitive

func (*Polyhedron) Transparent

func (o *Polyhedron) Transparent() Primitive

type Primitive

type Primitive interface {
	SetParent(Primitive)
	Parent() Primitive
	Disable() Primitive
	Highlight() Primitive
	ShowOnly() Primitive
	Transparent() Primitive
	Prefix() string
	Render(w *bufio.Writer)
}

type Render

type Render struct {
	ParentImpl
	Convexity uint16
	Items     *List "forward:Add"
	// contains filtered or unexported fields
}

func NewRender

func NewRender(convexity uint16, items ...Primitive) *Render

func (*Render) Add

func (o *Render) Add(items ...Primitive) *Render

func (*Render) Disable

func (o *Render) Disable() Primitive

func (*Render) Highlight

func (o *Render) Highlight() Primitive

func (*Render) Prefix

func (o *Render) Prefix() string

func (*Render) Render

func (o *Render) Render(w *bufio.Writer)

func (*Render) ShowOnly

func (o *Render) ShowOnly() Primitive

func (*Render) Transparent

func (o *Render) Transparent() Primitive

type RotationExtrusion

type RotationExtrusion struct {
	ParentImpl
	Angle     float64   "optional"
	Convexity uint16    "optional"
	Circular  *Circular "forward:SetFa,SetFs,SetFn"
	Items     *List     "forward:Add"
	// contains filtered or unexported fields
}

func NewRotationExtrusion

func NewRotationExtrusion(items ...Primitive) *RotationExtrusion

func (*RotationExtrusion) Add

func (o *RotationExtrusion) Add(items ...Primitive) *RotationExtrusion

func (*RotationExtrusion) Disable

func (o *RotationExtrusion) Disable() Primitive

func (*RotationExtrusion) Highlight

func (o *RotationExtrusion) Highlight() Primitive

func (*RotationExtrusion) Prefix

func (o *RotationExtrusion) Prefix() string

func (*RotationExtrusion) Render

func (o *RotationExtrusion) Render(w *bufio.Writer)

func (*RotationExtrusion) SetAngle

func (o *RotationExtrusion) SetAngle(val float64) *RotationExtrusion

func (*RotationExtrusion) SetConvexity

func (o *RotationExtrusion) SetConvexity(val uint16) *RotationExtrusion

func (*RotationExtrusion) SetFa

func (*RotationExtrusion) SetFn

func (*RotationExtrusion) SetFs

func (*RotationExtrusion) ShowOnly

func (o *RotationExtrusion) ShowOnly() Primitive

func (*RotationExtrusion) Transparent

func (o *RotationExtrusion) Transparent() Primitive

type Scale

type Scale struct {
	ParentImpl
	Scale Vec3
	Items *List "forward:Add"
	// contains filtered or unexported fields
}

func NewScale

func NewScale(scale Vec3, items ...Primitive) *Scale

func (*Scale) Add

func (o *Scale) Add(items ...Primitive) *Scale

func (*Scale) Disable

func (o *Scale) Disable() Primitive

func (*Scale) Highlight

func (o *Scale) Highlight() Primitive

func (*Scale) Prefix

func (o *Scale) Prefix() string

func (*Scale) Render

func (o *Scale) Render(w *bufio.Writer)

func (*Scale) ShowOnly

func (o *Scale) ShowOnly() Primitive

func (*Scale) Transparent

func (o *Scale) Transparent() Primitive

type Sphere

type Sphere struct {
	ParentImpl
	Radius   float64
	Circular *Circular "forward:SetFa,SetFs,SetFn"
	// contains filtered or unexported fields
}

func NewCircle

func NewCircle(radius float64) *Sphere

func NewSphere

func NewSphere(radius float64) *Sphere

func (*Sphere) Disable

func (o *Sphere) Disable() Primitive

func (*Sphere) Highlight

func (o *Sphere) Highlight() Primitive

func (*Sphere) Prefix

func (o *Sphere) Prefix() string

func (*Sphere) Render

func (o *Sphere) Render(w *bufio.Writer)

func (*Sphere) SetFa

func (o *Sphere) SetFa(val float64) *Sphere

func (*Sphere) SetFn

func (o *Sphere) SetFn(val uint16) *Sphere

func (*Sphere) SetFs

func (o *Sphere) SetFs(val float64) *Sphere

func (*Sphere) ShowOnly

func (o *Sphere) ShowOnly() Primitive

func (*Sphere) Transparent

func (o *Sphere) Transparent() Primitive

type Square

type Square struct {
	ParentImpl
	Dims   Vec2
	Center bool "optional"
	// contains filtered or unexported fields
}

func NewSquare

func NewSquare(dims Vec2) *Square

func (*Square) Disable

func (o *Square) Disable() Primitive

func (*Square) Highlight

func (o *Square) Highlight() Primitive

func (*Square) Prefix

func (o *Square) Prefix() string

func (*Square) Render

func (o *Square) Render(w *bufio.Writer)

func (*Square) SetCenter

func (o *Square) SetCenter(val bool) *Square

func (*Square) ShowOnly

func (o *Square) ShowOnly() Primitive

func (*Square) Transparent

func (o *Square) Transparent() Primitive

type Surface

type Surface struct {
	ParentImpl
	File      string
	Center    bool "optional"
	Invert    bool "optional"
	Convexity int  "optional"
	// contains filtered or unexported fields
}

func NewSurface

func NewSurface(file string) *Surface

func (*Surface) Disable

func (o *Surface) Disable() Primitive

func (*Surface) Highlight

func (o *Surface) Highlight() Primitive

func (*Surface) Prefix

func (o *Surface) Prefix() string

func (*Surface) Render

func (o *Surface) Render(w *bufio.Writer)

func (*Surface) SetCenter

func (o *Surface) SetCenter(val bool) *Surface

func (*Surface) SetConvexity

func (o *Surface) SetConvexity(val int) *Surface

func (*Surface) SetInvert

func (o *Surface) SetInvert(val bool) *Surface

func (*Surface) ShowOnly

func (o *Surface) ShowOnly() Primitive

func (*Surface) Transparent

func (o *Surface) Transparent() Primitive

type Text

type Text struct {
	ParentImpl
	Text      string
	Size      uint16 "optional"
	Font      string "optional"
	Halign    string "optional"
	Valign    string "optional"
	Spacing   uint16 "optional"
	Direction string "optional"
	Language  string "optional"
	Script    string "optional"
	Fn        uint16 "optional"
	// contains filtered or unexported fields
}

func NewText

func NewText(text string) *Text

func (*Text) Disable

func (o *Text) Disable() Primitive

func (*Text) Highlight

func (o *Text) Highlight() Primitive

func (*Text) Prefix

func (o *Text) Prefix() string

func (*Text) Render

func (o *Text) Render(w *bufio.Writer)

func (*Text) SetDirection

func (o *Text) SetDirection(val string) *Text

func (*Text) SetFn

func (o *Text) SetFn(val uint16) *Text

func (*Text) SetFont

func (o *Text) SetFont(val string) *Text

func (*Text) SetHalign

func (o *Text) SetHalign(val string) *Text

func (*Text) SetLanguage

func (o *Text) SetLanguage(val string) *Text

func (*Text) SetScript

func (o *Text) SetScript(val string) *Text

func (*Text) SetSize

func (o *Text) SetSize(val uint16) *Text

func (*Text) SetSpacing

func (o *Text) SetSpacing(val uint16) *Text

func (*Text) SetValign

func (o *Text) SetValign(val string) *Text

func (*Text) ShowOnly

func (o *Text) ShowOnly() Primitive

func (*Text) Transparent

func (o *Text) Transparent() Primitive

type Transform

type Transform struct {
	ParentImpl
	Items *List "forward:Add"
	// contains filtered or unexported fields
}

func NewRotation

func NewRotation(angle Vec3, items ...Primitive) *Transform

func NewRotationByAxis

func NewRotationByAxis(angle float64, vector Vec3, items ...Primitive) *Transform

func NewTranslation

func NewTranslation(vector Vec3, items ...Primitive) *Transform

func (*Transform) Add

func (o *Transform) Add(items ...Primitive) *Transform

func (*Transform) Append

func (o *Transform) Append(t *Transform)

func (*Transform) Disable

func (o *Transform) Disable() Primitive

func (*Transform) Highlight

func (o *Transform) Highlight() Primitive

func (*Transform) Inverse

func (o *Transform) Inverse() *Transform

func (*Transform) Prefix

func (o *Transform) Prefix() string

func (*Transform) Render

func (o *Transform) Render(w *bufio.Writer)

func (*Transform) ShowOnly

func (o *Transform) ShowOnly() Primitive

func (*Transform) Transparent

func (o *Transform) Transparent() Primitive

Jump to

Keyboard shortcuts

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