Bringing a 20 year old Draw command back to life...

Back in the early 80’s, there was the Radio Shack Trs-80 Color Computer series of computers. Of course, you interacted with it using Microsoft Basic (Extended Basic and eventually Disk Extended Basic). After looking through a few old magazines I found hiding away in some boxes, I was reminded of a pretty unique method that was used to draw images upon the screen. It has a lot of similarities with the concept of turtle graphics. Basically, turtle graphics is the idea of drawing using simple commands (up, down, left, right, change orientation, lift pen, etc.) and it’s a state based drawing system.

I thought, hey, why not do this in .NET? How hard could it be, right? Actually, parsing the sub-language was pretty straight forward. Drawing each command on the screen was rather simple as well. However, the way that this form of drawing works, it needs to remember the previous drawings and state between each command. I started to implement this using a control and had to work around the fact that invalidating the control (which is how you get the paint to occur), the previously drawn commands would be cleared.

I had two ways that I could approach this. I could attempt to remember every command passed in and redraw them all upon every refresh. That one didn’t sound like the way to go. So, instead I chose to use a backing image to draw upon and then paint that to the screen upon invalidation. I’ve also abstracted the actual drawing to it’s own class so that it could be leveraged to draw upon any Graphics surface (screen, bitmap, etc.). It’s very basic at this point and the control is actually missing several features (resize being a big one). Anyway, if your interested in playing with this slight diversion, you can get it here.

This post is licensed under CC BY 4.0 by the author.