Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "os" "github.com/lestrrat-go/openscad/ast" "github.com/lestrrat-go/openscad/dsl" ) func main() { stmts := dsl.Stmts( dsl.Variable("width").Value(30), dsl.Module("foobar"). Parameters(dsl.Variable("width")). Actions( dsl.Rotate( dsl.List(0, 180, 0), dsl.Translate( dsl.List(10, 10, 10), dsl.Cube(dsl.Variable("width"), 40, 5).Fn(24), dsl.Cube(5, 40, dsl.Variable("width")), dsl.Cylinder(10, 5, 15).Fa(12), ), ), ), dsl.Call("foobar"), ) if err := ast.Emit(stmts, os.Stdout); err != nil { fmt.Printf("failed to emit: %s\n", err) } }
Output: width = 30; module foobar(width) { rotate([0, 180, 0]) translate([10, 10, 10]) { cube([width, 40, 5], $fn=24); cube([5, 40, width]); cylinder(h=10, r1=5, r2=15, $fa=12); } } foobar();
Index ¶
- func Add(left, right interface{}) *ast.BinaryOp
- func Atan2(left, right interface{}) *ast.Call
- func Call(name string, parameters ...interface{}) *ast.Call
- func Ceil(v interface{}) *ast.Call
- func Children() *ast.Children
- func Circle(radius interface{}) *ast.Circle
- func Concat(values ...interface{}) *ast.Call
- func Cos(v interface{}) *ast.Call
- func Cube(x, y, z interface{}) *ast.Cube
- func Cylinder(height, radius1, radius2 interface{}) *ast.Cylinder
- func Declare(name string, value interface{}) *ast.Declare
- func Difference(stmts ...ast.Stmt) *ast.Difference
- func Div(left, right interface{}) *ast.BinaryOp
- func EQ(left, right interface{}) *ast.BinaryOp
- func Floor(v interface{}) *ast.Call
- func For(vars ...*ast.LoopVar) *ast.ForBlock
- func ForExpr(vars ...*ast.LoopVar) *ast.ForExpr
- func ForRange(start, end interface{}) *ast.ForRange
- func Function(name string) *ast.Function
- func GE(left, right interface{}) *ast.BinaryOp
- func GT(left, right interface{}) *ast.BinaryOp
- func Group(expr interface{}) *ast.Group
- func Hull(stmts ...ast.Stmt) *ast.Hull
- func Include(name string) *ast.Include
- func Index(v, index interface{}) *ast.Index
- func Intersection(stmts ...ast.Stmt) *ast.Intersection
- func LE(left, right interface{}) *ast.BinaryOp
- func LT(left, right interface{}) *ast.BinaryOp
- func Len(v interface{}) *ast.Call
- func LetBlock(vars ...*ast.Variable) *ast.LetBlock
- func LetExpr(vars ...*ast.Variable) *ast.LetExpr
- func LinearExtrude(height, center, convexity, twist, slices interface{}) *ast.LinearExtrude
- func List(values ...interface{}) []interface{}
- func Lookup(key, values interface{}) *ast.LookupStmt
- func LoopVar(v *ast.Variable, expr interface{}) *ast.LoopVar
- func Mod(left, right interface{}) *ast.BinaryOp
- func Module(name string) *ast.Module
- func Mul(left, right interface{}) *ast.BinaryOp
- func Negative(v interface{}) *ast.UnaryOp
- func PI() *ast.Variable
- func Point2D(x, y interface{}) *ast.Point2D
- func Polygon(pts, paths interface{}) *ast.Polygon
- func Polyhedron(points, triangles interface{}) *ast.Polyhedron
- func Render() *ast.Call
- func Rotate(v interface{}, children ...ast.Stmt) *ast.Rotate
- func Sin(v interface{}) *ast.Call
- func Sphere(radius interface{}) *ast.Sphere
- func Sqrt(v interface{}) *ast.Call
- func Stmts(stmts ...ast.Stmt) ast.Stmts
- func Sub(left, right interface{}) *ast.BinaryOp
- func Tan(v interface{}) *ast.Call
- func Ternary(cond, left, right interface{}) *ast.TernaryOp
- func Translate(v interface{}, children ...ast.Stmt) *ast.Translate
- func Union(stmts ...ast.Stmt) *ast.Union
- func Use(name string) *ast.Use
- func Variable(name string) *ast.Variable
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cube ¶
Cube creates a cube with the given dimensions. There is no Cube(size=XXX), only Cube([X,Y,Z])
func Difference ¶
func Difference(stmts ...ast.Stmt) *ast.Difference
func Intersection ¶
func Intersection(stmts ...ast.Stmt) *ast.Intersection
func LinearExtrude ¶
func LinearExtrude(height, center, convexity, twist, slices interface{}) *ast.LinearExtrude
func Lookup ¶
func Lookup(key, values interface{}) *ast.LookupStmt
func Polyhedron ¶
func Polyhedron(points, triangles interface{}) *ast.Polyhedron
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.