The First Two Problems

Anything worth doing is worth over doing, right? This time we have another two problems from Programming Praxis, aptly title “Turtle Graphics instead of just printing the characters. 😄

As always if you would like to download the entire source code, you can do so here. Granted, you’ll almost surely need source code.

Now the big question is how do you actually draw those? It turns out, it’s not so bad. Here’s the first function which takes a vector of point lists (like digits above) and draws the list at a given point with the given turtle:

Pretty straight forward. Save the state, lift the pen to move to the first point, and then recursively draw lines from point to point. Now what if we want to use that to draw a number? Still pretty straight forward. Just loop through the digits, drawing them one at a time. The hardest part was actually formatting them from the right so that the standard mod/div method for extracting digits would work.