Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created September 22, 2014 00:08
Show Gist options
  • Select an option

  • Save mattlundstrom/c8dec3b8cae042285907 to your computer and use it in GitHub Desktop.

Select an option

Save mattlundstrom/c8dec3b8cae042285907 to your computer and use it in GitHub Desktop.
drawDottedLine( new Point( 0, 0 ), new Point( 500, 100 ), 0x000000, 1, 3, 0, 1 );
function drawDottedLine( _p1:Point, _p2:Point, _color:uint = 0x000000, _thickness:Number = 1, _gap:Number = 10, _offset:Number = 0, _percent:Number = 1 ):void{
var line:MovieClip = new MovieClip();
addChild( line );
var distance:Number = distance( _p1, _p2 );
var increments:int = distance / _gap;
var gfx:Graphics = line.graphics;
gfx.beginFill( _color, _thickness );
for( var i:int = 0; i< increments; i++ )
{
var percetDrawn:Number = i * _gap / distance;
var _x:Number = lerp( _p1.x, _p2.x, percetDrawn );
var _y:Number = lerp( _p1.x, _p2.x, percetDrawn );
gfx.drawCircle( _x, _y, 2 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment