Pen Line Joins
How many points does a triangle have?
pen green, 25 for [1..3] fd 100 rt 120
Try the demo above. When you use a thick pen, a triangle has no points! That is because the corners are rounded.
In the web Canvas standard, there are three styles of line joins: 'miter', 'bevel', and 'round'. The turtle defaults to round, but we can try another shape by adding the name of the style to the pen command. (It has to be in quotes.)
pen green, 25, 'miter' for [1..3] fd 100 rt 120
The 'miter' line join makes a sharp mitered corner. Only one problem:
we haven't joined that last corner yet. We could move the turtle a
little bit (with fd 1
) to get a corner.
Or we can use the "fill" command with no color, which will close up any shape that ends where it starts.
pen green, 25, 'miter' for [1..3] fd 100 rt 120 fill()
Triangles should have three points, and now they do!