I was experimenting with compression and created a simple shape drawing library. Even with the flood fills the cpu was barely affected, so this seems like a legitimate drawing tool, and only costs 10 tokens per drawn shape! Here's the documentation if anyone looks into the code:
shape(x, y, rotation, drawstring):
draws a shape on screen, starting the cursor at x,y, with rotation from 0 to 1 at the origin (cursor start pos).
drawstring: a set of commands to draw, as a string (1 token!).
"C" color - set drawing Color (for lines and fills). color is a hex value 0-F.
"T" x y - move cursor relative To current position, drawing nothing. x and y are chars from "0"-"9"-"A"-"G", which represent -8 to 8. So "T00" means "to -8, -8", and "TGG" means "to 8, 8".
"L" x y - draw Line from current position to next position. x and y are 0-9+A-G as described above.
"F" x y stopcolor - flood Fill a region with drawing color until you encounter stopcolor. This fully works with rotation by filling the next (rotated) position defined by x,y. x and y are 0-9+A-G as described above, color is a hex value 0-F.
I will probably improve this library if people are interested, but for now I thought it was a fun little idea that only took a few hours to implement. Triangles and hexagons are easy now! =)
Storing the drawing commands in strings is a great idea--especially because it let's you use code space as opposed to having to store things in the sounds / sprite-sheet / map etc. I only wish there was a good way to get exportable text out of the program. On Windows, the debug print command doesn't actually print to the console/command prompt. :-(
For filling polygons, I have been working with a raster algorithm because it handles overlap better than a flood fill and you don't have to worry about starting points or leaks. (Well, really it just draws the whole polygon every time.) Here's what I based my code on: https://www.cs.rit.edu/~icss571/filling/example.html (I'm in the process of accelerating my code by pre-calculating what I can and trimming fat...)
One thing, it looks like CPU load is a little higher than you estimated (~1 frame)--need to check before and after drawing the polygons. Still, it's a great demo.
[Please log in to post a comment]