MCPcopy Create free account
hub / github.com/microsoft/SandDance / intersectPath

Function intersectPath

docs/app/js/sanddance-app.js:122186–122200  ·  view source on GitHub ↗
(draw1)

Source from the content-addressed store, hash-verified

122184var context = (context = (0, _vegaCanvas.canvas)(1, 1)) ? context.getContext("2d") : null;
122185const b = new Bounds();
122186function intersectPath(draw1) {
122187 return function(item, brush) {
122188 // rely on (inaccurate) bounds intersection if no context
122189 if (!context) return true; // add path to offscreen graphics context
122190 draw1(context, item); // get bounds intersection region
122191 b.clear().union(item.bounds).intersect(brush).round();
122192 const { x1 , y1 , x2 , y2 } = b; // iterate over intersection region
122193 // perform fine grained inclusion test
122194 for(let y21 = y1; y21 <= y2; ++y21)for(let x22 = x1; x22 <= x2; ++x22){
122195 if (context.isPointInPath(x22, y21)) return true;
122196 }
122197 // false if no hits in intersection region
122198 return false;
122199 };
122200}
122201function intersectPoint(item, box) {
122202 return box.contains(item.x || 0, item.y || 0);
122203}

Callers 2

markItemPathFunction · 0.70
sanddance-app.jsFile · 0.70

Calls 1

clearMethod · 0.65

Tested by

no test coverage detected