Dashed Line Decorator in Freehand Drawing Library

I’ve been insanely busy over the last couple months, for which I should be grateful, but at the same time a little bummed over the lack of posts.  Here’s a quick update on the new Decorator architecture in the Freehand Drawing Library.

In the prior post, I mentioned that the drawing algorithm is now abstracted into its own API.  A concrete implementation of any algorithm is injected into the BasicStroke class upon assigning a data provider.  Now, the drawing API itself is abstracted.  Using a Decorator pattern, it is now possible to dynamically change the line drawing style applied inside a specified drawing engine.  This completely separates the algorithm for computing the constituent points of a stroke from the line style used to draw the stroke.

Just like SkinnableComponents in Flex, the stroke algorithm and visual representation are now completely decoupled.  Here is a screenshot for a dashed-line Decorator.  The same smoothed-stroke algorithm for solid strokes is used in this example, except it is now agnostic to how the small line segments are drawn.

I’ll have some additional exciting announcements in the near future.  In the mean time, back to my gig!

Advertisement