Logo type; getting your fill with Logo.Donna Bearden.

Wouldn't it be nice if Logo had a fill command similar to the one in Pilot? When you place the turtle inside a shape and give the commands, the shape fills with color. Delta Drawing, a single keystroke, Logo-like program also has a fill command. Too bad you can't fill in shapes in Logo; you could make all kinds of simple and elaborate designs, starting with checkerboards and quilts (Figure 1).

Hold on! You know you never say can't in Logo. If you can define a problem and use your imagination a little, there is probably a way to solve it. Coloring a Square

Think about a square. Draw one on a piece of paper and color it in. One natural way to color it in is to go back and forth, moving down the square as you go. How would you tell the turtle to do that?

One way is to repeat the following commands as many times as necessary.

FD :D RT 90 FD 1 RT 90

FD :D LT 90 FD 1 LT 90

Like most problems in Logo, there is more than one solution. Using recursion and a conditional, we can write a procedure to draw successively smaller squares until the shape is entirely filled in:

TO FILL.SQUARE :N

IF :N = 0 [STOP]

REPEAT 4 [FD :N RT 90]

FILL.SQUARE :N - 1

END

If we can do it with a square, we can do it with a triangle:

TO FILL.TRIANGLE :N

IF :N = 0 [STOP]

REPEAT 3 [FD :N RT 120]

FILL.TRIANGLE :N - 1

END

and if we can do it with a triangle, we should be able to do it with a hexagon. We should be able to do it with any regular polygon. Drawing Polygons

If you have played with polygons and the Rule of 360 or Total Turtle Trip Theorum, you know that the turtle must turn through 360[deg.] to draw a polygon and end up facing the same direction as it started. Knowing that, we can write one procedure to draw any regular polygon we want:

TO POLY :R :D

REPEAT :R [FD :D RT 360/:R]

END

So now we should be able to write a single procedure to fill in any regular polygon.

TO FILL.POLY :R :D

IF :D = 0 [STOP]

REPEAT :R [FD: :D RT 360/:R]

FILL.POLY :R :D - 1

END

Try it and you will discover that it works pretty well for triangles, squares, pentagons, and hexagons. Once you call for a polygon with more than six sides, you will have gaps in the fill. The more sides for which you ask, the more gaps you will have. If you like seashells, you will like the results (Figure 2).

However, if you are more interested in filling in a solid shape, we must edit the procedure. After much experimentation, we came up with the following. (As we said earlier, however, there is always more than one solution. So you may think of another one.)

TO FILL.POLY2 :R :D

IF :D = 0 [STOP]

REPEAT :R [FD :D RT 360/:R]

RT 90 FD 1 LT 90

FILL.POLY2 :R :D - .5

END Drawing Circles

This works for polygons with 7 to 14 sides, and by the time you reach 14 sides, you have the illusion of a circle. A 15-sided polygon begins to have a few holes, so you must edit the procedure again. For now, these are enough to play with.

Sally evolved out of playing with filling shapes (Figure 3). She didn't look complete without freckles, so we used the DOT command, which allows you to put a dot anywhere on the screen just by naming the coordinates.