Previous Bezier Spline examples have illustrated how to draw a spline directly with pre-generated data in MXML. In some applications, it is desirable to define the Bezier Spline in MXML, but generate knots (control points) dynamically.
The following diagram shows our infamous arrow generated one segment at a time.
The demo allows one knot to be added or deleted (starting with the minimum of three) until the full set is defined. You may optionally close the spline to complete the drawing. Once the spline is closed, however, it is not recommended to remove and add knots because of the internal bookkeeping inside the Bezier Spline.
The control points are dynamically redrawn based on the internally generated propertyChange event, which also controls the spline redraw. This should illustrate the basics of defining a spline in MXML and dynamically generating knots via script. Download the MXML file here.
5 thoughts on “Degrafa – Dynamic Knot Generation”
What would be required to extend the Bezier spline so tension (or curvature) could be modified at each control point. Thus giving a person the ability to draw curves mixed with sharp angles.
If you want sharp angles mixed in with preserving continuity at other knots, it might be better to provide the ability to turn off the continuity matching at certain knots.
The tension parameter affects ‘how far away’ the control points are along the tangent line, once the tangent direction is determined. It needs to be some nonzero value just to have a proper set of Bezier control points in the first place.
Another possibility might be to create a more advanced spline that mixed linear segments in with Beziers. If you email me a sample set of points and how you might like to construct drawings with those points, I’ll see what I can come up with.
I think I was actually going to work on a component that allowed you to merge multiple geometries into one combined drawing path, that would probably accomplish what I was looking for.
That sounds like a spline where you would allow discontinuity of derivative at some of the knots, like where you join a quad. Bezier with a cubic or a simple line segment with another cubic spline, etc.
In the context of Degrafa, it might be best accomplished with another type of spline where the constituents would be lines, quad/cubic Beziers, and Bezier Splines.
Something interesting to think about.
This is realy great stuff i have seen and I realy apprecciate making such great work accessible for public .
I m having issue with this knot generation its hanging my browser (ie +firefox) I have latest degfree but still same issue cud u suggest me anything
Comments are closed.