Created
September 8, 2015 17:52
-
-
Save tanmaypatel/7dbf26254c33c29e77ab to your computer and use it in GitHub Desktop.
Area tag to SVG Path Element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var coordinatesData = "412,156, 427,161, 429,163, 444,153, 453,155, 457,159, 452,168, 459,174, 455,178, 460,179, 463,193, 460,203, 441,214, 436,217, 458,238, 469,257, 479,267, 478,269, 479,285, 458,309, 436,310, 414,305, 410,323, 397,334, 379,313, 389,316, 401,320, 399,305, 382,300, 371,290, 367,296, 366,298,338,274, 332,272, 300,239, 316,238, 316,234, 313,230, 328,225, 333,213, 338,196, 333,181, 337,166, 345,145"; | |
var coordsTokens = coordinatesData.split(/\s*,\s*/); | |
var pathData = ""; | |
for(var i = 0; i < coordsTokens.length; i+=2) | |
{ | |
if(i<2) | |
{ | |
pathData += "M" | |
} | |
else | |
{ | |
pathData += "L" | |
} | |
pathData += coordsTokens[i] + "," + coordsTokens[i+1] + " "; | |
}; | |
pathData += "z"; | |
var $path = $('<path d="' + pathData + '" />'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment