Home > Degrafa, Flex > Degrafa – Introduction to Splines Part X

Degrafa – Introduction to Splines Part X

December 15, 2008

Continuing from Part IX, one of the features of building the Bezier spline with cubic segments (individual cubic Bezier curves) is some flexibility in how the control cages are constructed.  The mathematical details are discussed in this TechNote.  At a high level, consider the spline as a rope that is passed through rings at each knot.  Suppose you could ‘pull’ on the rope at any ring.  What would happen to the rope?

We would expect the rope to get tighter and tighter until it reached some point that it could not be pulled any further (without breaking).  Intuitively, we would call this tension.  Bezier curves (individual or composite) do not naturally have tension parameters (as say a cardinal spline).  We can fake a tension setting as a natural consequence of assigning control points.

In the Singularity Bezier spline, the tension setting is a map of a tension scale to parameter values.  The tension scale varies from 1 (loose) to 5 (tight).  The internal parameter map is open for experimentation and some limitations are discussed in the above TechNote.

From a usability standpoint, all the average user need be concerned with is the tension setting from 1-5.  The default value is 1, which can be thought of as having the rope pass ‘loosely’ through the rings.  On average, the spline appears to have more curvature when passing through the knots.

The tension parameter is exposed to MXML, and the following illustrates setting to it maximum value of 5,

<BezierSpline id="mySpline" graphicsTarget="{[theTarget]}"
 verticalCenter="0" horizontalCenter="0"
 data="200,100 200,300 100,300 300,500 500,300
  400,300 400,100"
 fill="{myFill}" autoClose="true" tension="5">

producing the following drawing.

Cubic Bezier Spline with Maximum Tension

Cubic Bezier Spline with Maximum Tension

As you work through the code, you may notice a parameter or two such as ‘quality’ that appear to have no effect on the output.  This parameter in particular was an artifact of the Singularity cubic Bezier spline that was built on top of the FastBezier class.  The quality parameter controlled the number of subdivision steps (used to approximate the cubic Bezier with a small number of quadratic Bezier).  This parameter allowed render quality to be traded for performance.  It will be removed from future versions of the Degrafa Bezier Spline.

This completes the basic introduction to splines in Degrafa.  Future posts will provide demos of more advanced usage of the Degrafa splines and illustration of new features as they are added.

About these ads
Categories: Degrafa, Flex Tags: , , , ,
  1. Franck
    December 15, 2008 at 9:37 am

    Excellent!
    I suppose the BezierSpline class will come here :

    http://code.google.com/p/degrafa/source/browse/#svn/trunk/Degrafa/com/degrafa/geometry

  2. January 2, 2009 at 12:11 pm

    Nice tutorial, thanks.
    I’m trying to put a bezier spline on a sphere with pv3d but the graphic won’t appear… Is there a particular way to do that?

  1. No trackbacks yet.
Comments are closed.
Follow

Get every new post delivered to your Inbox.

Join 1,333 other followers

%d bloggers like this: