Liking cljdoc? Tell your friends :D

lambdaisland.witchcraft.shapes

Functions that create common shapes, like a box, ball, torus, tube, etc.

Functions that create common shapes, like a box, ball, torus, tube, etc.
raw docstring

archclj

(arch {:keys [width height start material]})

Creates an arch shape in the xy-plane (z=0), with given width and height. width is really the half-width, the distance from the center block to the side, and it can not be smaller than height. if (= width height) then this is just a half circle, if (< width height) then there a certain amount of 'pointedness' at the top. Note that if (< width height) the actual height might be smaller than the requested height.

Creates an arch shape in the xy-plane (z=0), with given width and height. width
is really the half-width, the distance from the center block to the side, and
it can not be smaller than height. if (= width height) then this is just a
half circle, if (< width height) then there a certain amount of 'pointedness'
at the top. Note that if (< width height) the actual height might be smaller
than the requested height.
sourceraw docstring

ballclj

(ball {:keys [radius center inner-radius material fill] :as opts})

Create a ball shape. By default the inner-radius is one block less than the outer radius, so you get a ball with a "wall" that is one block thick. Set inner-radius to 0 to get a solid ball.

:material is either a keyword, or a function which receives the [x y z] position and returns a keyword.

Returns a sequence of [x y z] or [x y z material], to be passed to [[wc/set-blocks]].

Create a ball shape.
By default the inner-radius is one block less than the outer radius, so you
get a ball with a "wall" that is one block thick. Set inner-radius to 0 to
get a solid ball.

`:material` is either a keyword, or a function which receives the `[x y z]`
position and returns a keyword.

Returns a sequence of `[x y z]` or `[x y z material]`, to be passed
to [[wc/set-blocks]].
sourceraw docstring

ball-fnclj

(ball-fn {:keys [radius center inner-radius]
          :or {inner-radius (- radius 1) center [0 0 0]}})

Return a predicate that checks if the location is part of the ball.

Return a predicate that checks if the location is part of the ball.
sourceraw docstring

boxclj

(box {:keys [east-west-length width north-south-length length height material
             start]})

Create a simple box. We also use this as the base shape to carve out other shapes.

If the start position is omitted you get a box which starts at [0 0 0] and you need to position the result yourself.

:material is either a keyword, or a function which receives the [x y z] position and returns a keyword. :material is optional, you can add materials on the result yourself instead.

Returns a sequence of [x y z] or [x y z material], to be passed to [[wc/set-blocks]].

To specify the size use :height, and either :width/:length, or :east-west-length/:north-south-length, as per your preference.

Create a simple box.
We also use this as the base shape to carve out other shapes.

If the start position is omitted you get a box which starts at [0 0 0] and you
need to position the result yourself.

`:material` is either a keyword, or a function which receives the `[x y z]`
position and returns a keyword. `:material` is optional, you can add materials
on the result yourself instead.

Returns a sequence of `[x y z]` or `[x y z material]`, to be passed
to [[wc/set-blocks]].

To specify the size use `:height`, and either `:width`/`:length`, or
`:east-west-length`/`:north-south-length`, as per your preference.
sourceraw docstring

lineclj

(line {:keys [start end length direction material step] :or {step 0.41}})

Draw a straight line between two points. Specify either end or direction+length, not both.

:material is either a keyword, or a function which receives the [x y z] position and returns a keyword.

Returns a sequence of [x y z] or [x y z material], to be passed to [[wc/set-blocks]].

Draw a straight line between two points.
Specify either end or direction+length, not both.

`:material` is either a keyword, or a function which receives the `[x y z]`
position and returns a keyword.

Returns a sequence of `[x y z]` or `[x y z material]`, to be passed
to [[wc/set-blocks]].
sourceraw docstring

range*clj

(range* a)
(range* a b)

Like range, but deal with negative or non-ascending numbers in a way we like better.

(range -3) ;;=> (-2 -1 0) (range 5 2) ;;=> (2 3 4)

Like range, but deal with negative or non-ascending numbers in a way
 we like better.

(range -3) ;;=> (-2 -1 0)
(range 5 2) ;;=> (2 3 4)
sourceraw docstring

rectubeclj

(rectube {:keys [east-west-length width north-south-length length height
                 material start direction]
          :or {direction :top-bottom}})

Create a rectangular tube, i.e. a box but with the inside hollow and two opposing sides open.

Arguments are like box, but with the added :direction which can be :east-west, :north-south, or :top-bottom. :top-bottom is the default.

Create a rectangular tube, i.e. a box but with the inside hollow and two
opposing sides open.

Arguments are like [[box]], but with the added `:direction` which can be
`:east-west`, `:north-south`, or `:top-bottom`. `:top-bottom` is the default.
sourceraw docstring

torusclj

(torus {:keys [radius tube-radius material margin start] :or {margin 15}})

Draw a torus shape. :radius is the radius of the "ring", :tube-radius is the radius of the tube/pipe. :material is optional and can be a keyword or a function from [x y z] to keyword. :margin determines the "thickness", experiment with different values depending on the size of your torus.

Returns a sequence of [x y z] or [x y z material], to be passed to [[wc/set-blocks]].

Draw a torus shape.
`:radius` is the radius of the "ring", `:tube-radius` is the radius of the
tube/pipe. `:material` is optional and can be a keyword or a function from `[x
y z]` to keyword. `:margin` determines the "thickness", experiment with
different values depending on the size of your torus.

Returns a sequence of `[x y z]` or `[x y z material]`, to be passed
to [[wc/set-blocks]].
sourceraw docstring

tubeclj

(tube {:keys [start end length direction radius inner-radius material fill
              distance-fn]
       :or {inner-radius -0.1 distance-fn wc/distance start [0 0 0]}})

Draw a tube, pipe, cylinder, or tunnel.

This can be arbitrarily rotated, it does not have to be axis-aligned.

:start and :end are the two ends of the central axis of the cylinder. :radius is the radius of the cylinder, :inner-radius is the space inside the "tube" that is hollow (or filled in if you specify a :fill material).

Alternatively to specifying :end you can specify a :direction + :length.

:material and :fill are either keywords, or functions which receive the [x y z] position and returns a keyword.

For best result experiment with fractional numbers, e.g. a :radius 6.1 :inner-radius 4.9 may look better than :radius 6 :inner-radius 5.

To compute this we determine the bounding box, then iterate over all blocks, project them onto the central axis, and then see if the distance between the block and this projected point equals the radius. You can specify the :distance-fn to use something other than euclidian distance here, e.g. Manhatten ([[m/manhatten]]) distance or Chebyshev ([[m/chebyshev]]) distance, which will give you more of a square pipe.

Returns a sequence of [x y z] or [x y z material], to be passed to [[wc/set-blocks]].

Draw a tube, pipe, cylinder, or tunnel.

This can be arbitrarily rotated, it does not have to be axis-aligned.

`:start` and `:end` are the two ends of the central axis of the cylinder.
`:radius` is the radius of the cylinder, `:inner-radius` is the space inside
the "tube" that is hollow (or filled in if you specify a `:fill` material).

Alternatively to specifying `:end` you can specify a `:direction` + `:length`.

`:material` and `:fill` are either keywords, or functions which receive the
`[x y z]` position and returns a keyword.

For best result experiment with fractional numbers, e.g. a `:radius
6.1 :inner-radius 4.9` may look better than `:radius 6 :inner-radius 5`.

To compute this we determine the bounding box, then iterate over all blocks,
project them onto the central axis, and then see if the distance between the
block and this projected point equals the radius. You can specify the
`:distance-fn` to use something other than euclidian distance here, e.g.
Manhatten ([[m/manhatten]]) distance or Chebyshev ([[m/chebyshev]]) distance,
which will give you more of a square pipe.

Returns a sequence of `[x y z]` or `[x y z material]`, to be passed
to [[wc/set-blocks]].
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close