Moon Phase ModulePosted by tomcamp on Tue, 05/19/2009 - 7:50am Being as nerdy as I tend to be, is sometimes quite fun. However, it isn't the type of fun that most people enjoy; pounding your head against a math problem until 2 or 3 in the morning. If you look at the banner above, the moon should be very close to the actual moon in the sky. I was digging around and found a script written by Dan Sheeler of the University of Chicago, that predicts the phase of the moon and thought it would be fun to integrate this into a Drupal module. The script worked great, but making it work dynamically with the image was a bit of a bitch. I didn't want to use 50 images to represent every possible variation of the phase. For example, one day may be 1% illuminated and the next may be 2.7%. I wanted the image to take that percentage and then overlay a transparent image so that I would only show the proper illumination and phase. It really gets quite complexed as you have 7 distinct phase, each with minute variations. I needed to account for new, crescent, quarter, gibbous and full moons. I also needed to account for crescent, quarter and gibbous being either waxing or waning. All in all, some good clean fun with math and image manipulation. If you put your mouse over the moon it will tell you what phase the moon is in. If you click on it, it will take you to a page with more information regarding the moon and you can go either forward or backwards to see what the moon will be tomorrow, the day after that or yesterday. |