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

Function intersectBoxLine

docs/tests/v3/es6/js/sanddance-test-es6.js:70143–70174  ·  view source on GitHub ↗
(box, x25, y24, u, v)

Source from the content-addressed store, hash-verified

70141 return intersectBoxLine(box, x24, y23, x2, y2);
70142}
70143function intersectBoxLine(box, x25, y24, u, v) {
70144 const { x1 , y1 , x2 , y2 } = box, dx = u - x25, dy = v - y24;
70145 let t0 = 0, t1 = 1, p, q, r, e;
70146 for(e = 0; e < 4; ++e){
70147 if (e === 0) {
70148 p = -dx;
70149 q = -(x1 - x25);
70150 }
70151 if (e === 1) {
70152 p = dx;
70153 q = x2 - x25;
70154 }
70155 if (e === 2) {
70156 p = -dy;
70157 q = -(y1 - y24);
70158 }
70159 if (e === 3) {
70160 p = dy;
70161 q = y2 - y24;
70162 }
70163 if (Math.abs(p) < 1e-10 && q < 0) return false;
70164 r = q / p;
70165 if (p < 0) {
70166 if (r > t1) return false;
70167 else if (r > t0) t0 = r;
70168 } else if (p > 0) {
70169 if (r < t0) return false;
70170 else if (r < t1) t1 = r;
70171 }
70172 }
70173 return true;
70174}
70175function blend(context25, item) {
70176 context25.globalCompositeOperation = item.blend || "source-over";
70177}

Callers 2

intersectRuleFunction · 0.70
intersectTextFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected