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

Degrafa – Introduction to Splines Part IX

December 12, 2008

Continuing from Part VIII, what happens if we want to close the arrow outline? We have discussed auto-closure for the Bezier spline in a previous post and this feature is available in the Degrafa spline.  Not only is it available, it is exposed to direct manipulation in MXML.  Simply modify the <BezierSpline> tag as follows,

<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">

There was a small bug in the initial port, so make sure you first update the code from SVN.  This produces the following drawing,

Auto-closed Cubic Bezier Spline

Auto-closed Cubic Bezier Spline

Degrafa splines are ‘open’ by default.  You must specify closure (if it is supported by a particular spline) by setting the autoClose parameter to true.  The closure is automatic; no additional knots or programming action are required.  The diagram below illustrates construction of the individual cubic Bezier control points.

Control Points for Individual Cubic Bezier Curves

Control Points for Individual Cubic Bezier Curves

An additional knot is automatically added to the data set to be interpolated.  The added knot is a duplicate of the first interpolation point.  An additional segment (cubic Bezier curve) is added to the spline.  Recall that the spline is sometimes called a composite Bezier curve as it is composed of independent cubic Bezier curves with continuity conditions imposed at the joins.

The control points for the final cubic Bezier curve in the composition are computed so that the slope of the in-tangent to the final knot matches that of the out-tangent of the first knot.  The same condition is applied to the in- and out-tangents of the final knot.  This preserves continuity at all joins.

Another parameter is available to adjust the visual characteristics of the interpolated spline.  In the spirit of a weekend cliffhanger, think about a rope that is threaded through a ring at each knot location.  What would happen if you pulled that rope tighter?

Categories: Degrafa, Flex Tags: , , , ,
  1. No comments yet.
  1. December 15, 2008 at 9:15 am
Comments are closed.
%d bloggers like this: