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

Function intersectBoxLine

docs/app/js/sanddance-app.js:122212–122243  ·  view source on GitHub ↗
(box, x25, y24, u, v)

Source from the content-addressed store, hash-verified

122210 return intersectBoxLine(box, x24, y23, x2, y2);
122211}
122212function intersectBoxLine(box, x25, y24, u, v) {
122213 const { x1 , y1 , x2 , y2 } = box, dx = u - x25, dy = v - y24;
122214 let t0 = 0, t1 = 1, p, q, r, e;
122215 for(e = 0; e < 4; ++e){
122216 if (e === 0) {
122217 p = -dx;
122218 q = -(x1 - x25);
122219 }
122220 if (e === 1) {
122221 p = dx;
122222 q = x2 - x25;
122223 }
122224 if (e === 2) {
122225 p = -dy;
122226 q = -(y1 - y24);
122227 }
122228 if (e === 3) {
122229 p = dy;
122230 q = y2 - y24;
122231 }
122232 if (Math.abs(p) < 1e-10 && q < 0) return false;
122233 r = q / p;
122234 if (p < 0) {
122235 if (r > t1) return false;
122236 else if (r > t0) t0 = r;
122237 } else if (p > 0) {
122238 if (r < t0) return false;
122239 else if (r < t1) t1 = r;
122240 }
122241 }
122242 return true;
122243}
122244function blend(context25, item) {
122245 context25.globalCompositeOperation = item.blend || "source-over";
122246}

Callers 2

intersectRuleFunction · 0.70
intersectTextFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected