I think this tutorial on the drawin api should help:
http://www.gotoandlearn.com/play?id=52