Documentation ¶
Index ¶
- func AddIndent(ctx context.Context) context.Context
- func Emit(stmt Stmt, w io.Writer, options ...EmitOption) error
- func EmitFile(filename string, w io.Writer, options ...EmitFileOption) error
- func EmitString(stmt Stmt, options ...EmitOption) (string, error)
- func GetIndent(ctx context.Context) string
- func Register(name string, s Stmt) error
- func WriteFile(filename string, options ...WriteFileOption) error
- type BareBlock
- type BinaryOp
- func (op *BinaryOp) BindPrecedence() int
- func (op *BinaryOp) EmitExpr(ctx *EmitContext, w io.Writer) error
- func (op *BinaryOp) EmitStmt(ctx *EmitContext, w io.Writer) error
- func (op *BinaryOp) Left() interface{}
- func (op *BinaryOp) Op() string
- func (op *BinaryOp) Rearrange(op2 *BinaryOp) *BinaryOp
- func (op *BinaryOp) Right() interface{}
- func (op *BinaryOp) String() string
- type Call
- type Children
- type Circle
- type Cube
- type Cylinder
- type Declare
- type Difference
- type ElseIfStmt
- type EmitContext
- func (e *EmitContext) AllowAssignment() bool
- func (e *EmitContext) Amalgamate() bool
- func (e *EmitContext) AsExpr() bool
- func (e *EmitContext) AsStmt() bool
- func (e *EmitContext) Copy() *EmitContext
- func (e *EmitContext) DecrIndent() *EmitContext
- func (e *EmitContext) ForceExpr() *EmitContext
- func (e *EmitContext) ForceStmt() *EmitContext
- func (e *EmitContext) IncrIndent() *EmitContext
- func (e *EmitContext) Indent() string
- func (e *EmitContext) WithAllowAssignment(allowAssignment bool) *EmitContext
- func (e *EmitContext) WithIndent(indent string) *EmitContext
- type EmitFileOption
- type EmitFileWriteFileOption
- type EmitOption
- type EmitWriteFileOption
- type Expr
- type ForBlock
- type ForExpr
- type ForRange
- type Function
- type Group
- type Hull
- type IfExpr
- type IfStmt
- type Include
- type Index
- type Intersection
- type LetBlock
- type LetExpr
- type LinearExtrude
- type LookupStmt
- type LoopVar
- type Module
- type Point2D
- type Point2DList
- type Polygon
- type Polyhedron
- type Registry
- type Rotate
- type Sphere
- type Stmt
- type Stmts
- type TernaryOp
- type Translate
- type UnaryOp
- type Union
- type Use
- type Variable
- type WriteFileOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Emit ¶
func Emit(stmt Stmt, w io.Writer, options ...EmitOption) error
Emit takes a statement (or a list of statements) and emits them into the writer.
By default it emits the statements as a regular OpenSCAD file, but you can ask it to create an "amalgamated" file by passing the WithAmalgamate option.
func EmitString ¶
func EmitString(stmt Stmt, options ...EmitOption) (string, error)
func WriteFile ¶
func WriteFile(filename string, options ...WriteFileOption) error
Types ¶
type BareBlock ¶
type BareBlock struct {
// contains filtered or unexported fields
}
func NewBareBlock ¶
type BinaryOp ¶
type BinaryOp struct {
// contains filtered or unexported fields
}
func NewBinaryOp ¶
func (*BinaryOp) BindPrecedence ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
func (*Call) Parameters ¶
type Children ¶
type Children struct {
// contains filtered or unexported fields
}
Creates a call to the children() module.
func NewChildren ¶
func NewChildren() *Children
type Cylinder ¶
type Cylinder struct {
// contains filtered or unexported fields
}
func NewCylinder ¶
func NewCylinder(height, radius1, radius2 interface{}) *Cylinder
To omit radius2, pass nil
type Difference ¶
type Difference struct {
// contains filtered or unexported fields
}
func NewDifference ¶
func NewDifference(children ...Stmt) *Difference
func (*Difference) Add ¶
func (u *Difference) Add(s Stmt) *Difference
func (*Difference) Body ¶
func (u *Difference) Body(s ...Stmt) *Difference
type ElseIfStmt ¶
type ElseIfStmt struct {
// contains filtered or unexported fields
}
func (*ElseIfStmt) EmitStmt ¶
func (eb *ElseIfStmt) EmitStmt(ctx *EmitContext, w io.Writer) error
type EmitContext ¶
type EmitContext struct {
// contains filtered or unexported fields
}
EmitContext holds the context for emitting OpenSCAD code. The object is immutable once created. To change the values, create a new context using one of the provided methods
func (*EmitContext) AllowAssignment ¶
func (e *EmitContext) AllowAssignment() bool
func (*EmitContext) Amalgamate ¶
func (e *EmitContext) Amalgamate() bool
func (*EmitContext) AsExpr ¶
func (e *EmitContext) AsExpr() bool
func (*EmitContext) AsStmt ¶
func (e *EmitContext) AsStmt() bool
func (*EmitContext) Copy ¶
func (e *EmitContext) Copy() *EmitContext
func (*EmitContext) DecrIndent ¶
func (e *EmitContext) DecrIndent() *EmitContext
func (*EmitContext) ForceExpr ¶
func (e *EmitContext) ForceExpr() *EmitContext
func (*EmitContext) ForceStmt ¶
func (e *EmitContext) ForceStmt() *EmitContext
func (*EmitContext) IncrIndent ¶
func (e *EmitContext) IncrIndent() *EmitContext
func (*EmitContext) Indent ¶
func (e *EmitContext) Indent() string
func (*EmitContext) WithAllowAssignment ¶
func (e *EmitContext) WithAllowAssignment(allowAssignment bool) *EmitContext
func (*EmitContext) WithIndent ¶
func (e *EmitContext) WithIndent(indent string) *EmitContext
type EmitFileOption ¶
type EmitFileOption interface { EmitOption // contains filtered or unexported methods }
type EmitFileWriteFileOption ¶
type EmitFileWriteFileOption interface { EmitOption EmitFileOption EmitWriteFileOption }
EmitFileWriteFileOption is an option that can be passed to Emit(), File() and WriteFile()
func WithAmalgamation ¶
func WithAmalgamation() EmitFileWriteFileOption
func WithRegistry ¶
func WithRegistry(r *Registry) EmitFileWriteFileOption
WithRegistry sets the registry to use when emitting the OpenSCAD code
type EmitOption ¶
type EmitWriteFileOption ¶
type EmitWriteFileOption interface { EmitOption WriteFileOption }
EmitWriteFileOption is an option that can be passed to Emit() and WriteFile()
type Expr ¶
type Expr interface {
EmitExpr(*EmitContext, io.Writer) error
}
Expr represents an expression in the OpenSCAD language.
An arbitrary object may be either an Expr or a Stmt, or both. For example, a *Variable is both an Expr and a Stmt.
type ForBlock ¶
type ForBlock struct {
// contains filtered or unexported fields
}
ForBlock represents a for loop block.
In OpenSCAD for can take two distinctive styles: one as an expression, and one as a statement. ForBlock the expression, use ForExpr
type ForRange ¶
type ForRange struct {
// contains filtered or unexported fields
}
func NewForRange ¶
func NewForRange(start, end interface{}) *ForRange
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
func NewFunction ¶
func (*Function) Parameters ¶
type Intersection ¶
type Intersection struct {
// contains filtered or unexported fields
}
func NewIntersection ¶
func NewIntersection(children ...Stmt) *Intersection
func (*Intersection) Add ¶
func (u *Intersection) Add(s Stmt) *Intersection
func (*Intersection) Body ¶
func (u *Intersection) Body(s ...Stmt) *Intersection
type LetBlock ¶
type LetBlock struct {
// contains filtered or unexported fields
}
func NewLetBlock ¶
type LinearExtrude ¶
type LinearExtrude struct {
// contains filtered or unexported fields
}
func NewLinearExtrude ¶
func NewLinearExtrude(height, center, convexity, twist, scale interface{}, children ...Stmt) *LinearExtrude
func (*LinearExtrude) Add ¶
func (l *LinearExtrude) Add(stmts ...Stmt) *LinearExtrude
func (*LinearExtrude) EmitStmt ¶
func (l *LinearExtrude) EmitStmt(ctx *EmitContext, w io.Writer) error
func (*LinearExtrude) Fn ¶
func (l *LinearExtrude) Fn(fn int) *LinearExtrude
type LookupStmt ¶
type LookupStmt struct {
// contains filtered or unexported fields
}
func NewLookup ¶
func NewLookup(key, values interface{}) *LookupStmt
func (*LookupStmt) EmitExpr ¶
func (l *LookupStmt) EmitExpr(ctx *EmitContext, w io.Writer) error
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) Parameters ¶
type Point2D ¶
type Point2D struct {
// contains filtered or unexported fields
}
func NewPoint2D ¶
func NewPoint2D(x, y interface{}) *Point2D
type Point2DList ¶
type Point2DList []*Point2D
func (*Point2DList) Add ¶
func (l *Point2DList) Add(pt *Point2D)
func (Point2DList) EmitExpr ¶
func (l Point2DList) EmitExpr(ctx *EmitContext, w io.Writer) error
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
func NewPolygon ¶
func NewPolygon(points, paths interface{}) *Polygon
type Polyhedron ¶
type Polyhedron struct {
// contains filtered or unexported fields
}
func NewPolyhedron ¶
func NewPolyhedron(points, faces interface{}) *Polyhedron
func (*Polyhedron) Convexity ¶
func (p *Polyhedron) Convexity(v interface{}) *Polyhedron
func (*Polyhedron) EmitStmt ¶
func (p *Polyhedron) EmitStmt(ctx *EmitContext, w io.Writer) error
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is used to register pieces of OpenSCAD code to a virtual filename.
type Stmt ¶
type Stmt interface {
EmitStmt(*EmitContext, io.Writer) error
}
Stmt repreents an OpenSCAD statement.
An arbitrary object may be either an Expr or a Stmt, or both. For example, a *Variable is both an Expr and a Stmt.
type TernaryOp ¶
type TernaryOp struct {
// contains filtered or unexported fields
}
func NewTernaryOp ¶
func NewTernaryOp(condition, trueExpr, falseExpr interface{}) *TernaryOp
type Translate ¶
type Translate struct {
// contains filtered or unexported fields
}
func NewTranslate ¶
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable represents a variable in the OpenSCAD language. It can be assigned a value so that in appropriate contexts, an assignment statement is emitted.
func NewVariable ¶
type WriteFileOption ¶
func WithOutputDir ¶
func WithOutputDir(dir string) WriteFileOption