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

An Animation Involving a Text Geometry

June 25, 2006
Roscoe, NY

In my forthcoming book I have a little class that defines a bunch of properties necessary to construct a FormattedText object, and also defines a read-only Geometry property that calls BuildGeometry from that FormattedText object. You can include this class in a Resources section of a XAML file and then use the resultant text geometry object for graphics.

I wanted the following program to be loose XAML, so I dumped a serialized GeometryGroup based on a large Times New Roman Bold font to a file, and merged it into some hand-written XAML, and put in a bunch of line breaks just in case you want to print the thing:

AnimatedTextGeometry.xaml

If the text is too big for your screen, here's a version in a Viewbox:

AnimatedTextGeometryWithViewbox.xaml

I give the text outline a dotted line and then animate StrokeDashOffset in discrete jumps. The effect is pretty cool (I think), and I am still amazed that styled lines on a closed path don't have any discontinuities. The person at Microsoft responsible for that logic should be extremely proud, and my hat is off to you.


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

(c) Copyright Charles Petzold
www.charlespetzold.com