MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / findCorner

Function findCorner

src/test/resources/libraries/html2canvas/html2canvas.js:2099–2120  ·  view source on GitHub ↗
(width, height, x, y, closest)

Source from the content-addressed store, hash-verified

2097 };
2098 var distance = function (a, b) { return Math.sqrt(a * a + b * b); };
2099 var findCorner = function (width, height, x, y, closest) {
2100 var corners = [
2101 [0, 0],
2102 [0, height],
2103 [width, 0],
2104 [width, height]
2105 ];
2106 return corners.reduce(function (stat, corner) {
2107 var cx = corner[0], cy = corner[1];
2108 var d = distance(x - cx, y - cy);
2109 if (closest ? d < stat.optimumDistance : d > stat.optimumDistance) {
2110 return {
2111 optimumCorner: corner,
2112 optimumDistance: d
2113 };
2114 }
2115 return stat;
2116 }, {
2117 optimumDistance: closest ? Infinity : -Infinity,
2118 optimumCorner: null
2119 }).optimumCorner;
2120 };
2121 var calculateRadius = function (gradient, x, y, width, height) {
2122 var rx = 0;
2123 var ry = 0;

Callers 1

calculateRadiusFunction · 0.85

Calls 2

distanceFunction · 0.85
reduceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…