MCPcopy Create free account
hub / github.com/breck7/scroll / polygonInside

Function polygonInside

external/.d3.js:11212–11224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11210 }
11211
11212 function polygonInside() {
11213 var winding = 0;
11214
11215 for (var i = 0, n = polygon.length; i < n; ++i) {
11216 for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) {
11217 a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1];
11218 if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; }
11219 else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; }
11220 }
11221 }
11222
11223 return winding;
11224 }
11225
11226 // Buffer geometry within a polygon and then clip it en masse.
11227 function polygonStart() {

Callers 1

polygonEndFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected