Haxe/AS3/PHP/JS: Orthogonal Polygon Partitioning