Turtle# - A basic Turtle Graphics implementation for C#
I was recently working on a project where I needed to laser cut some complex shapes for a puzzle. I needed a set of a dozen pentagons that were going to interlock to make a dodecahedron and each pentagon was going to have a complex set of markings which would be used to fill out the face with letters and direct the player how it should be assembled with the remaining tiles.
I knew that I was going to be making changes and modifications to the tiles and I didn't want to have to manually construct the patters for the faces more than once, and automating the process was going to be the easiest option for me. I dug around to see if I could find an existing project/tool/app that would allow me to easily generate a set of SVGs (the image format the laser cutter I was using needed) but I wasn't able to find anything that met my requirements. Inkscape's scripting functionality looked like it was going to do the trick at first, but it seemed as though all it provided was a very thin wrapper over the SVG data format. I would essentially be constructing the images 'by hand' with python, and there was no easy way to run a script and quickly see my results without re-loading the image in Inkscape each time. I wanted something that was a little bit higher level that I could abstract away the actual SVGness.
The first thing that came to my mind was LogoWriter, a simple implementation of the Logo programming language which provided an easy to use Turtle Graphics system for creating and manipulating vector images. Logo takes the term 'Turtle Graphics' very literally, and allows the user to manipulate actual turtle icon on screen, to allow you to easily see the results of your operations.
I was first exposed to LogoWriter while I was in elementary school and I always loved the ease at which I could create and animate simple scenes in LogoWriter and thought it would be fun to recreate while at the same time solving my problem. I was planning on iterating on my design pretty rapidly so I needed to be able to run my script and immediately see the results while at the same time being able to quickly change both the generation code and the Turtle code at the same, so I settled on LINQPad. In general, this is probably just about as large of a project that you'd want to write and manage in LINQPad since there's no good way to separate out bits and pieces of code, but the rest of the functionality is perfect.
The next thing I needed was a way to create and render SVGs. The SVG Rendering Library could do the trick, and with a few helper functions for rendering the SVGs to bitmaps, I could easily view my output directly within LINQPad.
This repo contains the collection of bits and pieces that I created over the course of the project, and my minimal attempt to pull it together into a proper library.