The Form Language, a Tutorial

Creating your own forms

All form descriptions have at least one object to display and they all end with the word "end", for example:

The simplest form script

sphere;

STACKING

sphere stack 5;

Stacking is not quite the same as joining, but it is similar.

sphere & box stack 5;

This gave us three spheres and two boxes, since we asked to stack 5 objects high. Stack works on the objects sphere and box in order

Coments, copyright and spaces

You can embed comments in Form scripts, these look like
/* comment here */
or
// comment until the end of the line

You can now place a copyright message in you form script, and have it displayed on the screen when it is encountered, you do this by putting the text " copyright " on a line with your name, like so
copyright this is a copyright line

Form is blind to spaces, as long as there is at least one space, tab or newline FORM doesn't care how many more there are.

STACK TRANSFORMS

Once you have stacked or joined some objects you can apply some transformations to them, for example you can "compress" them slightly e.g.

sphere stack 5 in 3;

This will fit 5 spheres into the space that would have been occupied by 3. Another way to compress is

sphere stack 10 in 50%;

This stacked them into 50% of their original space.

BEND

sphere stack 10 bend 90;

This bent them so that the last one is bent 90 degrees out of position.

TWIST

box stack 10 twist 45;

This twists them around their own axis, similar yet different to bend.

OFFSET TWIST

A variation on twist is:

sphere stack 10 twist 360 , 1;

in this case the boxes are twisted but not around their own axes, the second number is the amount of offset.

GROW

sphere stack 10 grow 0.1;

This "grows" the stack leaving the first item alone, and progressivly "growing" each item until the last is "grown" by the specified amount.

other types of grow are:

There is very little difference between these types, but you might like to play with them later.

COMBINATIONS

Twist, bend, grow can be combined in ANY order as in

sphere stack 40 in 75% bend 60 twist 45 grow 1.3;

NOTE: the semi colon at the end , this means that the object is finished, most commands in FORM finish with a semicolon.

If we had entered

sphere stack 40 in 75% bend 60 twist 45 grow 1.3;

We would have got a different form.

TWISTX and TWISTZ

These are two more variations on TWIST, can be nice when combined with BEND try

torus stack 20 in 25% twistz -90 bend 180; (flip.frm)

CHANGING SIZES

In FORM there are only five basic objects, the "sphere", the "box", the "torus", the "ellipse", and the spacer.

All of these have a basic size and shape. But you are not limited to these defaults, you can set your own values for radii/proportions.

For example the word "sphere" creates a sphere with a "radius" of half a unit, the phrase "sphere 1.5", creates a sphere three times as large. This means we can vary the appearance of a sphere so:

sphere & sphere (0.8) stack 10; Will give a stack of alternating large and small spheres.

BOX

For boxes you can again vary the size as in

but you can also turn the box into a brick by specifying three lengths for it as in:

which gives a box 1 unit across 3 units high and 0.4 units deep.

NOTE the "<" and ">", these are required.

ELLIPSE

The default ellipse is indistinguishable from a sphere, the reason spheres are included is simply because they display faster. Ellipses (or ellipsoids as they should be called) can be modified. You can specify their width and height, or their size along all three axes to give smartie and rugby ball shapes.

TORUS

Toroids, are doughnut shapes, you specify the small radius and the large radius, defaults are: 0.2 , 0.5. These are quite expensive computationally, but can give nice hollow stem effects, if you don't need them to be hollow try ellipse above to achieve a similar effect.

CONE

cones are, well cones really. Specify a base radius, and a height.

SPACER

spacers are invisible objects that are there to help you create gaps, and overlaps. ALL spacers require a size. Think of them as invisble spheres.

DEFINING YOUR OWN OBJECTS

Named objects

Unfortunately you cannot define your own primitives as such, but you can create NAMED OBJECTS. The way to do this is best shown by an example:-

my_object = sphere stack 10 bend 30;

This defines an object called "my_object", it will not be displayed, to display it you would need a line like:

my_object;

This line actually creates one of my_object for display. Once you have defined an object you can use it anywhere you like - so you can now have:

my_object = sphere stack 10 bend 30;
my_object & box (3);
end;
Not especially useful, but some of the more fun operations can only be performed using named objects. Another use for named objects is to speed up display, if you are using a lot of torus or ellipses, you might use named objects to speed things up like so:

torus stack 30 bend 20;
will take x seconds to display on my machine, so I change the description to read:

basic_object = ellipse (0.7, 0.5); // min rad+ maj rad = 0.5+ 0.2 = 0.7
basic_object stack 30 bend 20;
this now displays in y seconds. When I am happy with the form I can now change the first line to read

basic_object = torus (0.2 , 0.5);
and I get my original picture back again.

SQUARE BRACKETS

If you include a named object in a list you can optionally turn it on its side by using "[" object_name "]". This makes the obect grow out sideways. This is used in SAMPLE1 to get the stair treads.

ROUND BRACKETS

These group operations together like normal brackets, so you can now say :

sphere & (box stack 5) & torus;
and get

FAN

This is not very well named, it produces a "dandelion head" effect, try

ellipse <0.2 , 0.5, 0.2> fan 40 , 180;

The first value after fan is the number of copies to make, just like stack. The second value is the amount of spread to use, 180 is full spread, 90 gives a hemisphere etc.

There is an optional third value, "tightness", this gives "pulls" the individual spikes together, try

ellipse <0.2 , 0.5, 0.2> fan 40 , 180 , 0.1;

remember you can use named objects wherever you had a simple object, so you could try:

sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45;
sos fan 40 , 180 , 0.1;
It starts taking longer doesn't it, but it does look quite complex (it is; there are now 400 spheres in that picture).

The base in "flagpole.frm" is made from a fan of smartie shaped ellipsoids.

WEB

This on the other hand is well named, it produces a spiders web effect. It does however work best with previously defined stacks of objects.Try

sos /* stack of spheres */ = sphere stack 10;
sob /* stack of boxes */ = box stack 20 bend 20 twist 45;
sos web 3 with sob 4;

there are three more optional values, so for a full web you can get

OBJECT web SPOKE_NUMBER with DEFINED_OBJECT scale SCALE_NUMBER WEBBING_NUMBER hole HOLE_NUMBER excess EXCESS_NUMBER (italic words supplied by you)

so using the above objects "sob" and "sos" we can get

sos web 5 with sob scale(2) 10;

will enlarge the "webbing" to twice its original size.

sos web 5 with sob 10 hole 0.5;

will leave a hole about half the length of the spokes in the middle.

sos web 5 with sob 10 excess 0.5;

will make the webbing continue on past the end of the spokes for a distance of about half the length of the spokes.

see web1.frm, web2.frm and webgood.frm for examples of this.

HEIGHTLESS OBJECTS

When an object has been made with WEB or FAN it has no height, stacking them together has no effect, you MUST place a spacer in between them to get them to stack.

sphere & spacer & box & spacer stack 20;

Other operations

you can

delete #

this removes the x'th piece from the form.

and

delete #..#

which removes the x to y'th pieces from the form.

useful for getting rid of clutter.

move< x , y , z>

Moves the whole objects so far x units along the x axis etc. I'm still not very happy about this command, but it might be usefull.

copyright your text here You can put a copyright message in your script, it must be the first non blank item on a line. The whole line is output to the screen. In future versions this message may also be placed in any output file capable of accepting it e.g. as a GIF comment.

SPACING OBJECTS

This is an invisible object used to get round problems in the system. For example we have made a fan

sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45 , 0.5;
nicefan = sos fan 10 , 90, 0.1
and we want to put 5 on top of each other:

nicefan stack 5;
that didn't work because fans have no or very little height, we need to space them a bit.

so try

sos /* stack of spheres */ = sphere stack 10 bend 20 twist 45 , 0.5;
nicefan = sos fan 10 , 90, 0.1
spaced_fan = nicefan & spacer (5);
// spacer is radius 5 because if we look closely at sos we can
// guess it's about 5 units tall (10 * 0.5)
// alternatively we could have had
// spaced_fan = nicefan , sos delete 2 // which would have been
// more accurate

spaced_fan stack 5;
works fine.

Negative Spacing Objects

This is still part of the same workaround, consider:

a = sphere stack 10 in 10%;
b = sphere stack 10 in 10%;
then the join in "a & b" should be virtually indistingushable, unfortunately it isn't, there's no overlap!

so we introduce a negative spacer

a & spacer (-0.4) & b;
this then looks OKish. I'll be fixing this problem in a later release.


© and maintained by Andrew Rowbottom
This page has had 00721 hits since March 7, 1997[TextCounter Fatal Error: Could Not Increment Counter].
This page last updated 11 January 1995