I made these just now, completely by hand. It wouldn't be difficult to write a function to do this automatically. Algorithms aren't all that complicated and AGS already has all the tools needed, except for painting and detecting colors. From there it's just a matter of speed.
http://i168.photobucket.com/albums/u193/kamikazehighland/65536.png
http://i168.photobucket.com/albums/u193/kamikazehighland/65536.png