Wednesday, October 17, 2007

Birthday project - drawing waves

Thanks to the Drawing API that was added to Flash MX, this game is possible to do in Flash. While the drawing API is not as robust as the one found in Java, it is very efficient and is a lot more powerful and flexible than a quick glance at the list of function calls would have you believe. The drawing API is aimed at the creation of vector shapes, while Flash 8 added bitmap support so all that is needed now is support for hardware 3D graphics.

For my birthday project, I am essentially drawing sine waves. Plotting these is fairly simple as you simply use the basic formula of sin( 2*PI*(days_since_birthday+ skew)/period). Multiply this by your hight then plot the point. I drew the graph by simply moving to the first point on the graph then using the lineTo command to connect all the points together. For my purposes this was quite adequate. I could have created a better looking graph by using the curveTo command instead, but that was overkill for my needs.

The graph draws very quickly so I am easily able to update the graph in real time as any of the date or wave control values are changed. This is one of the cooler aspects of this program and is quite fun to play with. This concludes the development of this project. I think there is more then enough information to reveal what this project is, but for those of you who were unable to guess it will be posted tomorrow evening.

No comments: