Home > Degrafa > Degrafa Closed-Loop Catmull-Rom Spline

Degrafa Closed-Loop Catmull-Rom Spline

August 5, 2009

Just a quick update that support for closed-loop C-R splines has been added to Degrafa.  The algorithmis is the same one as used in Singularity and is documented in this TechNote.  The algorithm is designed to provide G-1 continuity at the join and works best if the knot sequence approximately represents a closed shape.  If the outermost knots are ‘pointing away’ from each other, behavior is unpredictable.

The current implementation is targeted towards a use of defining a single knot set with closure and no further modification.  It is not possible to add knots to an already closed C-R spline.  It is not currently possible to re-open the spline after closure.  These constraints are based on discussion with designers  on most likely usage. They are subject to future modification if people come up with applications that require closure and then re-opening of the spline.

A screenshot of a simple example is shown below,

clcr

There is no need to manually duplicate the first knot – doing so would result in undesired consequences.  The MXML is simply

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:comp="components.*"
 xmlns:degrafa="com.degrafa.*"
 xmlns:paint="com.degrafa.paint.*"
 xmlns:geom="com.degrafa.geometry.*"
 xmlns:splines="com.degrafa.geometry.splines.*"
 layout="absolute"
 width="600" height="500"
 pageTitle="Closed Catmull-Rom Spline">

 <mx:Canvas id="background" x="50" y="90" width="500" height="320"
  backgroundColor="#FFFFFF" />

 <paint:SolidStroke id="bluestroke" weight="2" color="#0000FF"/>
 <mx:Canvas id="splineLayer" />
 <splines:CatmullRomSpline id="spline" graphicsTarget="{[splineLayer]}"
  stroke="{bluestroke}"
  knots="150,230 230,170 370,210 390,320 280,360 160,320"
  closed="true" />
</mx:Application>

Not much here and not really worth a demo. Update SVN to access the new source.

Categories: Degrafa Tags: , ,
%d bloggers like this: