Shape Generators vox.shapes

Collection of functions for generating various shapes. Each of these methods creates a shape generator function; that is, a function which takes x, y, and z coordinates and returns true or false.

To use these functions in the Add/Remove voxel tool, you need to simply enter a function call, like this:

cuboid 7, 4, 3,  10, 10, 10

The call to cuboid will return a function that will be called on each voxel position (each x,y, and z in the lattice), returning true if the position is on the shape, or false otherwise.

Methods

Call methods with.name(),.name(arguments)or just .name arguments .

  • cube (r, cx, cy, cz) -> Function#

    Builds a generator function to make cubes

    Parameters
    r
    Number

    Radius (in voxels) = width = height = depth

    cx
    Number

    Center X lattice position

    cy
    Number

    Center Y lattice position

    cz
    Number

    Center Z lattice position

    Return
    return
    Function

    generator Generator function to make the cube

  • cuboid (w, h, d, cx, cy, cz, [hollow]) -> Function#

    Builds a generator function to make cuboids (rectangular prisms)

    Parameters
    w
    Number

    Width (in voxels)

    h
    Number

    Height (in voxels)

    d
    Number

    Depth (in voxels)

    cx
    Number

    Center X lattice position

    cy
    Number

    Center Y lattice position

    cz
    Number

    Center Z lattice position

    hollow
    Boolean

    True to create a hollow cuboid

    (Optional; defaults to false)
    Return
    return
    Function

    generator Generator function to make the cuboid

  • intersect (funcs) -> Function#

    Returns a new shape generator function that is the intersection (overlapping part) of several other shape generator functions.

    Example: overlap between a sphere and a cuboid:

    intersect(
        cuboid(4,5,7, 10,10,10),
        sphere(5, 10,10,15)
    )
    

    Note that generator functions need not be builtin:

    intersect(
        cuboid(4,5,7, 10,10,10),
        (x, y, z) -> x % 2 is 0
    )
    
    Parameters
    funcs
    Function[]

    ... Pass any number of shape generator functions as arguments

    Return
    return
    Function

    generator New union shape generator function

  • negate (funcs) -> Function#

    Returns a new shape generator function that is the negation of another shape generator function

    Example: Hollow a sphere out of the lattice

    negate sphereoid(4,5,7, 10,10,10)
    
    Parameters
    funcs
    Function[]

    ... Pass any number of shape generator functions as arguments

    Return
    return
    Function

    generator New union shape generator function

  • sphere (r, cx, cy, cz) -> Function#

    Builds a generator function to make spheres

    Parameters
    r
    Number

    Radius (in voxels) = width = height = depth

    cx
    Number

    Center X lattice position

    cy
    Number

    Center Y lattice position

    cz
    Number

    Center Z lattice position

    Return
    return
    Function

    generator Generator function to make the sphere

  • sphereoid (w, h, d, cx, cy, cz, [hollow]) -> Function#

    Builds a generator function to make sphereoids/ellipsoids

    Parameters
    w
    Number

    Width (in voxels) = X diameter

    h
    Number

    Height (in voxels) = Y diameter

    d
    Number

    Depth (in voxels) = Z diameter

    cx
    Number

    Center X lattice position

    cy
    Number

    Center Y lattice position

    cz
    Number

    Center Z lattice position

    hollow
    Boolean

    True to create a hollow sphereoid

    (Optional; defaults to false)
    Return
    return
    Function

    generator Generator function to make the sphereoid

  • union (funcs) -> Function#

    Returns a new shape generator function that is the union of several other shape generator functions.

    Example: union of a sphere and a cuboid:

    union(
        cuboid(4,5,7, 10,10,10),
        sphere(5, 10,10,15)
    )
    

    Note that generator functions need not be builtin:

    union(
        cuboid(4,5,7, 10,10,10),
        (x, y, z) -> x % 2 is 0
    )
    
    Parameters
    funcs
    Function[]

    ... Pass any number of shape generator functions as arguments

    Return
    return
    Function

    generator New union shape generator function