Beta Version of Freehand Drawing Library

Just a quick blurb about some interesting work I’ve been doing lately for which I retain complete code and IP interests.  I’ve received several inquiries over the last six months regarding freehand line drawing.  My general tendency is to refer people to the FlashAndMath example since that’s very similar to an algorithm I used back in the early ’90’s for variable-thickness drawings for a kiosk application.  For people wanting smooth, continuous point interpolation, I already have a variety of splines both in and outside Degrafa.

Requests for capability outside the F&M example have grown to the point that I decided to take this project on for a couple clients, especially since it piqued my research interests in terms of longer-term applications.  In my client’s minds, there is also a big difference between some script thrown together in a frame of a .FLA and a robust, commercial-quality AS 3 class library 🙂

The initial goal of this project is to provide a Freehand drawing class (Sprite subclass) that handles the single responsibility of drawing strokes in a defined boundary.  As always, I try to code to interfaces, not specific implementations, so Freehand implements IFreehandDrawable .  The algorithm is fundamentally similar to the one I used in the ’90’s and the F&M example, with support for speed-sensitive width, but fixed coloring.

Other features include the ability to reference and highlight individual strokes and input strokes manually as well as through mouse motion.  Mouse motions may be cached and then fed back into Freehand one at a time to create a stroke library or animate strokes.  Bitmap snapshot of the drawing area is provided.

Erasure by individual stroke or all strokes is possible and a dispose() method is provided to properly prepare Freehand instances for garbage collection.  Freehand instances may be used anywhere a Sprite is applicable (AS only, F3, or F4).  The current demo adds the Freehand instance as a child of a SpriteVisualElement.  Drawings occur inside bounds supplied during initialization and the Freehand container may be masked.

Internally, strokes are treated as Sprites, not bitmaps.  In the next release, a Stroke will be generalized to an implementation of a general IStroke interface, which opens the door for editable and transformable strokes.  A general-purpose gestures library will be used to map generic gestures to specific mouse/touch interactions to support device as well as online applications.

A screenshot of a Flex 4 (Spark) demo is shown below.

I can provide a demo link to interested clients.

Advertisement

2 thoughts on “Beta Version of Freehand Drawing Library

  1. Hey,

    looks interessting. I’ve tried it for my own and it would be great if i can see your demo.

    thanks andre

    1. Andre – send me email at theAlgorithmist[at]gmail[dot]com with a description of your project and budget. There is a license fee involved for this software (already licensed to two clients).

      thanks,

      – jim

Comments are closed.