import com.bumpslide.core.MtascApplet; import com.bumpslide.util.ClassUtil; import com.bumpslide.util.CubicBezier; import com.bumpslide.util.Draw; /** * Interpolation Test * * @mtasc -swf Interpolation.swf -header 500:400:31:eeeedd -main */ class com.bumpslide.example.applets.Interpolation extends MtascApplet { static function main(root_mc:MovieClip) : Void { ClassUtil.applyClassToObj( Interpolation, root_mc ); } var targetPoints:Array; var interpolatedPoints:Array; var sourceUrl = "Interpolation.as"; function Interpolation() { super(); onMouseDown = reset; reset(); message('Click to randomize...'); } /** * randomizes points, interpolates, and redraws */ function reset() { // create some random points targetPoints = new Array(); for(var i=0; i<9; i++) { targetPoints.push({x:50+50*i, y:Math.random() * 300 + 50}); } // interpolate var overshootFactor = 20; interpolatedPoints = CubicBezier.interpolatePiecewise( targetPoints, overshootFactor ); // draw draw(); } /** * Plots points, and draws Beziers using interpolation data */ function draw() { // create new clip to hold drawing var holder:MovieClip = createEmptyMovieClip('holder_mc', 1 ); // draw target points as little black boxes for(var i=0; i