A long time ago - in a place far, far away (sorry, couldn't resist), I remember seeing a cool little program on the Apple 2c that taught kids programming by having them move a little turtle around a screen. This was based on the Logo programming language. Someone mentioned it on a thread yesterday in CF-TALK, and me being the crazy person I am I decided - what the heck - let me try to recreate this in ColdFusion.
So with that - I present CF_LOGO. This is a custom tag that lets you create a canvas and then issue commands for the turtle (or pen) to draw. For example:
<cf_logo>
forward 100
right 90
forward 60
right 90
forward 90
right 90
forward 50
left 90
forward 99
home
forward 100
</cf_logo>
This tells the turtle/pen to move, turn, move, etc. The home command simply returns the turtle to the center of the canvas. This creates the following image:

The language supports many operations, but my tag supports the following commands:
forward/fd X | Move the pen forward X pixels. |
right x | Turn to the right X degrees. Currently X is ignored and all turns are 90 degrees. |
left x | Turn to the left X degrees. Currently X is ignored and all turns are 90 degrees. |
clearscreen/cs | Clears the screen. |
home | Moves the pen to the center of the canvas. |
penup/pu | Lifts the pen. Any future drawing operations won't be displayed. |
pendown/pd | Lowers the pen. Any future drawing operations will be displayed. |
The custom tag allows you to specify a height and width, a background and pen color, and you can even tell it to return the image as a CFImage object:
<cf_logo variable="test">
forward 100
right 90
forward 60
right 90
forward 90
</cf_logo>
<cfset imageScaleToFit(test,100,100)>
<cfimage action="writetobrowser" source="#test#">
Finally, I've set up a demo that lets you issue commands one at a time, to basically draw a picture online:
http://www.coldfusionjedi.com/demos/logo/test3.cfm
You can download the test files, the demo, and the custom tag below.
And yes - this is a complete and utter waste of time. That's what made it fun.
Archived Comments
I was one of those kids who spent many a n afternoon with other "gifted" kids moving turtles around the screen.
Well, at the risk of showing my age and immaturity, one of my first BASIC programs on my Tandy 1000SX was a detailed Teenage Mutant Ninja Turtle all rendered with graphic primitives. Looks like that would be right up my alley. lol
I love it, in all of it's glorious dorkishness.
Was one of those kids bald? Did he teach you that you can not bend a spoon, that's impossible. Instead try to understand that there is no spoon.
Ray, not to ruin your weekend but wouldn't this be pretty cool as an ajax-ified app so you could type in commands and get back an updated image in real time? That would be fun to play with :-)
Um. Steve. Did you see the last link in the blog entry?
oh man..in my Master Collection delirium I stopped reading all too soon.
that's it...i'm calling it quits for the week. sorry ray!
Sweet demo.
I now work as a CF/Flex developer for the school system where I first used Logo on an Apple IIe. I wonder if they will let me put this on our Intranet...
Yah!!! Now my daughter can start where I started. Ray, Best App Ever!!!!