Wrapping Dynamic Text to a Circular Path

Over the holiday season I’ve had a lot of opportunity to play with various ideas that have been running through my head of late. One of these, inspired by my wife and six-month old, was a text string dynamically wrapped around the perimeter of a circle. I did some looking on the web, and while there’s a good deal of references to “circle math” with ActionScript, I was unable to find anything in the way of working with text and a circle. Here’s a rough-in of my solution.

First and foremost is a special thanks to Cody Lindley for the refresher course on trigonometry as posted on ActionScript.org. Secondly note that this example is unfinished (outside of the core functionality) and is for use at your own risk.

My solution involves taking a string and iterating through the characters, creating a TextField for each as I go. I subsequently iterate through each of the created letters and position and rotate them accordingly. This of course involves embedding a font as otherwise dynamically created TextField’s will not render when rotated. And at the end of the day, the quality of the rotated font was a bit of a let down - something I’m hoping the new text rendering engine in Maelstrom will resolve.

If you have seen other examples of this type of dynamic wrapping of text to a curve, or if you make improvements to the code (which should be pretty easy to do) I’d love it if you left a note in the comments of this post. I have countless code snippets like this from across the Macromedia product line, so if something like this is valuable to you, I’d also appreciate it if you left a comment.

5 Responses to “Wrapping Dynamic Text to a Circular Path”

  1. Scott Janousek Says:

    Ironic. I was just thinking of implementing something like that for a spinning CD-ROM … ended up hard coding warped text from photoshop … I’ll have to see if it fits my needs now … would be nice to be able to update text on-the-fly.

  2. zeh Says:

    Actionscript.org seems to be down for me. Is it working for anyone else?

  3. Kevin Hoyt Says:

    I just tested both the main address for ActionScript.org and the link to the trigonometry article, and both worked for me.

  4. zeh Says:

    Thanks, Kevin. It’s still down for me - it must be some DNS replication error since it can’t even resolve the host ip. I’ll try again tomorrow.

  5. Sergey Kovalyov Says:

    http://www.teknoel.com/show/?file=/theory/metrics/

    Here is the nice example, but without source code, unfortunately. It uses font metrics, so demonstrates a bit better quality.