> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Guntur N. Sarwohadi > Sent: 28 February 2007 14:56 > To: [email protected] > Subject: Re: [Flashcoders] simulating airbrush + calligraphy brush > > > apply the airbrush effect in a bitmap along the path - this way you > > can assign different brushes to the path after it's been > drawn, undo > > points etc. > > > mmm.. love the idea... but, what do you mean by placing > bitmaps along a path? did you mean it will also stretch or > just show for every vertex of the path? can you give me > pseudo-code of how to do this?
Depends how you want to do it, but the simplest is to work with a spline. One method is to take one brush point every few moments and turn this path into a Catmull-Rom spline. Then you can draw as many points along the spline as you like. A quick guide to catmull rom splines is here: http://www.mvps.org/directx/articles/catmull/, but in essence: function catmullPoint (p0, p1, p2, p3, t) { // where p0 to p3 are points, and t is the fraction of the distance between p1 and p2 return 0.5 * (2*p1 + t*(p2 - p0) + t*t*(2*p0 - 5*p1 + 4*p2 - p3) + t*t*t*(-p0 + 3*p1 - 3*p2 + p3)) } So if you have a list of points p0, p1, ... , pN, then you can draw as many points along the spline as you like. Flash uses quadratic bezier curves in the drawing API and cubic beziers in the actual application - a cubic bezier and a Catmull-Rom spline are essentially the same thing but with different parameterizations. Danny _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

