gleamscad

Types

pub type CenteredOrNot {
  Centered
  NotCentered
}

Constructors

  • Centered
  • NotCentered

builder pattern for our OpenSCAD expressions:

pub type OpenSCADExpr {
  Union(expressions: List(OpenSCADExpr))
  Difference(expressions: List(OpenSCADExpr))
  Intersection(expressions: List(OpenSCADExpr))
  Translate(expr: OpenSCADExpr, vector: #(Float, Float, Float))
  Rotate(expr: OpenSCADExpr, angle: #(Float, Float, Float))
  Scale(expr: OpenSCADExpr, vector: #(Float, Float, Float))
  Mirror(expr: OpenSCADExpr, vector: #(Float, Float, Float))
  Circle(value: Float, rod: RadiusOrDiameter)
  Square(width: Float, height: Float, center: CenteredOrNot)
  Polygon(List(#(Float, Float)))
  Cube(size: #(Float, Float, Float), center: CenteredOrNot)
  Sphere(value: Float, rod: RadiusOrDiameter)
  Cylinder(
    height: Float,
    value: Float,
    rod: RadiusOrDiameter,
    center: CenteredOrNot,
  )
  Cylinder2(
    height: Float,
    value1: Float,
    value2: Float,
    rod: RadiusOrDiameter,
    center: CenteredOrNot,
  )
  LinearExtrude(
    expr: OpenSCADExpr,
    height: Float,
    center: CenteredOrNot,
    convexity: Float,
    twist: Float,
    slices: Float,
  )
  CustomCode(code: String)
}

Constructors

pub type RadiusOrDiameter {
  Radius
  Diameter
}

Constructors

  • Radius
  • Diameter

Values

pub fn circle(
  value: Float,
  rod: RadiusOrDiameter,
) -> OpenSCADExpr

Draws a 2d circle

pub fn cube(size: Float, center: CenteredOrNot) -> OpenSCADExpr

Creates a 3d cube with all sides of equal length

pub fn cube3(
  width: Float,
  depth: Float,
  height: Float,
  center: CenteredOrNot,
) -> OpenSCADExpr

Creates a 3d cube

pub fn custom_code(code: String) -> OpenSCADExpr

Allows for adding custom code

pub fn cylinder(
  height: Float,
  value: Float,
  rod: RadiusOrDiameter,
  center: CenteredOrNot,
) -> OpenSCADExpr

Creates a 3d cylinder

pub fn cylinder2(
  height: Float,
  value1: Float,
  value2: Float,
  rod: RadiusOrDiameter,
  center: CenteredOrNot,
) -> OpenSCADExpr

Creates a 3d cylinder. Enables you to pass different diameters/radii for top and bottom

pub fn difference(
  expressions: List(OpenSCADExpr),
) -> OpenSCADExpr

Create a difference of shapes

pub fn intersection(
  expressions: List(OpenSCADExpr),
) -> OpenSCADExpr

Creates an intersection of shapes

pub fn linear_extrude(
  expr: OpenSCADExpr,
  height: Float,
  center: CenteredOrNot,
  convexity: Float,
  twist: Float,
  slices: Float,
) -> OpenSCADExpr
pub fn mirror(
  expr: OpenSCADExpr,
  x: Float,
  y: Float,
  z: Float,
) -> OpenSCADExpr

Mirrors a shape

pub fn polygon(polygons: List(#(Float, Float))) -> OpenSCADExpr

Draws a 2d polygon

pub fn rotate(
  expr: OpenSCADExpr,
  x: Float,
  y: Float,
  z: Float,
) -> OpenSCADExpr

Rotate a shape

pub fn scale(
  expr: OpenSCADExpr,
  x: Float,
  y: Float,
  z: Float,
) -> OpenSCADExpr

Scales a shape

pub fn sphere(
  value: Float,
  rod: RadiusOrDiameter,
) -> OpenSCADExpr

Creates a 3d sphere

pub fn square(
  width: Float,
  height: Float,
  center: CenteredOrNot,
) -> OpenSCADExpr

Draws a 2d square

pub fn to_openscad(expr: OpenSCADExpr) -> String

Exports the data to a string, containing OpenSCAD code

pub fn translate(
  expr: OpenSCADExpr,
  x: Float,
  y: Float,
  z: Float,
) -> OpenSCADExpr

Translate (move) a shape

pub fn union(expressions: List(OpenSCADExpr)) -> OpenSCADExpr

Create a union of shapes

Search Document