I recently wanted to use Bezier curves in Flash to create some organic looking structures. This is a nice easy way to generate some interesting plant-like line drawing. The problem I almost immediately encountered was not being able to plot a given position on a Bezier curve, for example, in order to be able to add a leaf-like object to a 'plant'.
The way I found of overcoming this problem was to use de Casteljau's algorithm. Have a play with the illustration swf below and you may well guess how to evaluate the x, y coords of points that intersect the Bezier curve. You can drag the origin, control and anchor points (red dots) to change the nature of the curve.
I have used this technique to create the larger swf below which shows the small white squares being plotted to intersecting points on each curve. For a bit of extra fun I have added some sliders to control the appearance of the 'Bezier plants'.
All source code, including the algorithm, below.
|
||||
|
|
This Month
Month Archive
Login
|
|||
|
|
||||
