Creating Falling Snow in Silverlight!
Exactly a year ago (plus one day…but who’s counting?!), I posted a sample WPF application that simulates falling snow. Since Silverlight 2 was released since then, below you will find a Silverlight version of a similar falling snow effect:
Just click on the Let It Snow banner to cause 200 snowflakes to start falling. Feel free to use this for your own projects, and the source files have been provided below:
Download Falling Snow Source |
For your own projects, the only thing you may want to tweak is the width and height of your application. Currently, everything is hard coded to a width and height of 500px by 300px respectively, but if you decide to change the size, be sure to open Page.xaml.cs and change the dimensions provided:
private void PopulateSnowFlakes() { for (int i = 0; i < 200; i++) { SnowFlake snowFlake = new SnowFlake(); // 500 and 300 is the width/height of the application snowFlake.SetInitialProperties(500, 300); LayoutRoot.Children.Add(snowFlake); } } |
Besides that, everything else should be pretty straightforward. If you have any questions, feel free to leave them below.
Cheers!
Kirupa
Comments
Anonymous
December 27, 2008
PingBack from http://www.codedstyle.com/creating-falling-snow-in-silverlight/Anonymous
December 27, 2008
Very nice! I'm glad you avoided the temptation to soften this up with radial gradients on the flakes... :) It looks great.Anonymous
December 27, 2008
Haha, thanks Robby. I don't know what I was thinking last year when I gave the snowflakes some gradients :PAnonymous
December 28, 2008
In this issue: Maurice de Beijer, Damon Payne, Expression Blend and Design BLog, Bart Czernicki, NingAnonymous
December 28, 2008
Quoi de mieux qu’une bonne chute de neige pour embellir vos projets de fin d’année ? C’est ce que vousAnonymous
December 29, 2008
Thanks for posting this! Awhile ago I tried to create a decent looking snow animation using SL, but was unable (I'm a web designer, but only a novice C# programmer). It's nice to see how to do this! There's lots for someone like me to learn from your code. I might actually reopen that project and add that snow animation in after all. Thanks again!Anonymous
December 29, 2008
Открытки, как изветно, бывают самые-самые разные, поэтому сразу от слов к делу. Открытка будет вот такая:Anonymous
December 29, 2008
Открытки, как извеcтно, бывают самые-самые разные, поэтому сразу от слов к делу. Открытка будет вот такая:Anonymous
December 29, 2008
ok, Natal passou e a previsão é de 29 graus aqui em sampa, mas até que essa animaçãozinha cai bem Anonymous
December 30, 2008
Открытки, как известно, бывают самые-самые разные, поэтому сразу от слов к делуAnonymous
January 21, 2009
Exactly a year ago (plus one day…but who’s counting?!), I posted a sample WPF application that simulatesAnonymous
February 08, 2009
Открытки, как известно, бывают самые-самые разные, поэтому сразу от слов к делу. Падающий снег, мигающая звездочка, встроенные DeepZoom, несколько ссылок и открывающееся окошко с благодарностями. Исходники – в самом конце (их можно свободно использоватьAnonymous
December 13, 2010
I made the same effect about a year ago, your code is very similar to mine but both mine and yours have a slight stutter in the animation. I've tried it this way using the CompositionTarget.Rendering event, and also with assigning each flake a DoubleAnimation (which performs worse in terms of fp/s), both give the same stutter.Anonymous
December 13, 2010
I made the same effect, your code is very similar to mine but both mine and yours have a slight stutter in the animation. I've tried it this way using the CompositionTarget.Rendering event, and also with assigning each flake a DoubleAnimation (which performs worse in terms of fp/s), both give the same stutter.Anonymous
November 26, 2012
чтоб тебя - у тебя ничего не работает !Anonymous
December 12, 2014
This sounds great I will be sure to use this in my upcoming projectAnonymous
December 15, 2014
What a joy! Thanks for sharing. Are u sure you don't wear a big red had. MERRY CHRISTMAS ⛄✳⛪Anonymous
November 12, 2015
I love that!!the snow ⛄ it's a beautiful!!!Anonymous
December 09, 2015
Can you put on how many weeks as well?