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

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

Text Deformation Based on Bézier Splines

November 29, 2009
New York, N.Y.

In previous blog entries I showed how to use a WPF program (called TextOutlineGenerator and available from here) to generate text outlines that you can then use in Silverlight programs for some interesting effects. This morning I woke up with an idea to deform a whole character string based on two Bézier curves.

Conceptually, the math is fairly straightforward: Consider a text string whose character outlines are polylines. The entire text string is definable as a bunch of Point objects. Each of these Point objects is within a Rect bounding box. Although the Point objects define an actual coordinate position, they can also be expressed as fractional coordinates (xFraction, yFraction) relative to the bounding box, where xFraction and yFraction range from 0 to 1.

One Bézier curve is aligned with the top of the bounding box, and the other with the bottom of the bounding box. As you change the end points and control points of these two Bézier curves, each point that defines the text string is moved to a new location. That location is calculated by using xFraction as the dependent variable t in the two Bézier formulas to get a point on each of the Bézier curves, and then using yFraction to calculate a weighted average of those two points.

You can run the program from here:


As the name of the program suggests, you click to go into deformation mode. You click again to return the display to normal. Here's the source code.


Mr Petzold,

Would you be so kind as to provide a version of this project that uses the Path mini-language.

I need to dynamically create the paths, and I found a way of doing that via a call to a WPF based web service, but it only returns the mini-language.

Once i have the mini-language path rendered, I need to be able to distort it as you do in this example.

PLEASE help me if you can...

David, Fri, 9 Apr 2010 16:13:38 -0400

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

(c) Copyright Charles Petzold