Include things in order of how they might be learned. Each coding example uses things that have been described earlier in the tutorial.

Include things that a beginner might not know, but that a more experienced user would regard as "clutter".

Facilitate the expansion of the tutorial by many users.

Visualizations of the code are not included here in order that you might be inspired to cut and paste it into a running openSCAD to see how it looks. You should change some of the code to experiment with it.

Terms used within Definitions

Vector

A vector is a number of values between [], as [x,x,x]. The most common vectors are [width, depth, height] or [X,Y,Z] in defining shapes. In defining color values, the vectors are [red, green, blue] or [R,G,B]. They are valued from 0 to 100.
Here are some vector values to be used for color
black = [0,0,0];
red = [1,0,0];
green = [0,1,0];
blue = [0,0,1];
magenta = [1,0,1];
white = [100,100,100];

Convexity

This is an integer. The convexity parameter specifies the maximum number of front or back sides a ray intersecting the object might penetrate. This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering.

Subtree

A subtree is the code following a module call up to the next semicolon that is outside braces ({}). In the code

translate([0,0,0]) cube(20);

cube(20) is a subtree. This could be made more clear by writing

translate([0,0,0]) {cube(20);}

A semicolon after the "}" is required if there are statements after the subtree.

Here is a cube with a vector. Because the vector values are not the same, the "cube" is actually a rectangular prism. "true" causes the prism to be centered on the axes; "false" causes the prism to be drawn starting at one corner.

A polyhedron is a geometric solid in three dimensions with flat faces and straight edges, or so says Wikipedia. At least this definition is more understandable than the one in the manual. The following polyhedron is a triangular prism. It consists of a number of beginning points, followed by the definition of the triangle to be drawn at each point (I think).

Here's a thing that looks like a pawn in a Staunton chess set (sort of). The base is a square platform, 40mm x 40mm that is 4mm thick. In the middle of it is a truncated cone 40mm high. Its base has a radius of 15mm. Its top has a radius of 5mm. A sphere with a radius of 10mm is placed (by "translate") 40mm up from the axes. It is centered by the 0,0 on the X and Y axes.

A module declaration consists of the word "module", followed by the module name, the parameters in parentheses (), and a subtree. In the following example the subtree is the line beginning with "translate".
A module declaration is not executed until it is called by later code.

module placeIt(foo)
translate([foo*3,0,0]) sphere(foo);

a=5;
placeIt(a); // placeIt is a call to the module with a value of 5.
assign (a=20) {echo(a);placeIt(a);}; // This is a call to placeIt with a value of 20.
assign(a=40) placeIt(a); // This draws a third sphere
echo(a); // This echoes a 5

This module will, when it's called, draw a pawn in the position indicated by the parameters:

The following loop sweeps the sphere around in a circle to create a ring of spheres. For each value of i from 0 to 19, a new sphere is placed with a different rotation. (The translate step moves the sphere so that the rotate step is rotating it around a point 50 units off center.)
union(){

Here, we rotate and scale a cube by a set of primes.
The for loop works in OpenSCAD with the CSG toolset, so you can union or difference objects generated by for loops to create complex structures. (You can use intersections as well, but you’ll have to use the workaround described in the documentation.)
for (i = [3, 5, 7, 11]){

Include things in order of how they might be learned. Each coding example uses things that have been described earlier in the tutorial.

Include things that a beginner might not know, but that a more experienced user would regard as "clutter".

Facilitate the expansion of the tutorial by many users.

Visualizations of the code are not included here in order that you might be inspired to cut and paste it into a running openSCAD to see how it looks. You should change some of the code to experiment with it.

Terms used within Definitions

Vector

A vector is a number of values between [], as [x,x,x]. The most common vectors are [width, depth, height] or [X,Y,Z] in defining shapes. In defining color values, the vectors are [red, green, blue] or [R,G,B]. They are valued from 0 to 100.
Here are some vector values to be used for color

Convexity

This is an integer. The convexity parameter specifies the maximum number of front or back sides a ray intersecting the object might penetrate. This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering.

Subtree

A subtree is the code following a module call up to the next semicolon that is outside braces ({}). In the code

translate([0,0,0]) cube(20);

cube(20) is a subtree. This could be made more clear by writing

translate([0,0,0]) {cube(20);}

A semicolon after the "}" is required if there are statements after the subtree.

Here is a cube with a vector. Because the vector values are not the same, the "cube" is actually a rectangular prism. "true" causes the prism to be centered on the axes; "false" causes the prism to be drawn starting at one corner.

A polyhedron is a geometric solid in three dimensions with flat faces and straight edges, or so says Wikipedia. At least this definition is more understandable than the one in the manual. The following polyhedron is a triangular prism. It consists of a number of beginning points, followed by the definition of the triangle to be drawn at each point (I think).

Here's a thing that looks like a pawn in a Staunton chess set (sort of). The base is a square platform, 40mm x 40mm that is 4mm thick. In the middle of it is a truncated cone 40mm high. Its base has a radius of 15mm. Its top has a radius of 5mm. A sphere with a radius of 10mm is placed (by "translate") 40mm up from the axes. It is centered by the 0,0 on the X and Y axes.

A module declaration consists of the word "module", followed by the module name, the parameters in parentheses (), and a subtree. In the following example the subtree is the line beginning with "translate".
A module declaration is not executed until it is called by later code.

module placeIt(foo)
translate([foo*3,0,0]) sphere(foo);

a=5;
placeIt(a); // placeIt is a call to the module with a value of 5.
assign (a=20) {echo(a);placeIt(a);}; // This is a call to placeIt with a value of 20.
assign(a=40) placeIt(a); // This draws a third sphere
echo(a); // This echoes a 5

This module will, when it's called, draw a pawn in the position indicated by the parameters:

The following loop sweeps the sphere around in a circle to create a ring of spheres. For each value of i from 0 to 19, a new sphere is placed with a different rotation. (The translate step moves the sphere so that the rotate step is rotating it around a point 50 units off center.)

Here, we rotate and scale a cube by a set of primes.
The for loop works in OpenSCAD with the CSG toolset, so you can union or difference objects generated by for loops to create complex structures. (You can use intersections as well, but you’ll have to use the workaround described in the documentation.)