Tymless Tutorial: Drawing



   
  < flipping

Regular Polygons

 
irregular polygons >
 

Drawing

Control

Data

Reference

 

You can always draw regular polygons using simple lines, as long as you know what angle to turn. But Tymless makes it even easier, and also lets you fill them with colour. The 'regular polygon' command {} draws a square by default, and fills it with grey:

// a filled square
{}

To draw, say, an eleven-sided polygon is not much harder: The number-of-sides system variable ${} tells the turtle how many sides to draw on regular polygons.

// an eleven-sided polygon
${}=11
{}

Setting ${} to a large number approximates a circle. The smallest number it will accept is zero, which tells the turtle to draw pixels (the smallest dot the screen can show).

All these polygons have been filled with grey and surrounded by a black border. You can change this behaviour using $border, another system variable (you can use $| instead if you prefer. It means the same thing and is quicker to type).

// a row of borderless hexagons
${}=6
$border=0
{} ; {} ; {} ; {}

Note how each hexagon sits directly next to the previous one. Regular polygons are sized and orientated to allow that, however many sides they may have. (In particular, they are drawn to a have a diameter equal to the turtle walk-distance. What is the diameter of a regular polygon? Well I define that as the distance between the centres of adjacent polygons.)

To create 'empty' polygons set $fill to zero.

   
  < flipping
 
irregular polygons >