If your just interested on the post topic feel free to skip this paragraph; just me talking about the past 3 months and what has been going on in my life. 3 months since my last post .... wow, life sure has been crazy. Not only with the holidays being crazy as usual, I also got married and went on my honeymoon!!! All of my tasks for the wedding just seemed to hit all at once and things got crazy from then on, until the wedding day of course. Everything went very well on my wedding day, the limo was a 67' Rolls Royce and the food at the reception was absolutely amazing, well what little I had! Then it was off the Maui, Hawaii where my wife and I stayed for a week and a half. It was gorgeous, too pretty for pictures to describe (and yes, there are many many pictures, over 12 GB worth!!!). My wife is a photographer and so she was prepared ;) I took some pictures too, and one of them is on our wall in our living room, go me! But alas the good times were interrupted by the worst storm since 1980 ... rain rain rain. It made the water all muddy with debris everywhere, flash floods, and 100+ mph wind gusts! Luckily Maui is extremely small (70 miles wide) and we were able to drive through the storm to the other side of the island and find some sunshine, some days. Even though 7 out of the 9 days were filled with rain, we found time to enjoy Maui to its fullest. I would especially recommend Mama's Fish house, a little pricey (like all other restaurants on the island) but they had the best food of all; try the parmesan crusted, crab and lobster filled Mahi Mahi, the best fish I have ever had! Then the honeymoon was over and the holidays upon us. Of course we had to catch back up with work and then off for the holidays and then back to work so my time has been busy. Oh, and you think taking time off from work would provide me with some time to blog / code, not really ... the Mrs. had other plans, more housework! But now things have settled down some and I am starting to get back into the groove of things at home and at work. So stay tuned for more posts, I have about 3 more ideas I want to blog about already! And now onto the snowflakes!
Above is a picture of the snowflake picture project. I have provided full source as well as just the executable for all interested. Let me first say that the code was written purely for my rehearsal dinner slide show and thus it is not formatted or commented as well as it should be. But it does work and provide another alternative way to think about a slide show presentation that can be created quickly.
The program looks for all .jpg files in your MyPictures directory and all of its subdirectories. It then makes a vector snowflake outline and paints the image onto its background. There is simple, very simply math that moves the snowflakes from the top to the bottom of the screen and sways them back and forth. I did not have much time to write a better algorithm for animating the falling and swaying of the snowflakes, feel free to write a better one and share it! Here's the gist of the algorithm:
- get the total height of the screen and apply a translate transform to each snowflake on its y-axis. Each transform has a random number assigned to it for the time interval to fall, this number is constrained by minimum and maximum bounds. Once the snowflake passes the bottom of the screen, clear its transform and apply another. Repeat indefinitely.
- each snowflake also has an x-axis translate transform applied to it that uses two random numbers to move it some delta over some random time.
Now this algorithm is by far simple and it shows when you run the application from time to time. If the random numbers are all very close (maybe I am using the random class wrong) then the snowflakes bunch up. Also, all of the snowflakes start at a similar position and are not offset by much.
The program also enlarges and centers (on the y-axis) 1 snowflake at a time throughout the life of the program. This is to give that full screen picture effect so you can view the whole picture better. When the snowflake is enlarging the vector graphic that holds the image changes to open the center up some and all you to view most of the image. There is another xaml graphic in the solution that allows for a closed center for the enlarged snowflake; these are found in 'Snowflake.xaml'.
Feel free to change the code, use your own falling algorithm, your own graphics and make any changes you would like. If you do make some cool changes please share them! I had another version that I did not include due to space issues, that had music throughout the programs life and overlay text in the beginning for some description about the presentation.
To close the program, mouse over the upper right for 'close' to appear and click on it. Enjoy!