I was in a “star” mood this afternoon and created this Silverlight 2.0 demonstration.
For rendering it uses the CompositionTarget.Rendering method (the easiest way to control dynamic animations such as this). It also uses the VisualStateManager in a variety of places to control the user interface. I’ve become a big fan of the VSM – it’s easier to use than what WPF has as of 3.5 SP1 (I know it’s coming to WPF as well).
If you click into the UI to give it focus, you can press the [F] key to go full screen.
Switching to full screen is simple:
SilverlightHost host = Application.Current.Host; if(host != null) { Content content = host.Content; content.IsFullScreen = true; }
I’ve also used my ToColorFromHex function liberally (I used Kuler to make some colors and grabbed their hex values and directly pasted into my source code).
To create the star trails (as I’ve called them), I needed to do a little bit of trigonometry:
double radians = Math.Atan2(-star.Vector2D.Y, -star.Vector2D.X); (star.StarTrailUI.RenderTransform as RotateTransform).Angle = radians * 180 / Math.PI;
I used a RenderTransform in place of building a line with the proper X & Y coordinates as it made dealing with the LinearGradientBrush on the trail a TON easier (for me at least).
I’ve provided all of the source code – maybe you’ll find it useful (if so, I’d like to hear about it!).
Update: Fixed the links. Sorry!