Level_2 is a Bricklayer interface (technically speaking an SML structure) that provides a set of functions for “putting” LEGO bricks in the xz-plane.

See Vitruvia Concepts 10-13 for exercises relating to Level_2 functions.

To get (direct) access to all the functions in Level_2, place the following command at the beginning of your bricklayer program:

open Level_2;
Level_2 contains all the functions found in Level_1 plus the functions listed below.

setOffset2D : xzTuple → unit

For the xz-plane, an offset is denoted by a pair of integers and has the form: (xOffset, zOffset). The value xOffset is an integer that will be added to the x value of every coordinate processed. The zOffset is an integer that will be added to the z value of every coordinate processed. An example of a setOffset2D function call is shown below.

setOffset2D (4,0);

A detailed discussion of offsets which includes coding examples can be found here.


incOffset2D : xzTuple → unit

The function call incOffset2D(deltaX,deltaZ) will permantly increment the internal (x,z) offset used by Bricklayer by the amounts deltaX and deltaZ respectively. An example of a incOffset2D function call is shown below.

incOffset2D (3,7);

A detailed discussion of offsets which includes coding examples can be found here.


decOffset2D : xzTuple → unit

The function call decOffset2D(deltaX,deltaZ) will permantly decrement the internal (x,z) offset used by Bricklayer by the amounts deltaX and deltaZ respectively. An example of a decOffset2D function call is shown below.

decOffset2D (6,2);

Note that incOffset2D and decOffset2D are opposites. For example, the code

incOffset2D (3,7);
decOffset2D (3,7);

leaves the Bricklayer internal offset unchanged. Also the following two function calls are equivalent.

incOffset2D (~3,7) ≡ decOffset2D (3,~7)

Note that, in SML, negative integers are denoted using the ~ symbol instead of the – symbol. For example, in SML a minus 4 is denoted ~4.

A detailed discussion of offsets which includes coding examples can be found here.


circleXZ : radius → brick_type → center → unit

The function circleXZ is a curried function that will create a circle when given (1) an integer denoting a radius, (2) a brick type (e.g., BLUE) and (3) a 2D coordinate denoting the center of the circle. An example of a circleXZ function call is shown below.

circleXZ 10 BLUE (10,10);

The function call shown above will create a circle in the XZ plane whose diameter = 21 (i.e., 2*radius + 1). The smallest virtual space which can contain this circle is build(21,21).


ringXZ : radius → thickness → brick_type → center → unit

The function ringXZ is a curried function that will create a circle when given (1) an integer denoting a radius, (2) an integer denoting a ring thickness, (3) a brick type (e.g., BLUE) and (4) a 2D coordinate denoting the center of the ring. An example of a ringXZ function call is shown below.

ringXZ 10 2 BLUE (10,10);

The function call shown above will create a ring in the XZ plane whose diameter = 21 (i.e., 2*radius + 1). The smallest virtual space which can contain this ring is build(21,21).