Skip to content

Instantly share code, notes, and snippets.

@jayproulx
Created August 4, 2010 19:31
Show Gist options
  • Save jayproulx/508650 to your computer and use it in GitHub Desktop.
Save jayproulx/508650 to your computer and use it in GitHub Desktop.
function lineTowards(g:Graphics, x:int, y:int, length:int):void
{
var c:Number = Math.sqrt(Math.sqr(x) + Math.sqr(y));
var ratio:Number = length / c;
g.lineTo(x*ratio, y*ratio);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment