Skip to content

Instantly share code, notes, and snippets.

@MattMcFarland
Created May 8, 2011 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattMcFarland/961260 to your computer and use it in GitHub Desktop.
Save MattMcFarland/961260 to your computer and use it in GitHub Desktop.
polygon
private static function drawPolygon(map:Map, rect:Rectangle):Vector.<Point>
{
var tileWidth:int = map._tileWidth;
var tileHeight:int = map._tileHeight;
var topRight:Point = tileToPixelCoords(map, new Point(rect.width,0));
var bottomRight:Point = tileToPixelCoords(map, rect.bottomRight);
var bottomLeft:Point = tileToPixelCoords(map, new Point(0,rect.bottom));
var polygon:Vector.<Point> = new Vector.<Point>();
polygon.push(qPoint(tileToPixelCoords(map, qPoint(rect.topLeft))));
polygon.push(new Point( topRight.x + tileWidth / 2,
topRight.y + tileHeight / 2));
polygon.push(new Point( bottomRight.x, bottomRight.y + tileHeight));
polygon.push(new Point( bottomLeft.x - tileWidth / 2,
bottomLeft.y + tileHeight / 2));
return polygon;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment