Turtle Steps

Turtle Steps

August 3, 2024
QLogo, Code, Turtle
Graphics, Resolution, Modernization

Pixels #

UCBLogo was designed to run on DOS machines, which had a well-defined screen resolution. Windows wasn’t really a thing at the time, and so you could count on the turtle’s graphics region being very static.

Also, since screen resolutions were so low, a single pixel was much larger, and very visible. So it made sense at the time that everything the turtle did was defined in pixels.

No Pixels #

Today, the boundaries of the turtle graphics region are much more fluid. Users expect user interface elements to be easily movable and resizable, but the Logo language doesn’t have that much flexibility.

For example, how far does the turtle go before it has to wrap to the other side of the screen? A user can’t expect consistent boundary behavior when the turtle reaches the edge of the screen, as the window size may have changed between movements.

On top of that, the pixels on a modern computer are much smaller. Many modern systems have pixels that are smaller than the human eye can see, so it makes less sense to define the turtle’s movement in pixels.

Turtle Steps #

My solution was to have the concept of the turtle’s movement be defined in “steps” instead of pixels, and have the turtle’s region be defined in steps as well. A “step” can grow or shrink along with the drawing region.

To facilitate this, I added several new commands to the language. For example, SETBOUNDS allows you to change the size of the turtle’s region. I also added BOUNDS to allow you to see the current size of the turtle’s region. SETBOUNDS doesn’t affect the user’s GUI; that is still under the user’s control. Similarly, BOUNDS doesn’t give you any information about the state of the GUI, since that can change at any moment.

New Window #

While playing with a cool Logo program I found on the web (which I’ll discuss in a future post), I came up with another idea: what if the turtle’s boundaries adjusted automatically to fit the graphics being drawn? At first, I came up a new turtle mode, ADAPTIVE, which grows the turtle’s boundaries to accommodate the turtle’s movement. It works, but I think it might be better to use the already existing WINDOW mode since “window” is the mode that allows the turtle to roam freely everywhere. So now instead of the turtle disappearing off the canvas, WINDOW now means that the window of the canvas will adjust to keep the turtle visible.

Of course, there are drawbacks to this idea. The view can zoom out so far that the turtle itself and the lines it draws become too small to be visible. However, this is a more manageable problem than having a turtle that disappears off the canvas.