Skip to content

Instantly share code, notes, and snippets.

@lucasmotta
Created May 17, 2011 02:09
Show Gist options
  • Save lucasmotta/975761 to your computer and use it in GitHub Desktop.
Save lucasmotta/975761 to your computer and use it in GitHub Desktop.
Returns a specific point from segments of points
public function getPointAt(progress : Number) : Point
{
var i : int;
var length : int = _points.length;
var pointProgress : Number;
var totalProgress : Number = 0;
for(i = 1 ; i < length; i++)
{
pointProgress = Point.distance(_points[i], _points[i - 1]) / _length;
totalProgress += pointProgress;
if(totalProgress >= progress)
{
return Point.interpolate(_points[i - 1], _points[i], (totalProgress - progress) / pointProgress);
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment