dsl

package
v0.0.0-...-04f0d06 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 1 Imported by: 1

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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(left, right interface{}) *ast.BinaryOp

func Atan2

func Atan2(left, right interface{}) *ast.Call

func Call

func Call(name string, parameters ...interface{}) *ast.Call

func Ceil

func Ceil(v interface{}) *ast.Call

func Children

func Children() *ast.Children

func Circle

func Circle(radius interface{}) *ast.Circle

func Concat

func Concat(values ...interface{}) *ast.Call

func Cos

func Cos(v interface{}) *ast.Call

func Cube

func Cube(x, y, z interface{}) *ast.Cube

Cube creates a cube with the given dimensions. There is no Cube(size=XXX), only Cube([X,Y,Z])

func Cylinder

func Cylinder(height, radius1, radius2 interface{}) *ast.Cylinder

func Declare

func Declare(name string, value interface{}) *ast.Declare

func Difference

func Difference(stmts ...ast.Stmt) *ast.Difference

func Div

func Div(left, right interface{}) *ast.BinaryOp

func EQ

func EQ(left, right interface{}) *ast.BinaryOp

func Floor

func Floor(v interface{}) *ast.Call

func For

func For(vars ...*ast.LoopVar) *ast.ForBlock

func ForExpr

func ForExpr(vars ...*ast.LoopVar) *ast.ForExpr

func ForRange

func ForRange(start, end interface{}) *ast.ForRange

func Function

func Function(name string) *ast.Function

func GE

func GE(left, right interface{}) *ast.BinaryOp

func GT

func GT(left, right interface{}) *ast.BinaryOp

func Group

func Group(expr interface{}) *ast.Group

func Hull

func Hull(stmts ...ast.Stmt) *ast.Hull

func Include

func Include(name string) *ast.Include

func Index

func Index(v, index interface{}) *ast.Index

func Intersection

func Intersection(stmts ...ast.Stmt) *ast.Intersection

func LE

func LE(left, right interface{}) *ast.BinaryOp

func LT

func LT(left, right interface{}) *ast.BinaryOp

func Len

func Len(v interface{}) *ast.Call

func LetBlock

func LetBlock(vars ...*ast.Variable) *ast.LetBlock

func LetExpr

func LetExpr(vars ...*ast.Variable) *ast.LetExpr

func LinearExtrude

func LinearExtrude(height, center, convexity, twist, slices interface{}) *ast.LinearExtrude

func List

func List(values ...interface{}) []interface{}

func Lookup

func Lookup(key, values interface{}) *ast.LookupStmt

func LoopVar

func LoopVar(v *ast.Variable, expr interface{}) *ast.LoopVar

func Mod

func Mod(left, right interface{}) *ast.BinaryOp

func Module

func Module(name string) *ast.Module

func Mul

func Mul(left, right interface{}) *ast.BinaryOp

func Negative

func Negative(v interface{}) *ast.UnaryOp

func PI

func PI() *ast.Variable

func Point2D

func Point2D(x, y interface{}) *ast.Point2D

func Polygon

func Polygon(pts, paths interface{}) *ast.Polygon

func Polyhedron

func Polyhedron(points, triangles interface{}) *ast.Polyhedron

func Render

func Render() *ast.Call

func Rotate

func Rotate(v interface{}, children ...ast.Stmt) *ast.Rotate

func Sin

func Sin(v interface{}) *ast.Call

func Sphere

func Sphere(radius interface{}) *ast.Sphere

func Sqrt

func Sqrt(v interface{}) *ast.Call

func Stmts

func Stmts(stmts ...ast.Stmt) ast.Stmts

func Sub

func Sub(left, right interface{}) *ast.BinaryOp

func Tan

func Tan(v interface{}) *ast.Call

func Ternary

func Ternary(cond, left, right interface{}) *ast.TernaryOp

func Translate

func Translate(v interface{}, children ...ast.Stmt) *ast.Translate

func Union

func Union(stmts ...ast.Stmt) *ast.Union

func Use

func Use(name string) *ast.Use

func Variable

func Variable(name string) *ast.Variable

Types

This section is empty.

Jump to

Keyboard shortcuts

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