This file contains 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
function pathFromPolygon(points) { | |
var p = points.split(/\s+/); | |
var path = ''; | |
for( var i = 0, len = p.length; i < len; i++ ) { | |
path += (i && 'L' || 'M') + p[i] | |
} | |
return path; | |
} |
This file contains 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
# Recursive descent parser | |
# http://adayinthepit.com/2011/07/19/hanging-in-the-treetops/ | |
def exp(stack) | |
token = stack.shift | |
return stack if token =~ /[0-9]/ || token =~ /X/ && exp(stack) || token =~ /Y|Z/ && exp(stack) && exp(stack) | |
false | |
end | |
def parse(source) | |
stack = exp(source.split('')) |
OlderNewer