PETZOLD BOOK BLOG

Charles Petzold on writing books, reading books, and exercising the internal UTM


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

I Saw a Silly Animation This Morning...

April 2, 2006
New York City

... on CNN Headline News to remind us that Daylight Saving Time has begun, so of course I had to reproduce it in XAML. You can download or run the TimeChange.xaml file or look at it here:

A few notes:

The RenderTransformOrigin vertical coordinate of 0.8 was selected empirically so the rotation occurs in the horizontal center of the letter approximately on the baseline.

Each DoubleAnimation contains a minimum amount of information to make this work. By default, the To value is picked up from the default value of the property being animated (which is 0). The default Duration is 1 second. I wanted to code everything for a duration of 1 second per letter and then adjust the overall speed later using SpeedRatio.

I wanted the letters to spin in succession, followed by a pause and then repeat the whole thing. However, when I set both a SpeedRatio and a Duration on the Storyboard, funny things started happening. That's why I introduced a ParallelTimeline element with the Duration and RepeatBehavior, and then put the SpeedRatio of 2.5 in the Storyboard. In real time, the whole thing runs 6 seconds: 4 seconds of spinning letters and a 2 second pause.


Recent Entries
< PreviousBrowse the ArchivesNext >
Subscribe to the RSS Feed

(c) Copyright Charles Petzold
www.charlespetzold.com