When I was younger, I used to type in programs from computer magazines. In an early issue of one of them (I forget which one), there was a small graphics program called snowflak.bas which drew an arm with ten lines, redrew it 6 times around a circle, inverted it, and drew it’s reflection 6 times so you ended up with a pretty “snowflake” pattern.
When I was learning WPF, I remembered this program, and thought it would be a good way to learn animations, so I coded it up in WPF.
This week, I realized I was going to need to do some Silverlight animations for an upcoming project, so it seemed like a good idea to port it over to Silverlight. It turns out the code for the Silverlight version is almost identical to the WPF version with a few minor changes to the canvas handling. (It was easier to setup the timelines in SL)
It’s a simple process. It determines all the random numbers up front, sets up a timeline for the entire drawing process, the kicks off the animation and lets it go. Each line starts out as a single point which is hidden, and as it’s time for that part of the arm to be drawn, the timeline shows the line, and extends it to the to point using a double animation. Each timeline was placed into a storyboard with a begin time that is at the end of the previous timeline to get the smooth effect. I even played around with alternate effects like drawing each spoke simultaneously.
At any rate, here’s the output of the first Silverlight app I’m posting to this blog.
(I wish I could say I had still remembered the code, but I had to look it up. The wonders of the internet :) )