Home > Flex, Math, Portfolio > Lang Simplification in Freehand drawing library

Lang Simplification in Freehand drawing library

October 31, 2011

A new LineUtils class was added to the Beta 0.9 distribution of the Freehand drawing library.  This class is a repository for methods involving line simplification and related utilities.  Lang Simplification is the baseline algorithm in the class and more sophisticated algorithms will be added in future releases.  This supports efforts by beta users to create stroke editors.  Adaptive versions of simplification and smoothing are also useful in the constant-width stroke classes coming in the full 1.0 release.

A simple example of Lang is shown below.

The dots represent the raw stroke coordinates.  The black lines segments simply connect the dots.  The red line shows the simplification with a small look-ahead and pixel tolerance of 10.  The current implementation is non-recursive and should be suitably fast for interactive stroke editing (after drawing a raw stroke).

The current beta is closed, however, I may open up a couple more slots when RC1 is released since there is growing interest in constant-width strokes.  My current plan is to use an injectable drawing class to do the actual drawing and have one base class manage the interface with the user (implementing IFreehandDrawable).  This provides two benefits.  It allows users to create factories that return IFreehandDrawable instances based on the desired stroke characteristics.  The actual application is authored to an interface, not a specific implementation.  The injectable drawing class allows a wide variety of drawing algorithms to be applied (including specialized implementations for one-off applications) without bloating the library with a new class for each variant.

Categories: Flex, Math, Portfolio
%d bloggers like this: