Tymless Tutorial: Reference



   
  < system variables

Walk Commands

 
turn commands >
 

Drawing

Control

Data

Reference

 

The 'walk' commands all tell the turtle to walk forwards, and optionally do something when you get there. The four options are:

walk ; do not draw anything
draw | draw a line as you go
connect \ when you get there, draw a line to the end of the last line
corner ^ create a polygon corner when you get there (should be used within curly brackets to indicate the start and end of an irregular polygon)

These commands can be used alone, in which case the turtle moves the walk-distance held in $;. For example this program...

|

...draws a line of length 1 unit, because the default value of $; is 1.

The basic commands can also be combined with other characters to change the distance moved. Each combination forms a single Tymless keyword:

: location move to the specified location
: n move n
* n move $; times n
/ n move $; divided by n
+ n move $; plus n
- n move $; minus n
= n first change $; to n, then move $;
*= n first multiply $; by n, then move $;
/= n first divide $; by n, then move $;
+= n first add n to $;, then move $;
-= n first subtract n from $;, then move $;

Example 1.

|*2 ; |+=2 ;:4 |

This program draws three lines with space between them.

  • The first line is length 2.
  • The first space is length 1 (because $; has not yet been changed).
  • The second line is length 3
  • The second space is length 4
  • The last line is length 3 (because $; was changed while drawing the second line)

Example 2.

|: (3 by 4)
|: (2 by 1)

This program draws a line directly from the origin (0,0) to location (3,4), and then another one from there to (2,1).

There are also three related commands:

query distance ;? location returns the distance to location from here. Makes no change to the turtle (see also query direction)
join loc1 <-> loc2 draws a line between locations loc1 and loc2
regular polygon {} draw a regular polygon.

The regular polygon command {} deserves some explanation. It does not cause the Turtle to move or change direction, but nevertheless draws a polygon with ${} sides. The direction the turtle is facing passes through the middle of one side. The size of the polygon (i.e. its diameter, the distance between the centres of two adjacent polygons) is given by $;.

The regular polygon command {} can be combined with the same characters as draw | etc, to give more control of the polygon size.

Example 3.

(3 by 5) <-> (2 by 4)

...draws a line from (3,5) to (2,4).

Example 4.

${} = 6
{}*2 {}

...draws two concentric hexagons

 

   
  < system variables
 
turn commands >