UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

1,151 lines (1,150 loc) 40.8 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { Base, Point_$type, Number_$type, Boolean_$type, typeCast, fromEnum, markType, PointUtil } from "./type"; import { Rect } from "./Rect"; import { BezierSegment } from "./BezierSegment"; import { PolyBezierSegment } from "./PolyBezierSegment"; import { List$1 } from "./List$1"; import { Tuple$2 } from "./Tuple$2"; import { PolyLineSegment } from "./PolyLineSegment"; import { ArcCenterInfo } from "./ArcCenterInfo"; import { ArcSegment } from "./ArcSegment"; import { Size } from "./Size"; import { MathUtil } from "./MathUtil"; import { LineSegment } from "./LineSegment"; import { PathGeometry } from "./PathGeometry"; import { LineGeometry } from "./LineGeometry"; import { RectangleGeometry } from "./RectangleGeometry"; import { EllipseGeometry } from "./EllipseGeometry"; import { isNaN_, isInfinity } from "./number"; /** * @hidden */ export let CoreGeometryUtil = /*@__PURE__*/ (() => { class CoreGeometryUtil extends Base { static q(a, b, c) { let d = b.x; let e = b.y; let f = c.x; let g = c.y; let h = a.x; let i = a.y; let j = f - d; let k = g - e; let l = j * j + k * k; if (l == 0) { return (h - d) * (h - d) + (i - e) * (i - e); } let m = ((h - d) * j + (i - e) * k) / l; m = m < 0 ? 0 : (m > 1 ? 1 : m); let n = d + j * m; let o = e + k * m; let p = (n - h) * (n - h) + (o - i) * (o - i); return p; } static z(a, b, c) { let d = (b.y <= a.y && c.y > a.y) || (c.y <= a.y && b.y > a.y); if (d) { let e = (c.x - b.x) / (c.y - b.y); let f = (a.y - b.y); let g = e * f; let h = b.x + g; if (a.x < h) { if (c.y > b.y) { return 1; } else { return -1; } } } return 0; } static c(a, b) { let c = (b.top <= a.y && b.bottom > a.y) && (b.left >= a.x || b.right >= a.x); return c; } static w(a, b, c) { let d = b; let e = c.e; let f = c.f; let g = c.g; let h = CoreGeometryUtil.ao(d, e, f, g); if (!CoreGeometryUtil.c(a, h)) { return 0; } let i = CoreGeometryUtil.an(d, e, f, g); if (!CoreGeometryUtil.c(a, i)) { return 0; } return CoreGeometryUtil.x(a, d, e, f, g); } static aa(a, b, c) { if (c.b == null || c.b.count < 3) { return 0; } let d = c.b.count; let e = b; let f = b; let g = b; let h = b; let i = 0; let j = 0; while (i < d) { if (i + 1 < d && i + 2 < d) { f = c.b._inner[i]; g = c.b._inner[i + 1]; h = c.b._inner[i + 2]; let k = CoreGeometryUtil.ao(e, f, g, h); if (CoreGeometryUtil.c(a, k)) { let l = CoreGeometryUtil.an(e, f, g, h); if (CoreGeometryUtil.c(a, l)) { j += CoreGeometryUtil.x(a, e, f, h, h); } } e = h; } i = i + 3; } return j; } static x(a, b, c, d, e) { return CoreGeometryUtil.ad(a, b, c, d, e, 1, 0); } static ao(a, b, c, d) { let e = new List$1(Point_$type, 0); e.add(a); e.add(b); e.add(c); e.add(d); let f = 1.7976931348623157E+308; let g = 1.7976931348623157E+308; let h = -1.7976931348623157E+308; let i = -1.7976931348623157E+308; for (let j = 0; j < e.count; j++) { let k = e._inner[j]; f = k.x < f ? k.x : f; h = k.x > h ? k.x : h; g = k.y < g ? k.y : g; i = k.y > i ? k.y : i; } return new Rect(0, f, g, h - f, i - g); } static an(a, b, c, d) { let e = new List$1(Point_$type, 0); e.add(a); e.add(d); let f = CoreGeometryUtil.n(a.x, b.x, c.x, d.x); for (let g = 0; g < f.count; g++) { if (f._inner[g] >= 0 && f._inner[g] <= 1) { e.add(CoreGeometryUtil.ak(a, b, c, d, f._inner[g])); } } let h = CoreGeometryUtil.n(a.y, b.y, c.y, d.y); for (let i = 0; i < h.count; i++) { if (h._inner[i] >= 0 && h._inner[i] <= 1) { e.add(CoreGeometryUtil.ak(a, b, c, d, h._inner[i])); } } let j = 1.7976931348623157E+308; let k = 1.7976931348623157E+308; let l = -1.7976931348623157E+308; let m = -1.7976931348623157E+308; for (let n = 0; n < e.count; n++) { j = Math.min(j, e._inner[n].x); l = Math.max(l, e._inner[n].x); k = Math.min(k, e._inner[n].y); m = Math.max(m, e._inner[n].y); } return new Rect(0, j, k, l - j, m - k); } static n(a, b, c, d) { let e = 3 * (-a + 3 * b - 3 * c + d); let f = 6 * (a - 2 * b + c); let g = 3 * (b - a); let h = CoreGeometryUtil.o(e, f, g); return h; } static o(a, b, c) { let d = new List$1(Number_$type, 0); let e = Math.abs(a) < 1E-09; if (e) { if (Math.abs(b) > 1E-09) { let f = -c / b; if (!isNaN_(f) && !isInfinity(f)) { d.add(f); } } } else { let g = b * b - 4 * a * c; if (g >= 0) { let h = Math.sqrt(g); let i = (-b + h) / (2 * a); let j = (-b - h) / (2 * a); d.add(i); d.add(j); } } return d; } static ak(a, b, c, d, e) { let f = 1 - e; let g = f * f * f; let h = f * f; let i = e * e * e; let j = e * e; let k = g * a.x + 3 * h * e * b.x + 3 * f * j * c.x + i * d.x; let l = g * a.y + 3 * h * e * b.y + 3 * f * j * c.y + i * d.y; return { $type: Point_$type, x: k, y: l }; } static ah(a, b, c, d) { if (c.b == null || c.b.count < 3) { return new Tuple$2(Boolean_$type, Point_$type, CoreGeometryUtil.e(a, b, d), b); } let e = c.b.count; let f = b; let g = b; let h = b; let i = b; let j = 0; while (j < e) { if (j + 1 < e && j + 2 < e) { g = c.b._inner[j]; h = c.b._inner[j + 1]; i = c.b._inner[j + 2]; let k = CoreGeometryUtil.ao(f, g, h, i); if (RectUtil.r(k, d).containsPoint(a)) { let l = CoreGeometryUtil.an(f, g, h, i); if (RectUtil.r(l, d).containsPoint(a)) { if (CoreGeometryUtil.ae(a, f, g, h, i, d).c) { return new Tuple$2(Boolean_$type, Point_$type, true, c.b._inner[c.b.count - 1]); } } } f = i; } j = j + 3; } return new Tuple$2(Boolean_$type, Point_$type, false, c.b._inner[c.b.count - 1]); } static e(a, b, c) { let d = b.x - a.x; let e = b.y - a.y; let f = d * d + e * e; if (f < c * c) { return true; } return false; } static ag(a, b, c, d) { let e = b; let f = c.e; let g = c.f; let h = c.g; let i = CoreGeometryUtil.ao(e, f, g, h); if (!RectUtil.r(i, d).containsPoint(a)) { return new Tuple$2(Boolean_$type, Point_$type, false, h); } let j = CoreGeometryUtil.an(e, f, g, h); if (!RectUtil.r(j, d).containsPoint(a)) { return new Tuple$2(Boolean_$type, Point_$type, false, h); } return CoreGeometryUtil.ae(a, e, f, g, h, d); } static ae(a, b, c, d, e, f) { if (CoreGeometryUtil.m(a, b, c, d, e, f, 0)) { return new Tuple$2(Boolean_$type, Point_$type, true, e); } else { return new Tuple$2(Boolean_$type, Point_$type, false, e); } } static ad(a, b, c, d, e, f, g) { if (g >= CoreGeometryUtil.u) { return CoreGeometryUtil.z(a, b, e); } if (CoreGeometryUtil.f(b, c, d, e)) { return CoreGeometryUtil.z(a, b, e); } let h = CoreGeometryUtil.ao(b, c, d, e); if (h.width < (f / 2) && h.height < (f / 2)) { return CoreGeometryUtil.z(a, b, e); } let i = CoreGeometryUtil.a(b, c, d, e, 0.5); let j = i[0]; let k = i[1]; let l = i[2]; let m = i[3]; let n = i[4]; let o = i[5]; let p = i[6]; let q = i[7]; let r = (CoreGeometryUtil.ad(a, j, k, l, m, f, g + 1)); let s = (CoreGeometryUtil.ad(a, n, o, p, q, f, g + 1)); return r + s; } static m(a, b, c, d, e, f, g) { if (g >= CoreGeometryUtil.u) { return CoreGeometryUtil.i(a, b, e, f); } if (CoreGeometryUtil.f(b, c, d, e)) { return CoreGeometryUtil.i(a, b, e, f); } let h = CoreGeometryUtil.ao(b, c, d, e); if (h.width < (f / 2) && h.height < (f / 2)) { return CoreGeometryUtil.i(a, b, e, f); } let i = CoreGeometryUtil.a(b, c, d, e, 0.5); let j = i[0]; let k = i[1]; let l = i[2]; let m = i[3]; let n = i[4]; let o = i[5]; let p = i[6]; let q = i[7]; if (CoreGeometryUtil.m(a, j, k, l, m, f, g + 1)) { return true; } if (CoreGeometryUtil.m(a, n, o, p, q, f, g + 1)) { return true; } return false; } static a(a, b, c, d, e) { let f = { $type: Point_$type, x: a.x + e * (b.x - a.x), y: a.y + e * (b.y - a.y) }; let g = { $type: Point_$type, x: b.x + e * (c.x - b.x), y: b.y + e * (c.y - b.y) }; let h = { $type: Point_$type, x: c.x + e * (d.x - c.x), y: c.y + e * (d.y - c.y) }; let i = { $type: Point_$type, x: f.x + e * (g.x - f.x), y: f.y + e * (g.y - f.y) }; let j = { $type: Point_$type, x: g.x + e * (h.x - g.x), y: g.y + e * (h.y - g.y) }; let k = { $type: Point_$type, x: i.x + e * (j.x - i.x), y: i.y + e * (j.y - i.y) }; let l = a; let m = f; let n = i; let o = k; let p = k; let q = j; let r = h; let s = d; let t = new Array(8); t[0] = l; t[1] = m; t[2] = n; t[3] = o; t[4] = p; t[5] = q; t[6] = r; t[7] = s; return t; } static f(a, b, c, d) { let e = Math.sqrt(CoreGeometryUtil.q(b, a, d)); let f = Math.sqrt(CoreGeometryUtil.q(c, a, d)); if (e + f < 0.0001) { return true; } return false; } static ab(a, b, c) { if (c._points == null || c._points.count == 0) { if (PointUtil.equals(a, b)) { return 1; } } let d = b; let e = b; let f = 0; for (let g = 0; g < c._points.count; g++) { e = c._points._inner[g]; f += CoreGeometryUtil.z(a, d, e); d = e; } return f; } static ai(a, b, c, d) { if (c._points == null || c._points.count == 0) { return new Tuple$2(Boolean_$type, Point_$type, CoreGeometryUtil.e(a, b, d), b); } let e = b; let f = b; for (let g = 0; g < c._points.count; g++) { f = c._points._inner[g]; if (CoreGeometryUtil.i(a, e, f, d)) { return new Tuple$2(Boolean_$type, Point_$type, true, c._points._inner[c._points.count - 1]); } e = f; } return new Tuple$2(Boolean_$type, Point_$type, false, c._points._inner[c._points.count - 1]); } static b(a, b) { let c = (a.x - b.e.x) / 2; let d = (a.y - b.e.y) / 2; let e = Math.abs(b.f.width); let f = Math.abs(b.f.height); let g = MathUtil.p(b.c); let h = Math.cos(g); let i = Math.sin(g); let j = h * c + i * d; let k = -i * c + h * d; let l = ((j * j) / (e * e)) + ((k * k) / (f * f)); if (l > 1) { let m = Math.sqrt(l); e = e * m; f = f * m; } let n = e * e; let o = f * f; let p = j * j; let q = k * k; let r = (n * o) - (n * q) - (o * p); let s = ((n * q) + (o * p)); if (s == 0) { return null; } let t = Math.sqrt(Math.max(0, r / s)); if (b.b == (b.d == 1)) { t = -t; } let u = t * ((e * k) / f); let v = t * -((f * j) / e); let w = (h * u) - (i * v) + ((b.e.x + a.x) / 2); let x = (i * u) + (h * v) + ((b.e.y + a.y) / 2); let y = CoreGeometryUtil.p(1, 0, (j - u) / e, (k - v) / f); let z = CoreGeometryUtil.p((j - u) / e, (k - v) / f, (-j - u) / e, (-k - v) / f); if (b.d == 1 && z < 0) { z += 2 * Math.PI; } else if (b.d == 0 && z > 0) { z -= 2 * Math.PI; } return ((() => { let $ret = new ArcCenterInfo(); $ret.c = { $type: Point_$type, x: w, y: x }; $ret.a = y; $ret.b = z; return $ret; })()); } static p(a, b, c, d) { let e = a * c + b * d; let f = Math.sqrt((a * a + b * b)); let g = Math.sqrt((c * c + d * d)); let h = Math.acos(Math.min(Math.max(e / (f * g), -1), 1)); if (a * d - b * c < 0) { return -h; } return h; } static d(a, b, c, d, e) { b = CoreGeometryUtil.t(b); a = CoreGeometryUtil.t(a); let f = d ? (2 * Math.PI - c) : c; let g = CoreGeometryUtil.t(a - b); if (e == 1) { return g <= f; } else { return (2 * Math.PI - g) <= f; } } static v(a, b, c) { let d = CoreGeometryUtil.b(b, c); if (d == null) { return CoreGeometryUtil.z(a, b, c.e); } let e = d.c.x; let f = d.c.y; let g = a.x - e; let h = a.y - f; let i = MathUtil.p(-c.c); let j = Math.cos(i); let k = Math.sin(i); let l = Math.abs(c.f.width); let m = Math.abs(c.f.height); let n = (g * j - h * k) / l; let o = (h * j + g * k) / m; let p = Math.sqrt(n * n + o * o); let q = Math.atan2(o, n); q = CoreGeometryUtil.t(q); let r = d.a; let s = d.a + d.b; r = CoreGeometryUtil.t(r); s = CoreGeometryUtil.t(s); let t = 1 - (o * o); if (t < 0) { return 0; } let u = CoreGeometryUtil.d(q, r, d.b, c.b, c.d); let v = [Math.sqrt(t), -Math.sqrt(t)]; for (let w = 0; w < v.length; w++) { let x = v[w]; let y = x * l; let z = o * m; let aa = j * y - k * z + e; let ab = k * y + j * z + f; if (aa > a.x) { if (CoreGeometryUtil.d(q, r, d.b, c.b, c.d)) { return d.b > 0 ? 1 : -1; } } } return 0; } static t(a) { if (isNaN_(a) || isInfinity(a)) { return a; } while (a > 2 * Math.PI) { a -= 2 * Math.PI; } while (a < 0) { a += 2 * Math.PI; } return a; } static af(a, b, c, d) { let e = CoreGeometryUtil.b(b, c); if (e == null) { if (CoreGeometryUtil.i(a, b, c.e, d)) { return new Tuple$2(Boolean_$type, Point_$type, true, c.e); } else { return new Tuple$2(Boolean_$type, Point_$type, false, c.e); } } let f = e.c.x; let g = e.c.y; let h = a.x - f; let i = a.y - g; let j = MathUtil.p(-c.c); let k = Math.cos(j); let l = Math.sin(j); let m = Math.abs(c.f.width); let n = Math.abs(c.f.height); let o = (h * k - i * l) / m; let p = (i * k + h * l) / n; let q = d; let r = 0; let s = Math.sqrt(q * q + r * r); let t = (q * k - r * l) / m; let u = (r * k + q * l) / n; let v = Math.sqrt(t * t + u * u); let w = Math.sqrt(o * o + p * p); let x = Math.abs(w - 1) < v; let y = Math.atan2(p, o); y = CoreGeometryUtil.t(y); let z = e.a; let aa = e.a + e.b; z = CoreGeometryUtil.t(z); aa = CoreGeometryUtil.t(aa); let ab = CoreGeometryUtil.d(y, z, e.b, c.b, c.d); return new Tuple$2(Boolean_$type, Point_$type, ab && x, c.e); } static ac(a, b, c) { let d = 0; if (typeCast(LineSegment.$, c) !== null) { let e = c; d += CoreGeometryUtil.z(a, b, e.c); } else if (typeCast(PolyBezierSegment.$, c) !== null) { let f = c; d += CoreGeometryUtil.aa(a, b, f); } else if (typeCast(BezierSegment.$, c) !== null) { let g = c; d += CoreGeometryUtil.w(a, b, g); } else if (typeCast(PolyLineSegment.$, c) !== null) { let h = c; d += CoreGeometryUtil.ab(a, b, h); } else if (typeCast(ArcSegment.$, c) !== null) { let i = c; d += CoreGeometryUtil.v(a, b, i); } return d; } static aj(a, b, c, d) { if (typeCast(LineSegment.$, c) !== null) { let e = c; let f = CoreGeometryUtil.i(a, b, e.c, d); return new Tuple$2(Boolean_$type, Point_$type, f, e.c); } else if (typeCast(PolyBezierSegment.$, c) !== null) { let g = c; return CoreGeometryUtil.ah(a, b, g, d); } else if (typeCast(BezierSegment.$, c) !== null) { let h = c; return CoreGeometryUtil.ag(a, b, h, d); } else if (typeCast(PolyLineSegment.$, c) !== null) { let i = c; return CoreGeometryUtil.ai(a, b, i, d); } else if (typeCast(ArcSegment.$, c) !== null) { let j = c; return CoreGeometryUtil.af(a, b, j, d); } return new Tuple$2(Boolean_$type, Point_$type, false, { $type: Point_$type, x: NaN, y: NaN }); } static am(a, b) { if (typeCast(LineSegment.$, b) !== null) { let c = b; return c.c; } else if (typeCast(PolyBezierSegment.$, b) !== null) { let d = b; if (d.b == null || d.b.count == 0) { return a; } return d.b._inner[d.b.count - 1]; } else if (typeCast(BezierSegment.$, b) !== null) { let e = b; return e.g; } else if (typeCast(PolyLineSegment.$, b) !== null) { let f = b; if (f._points == null || f._points.count == 0) { return a; } return f._points._inner[f._points.count - 1]; } else if (typeCast(ArcSegment.$, b) !== null) { let g = b; return g.e; } return a; } static y(a, b) { let c = b._startPoint; if (b._segments == null || b._segments.count == 0) { if (PointUtil.equals(c, a)) { return 1; } } let d = 0; for (let e = 0; e < b._segments.count; e++) { let f = b._segments._inner[e]; d += CoreGeometryUtil.ac(a, c, f); c = CoreGeometryUtil.am(c, f); } return d; } static h(a, b, c) { let d = b._startPoint; if (b._segments == null || b._segments.count == 0) { return CoreGeometryUtil.k(a, d, c); } for (let e = 0; e < b._segments.count; e++) { let f = b._segments._inner[e]; let g = CoreGeometryUtil.aj(a, d, f, c); if (g.c) { return true; } else { d = g.d; } } return false; } static k(a, b, c) { if ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) < c * c) { return true; } return false; } static g(a, b) { if (b == null || b.an == null) { return false; } let c = 0; if (typeCast(PathGeometry.$, b.an) !== null) { let d = b.an; for (let e of fromEnum(d.c)) { c += CoreGeometryUtil.y(a, e); } } else if (typeCast(LineGeometry.$, b.an) !== null) { let f = b.an; c += CoreGeometryUtil.z(a, f.d, f.c); } else if (typeCast(RectangleGeometry.$, b.an) !== null) { let g = b.an; if (g.e.containsPoint(a)) { return true; } } else if (typeCast(EllipseGeometry.$, b.an) !== null) { let h = b.an; return ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c) * (h.c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d) * (h.d)))) <= 1; } return c != 0; } static j(a, b, c) { if (b == null || b.an == null) { return false; } if (typeCast(PathGeometry.$, b.an) !== null) { let d = b.an; for (let e of fromEnum(d.c)) { if (CoreGeometryUtil.h(a, e, c)) { return true; } } } else if (typeCast(LineGeometry.$, b.an) !== null) { let f = b.an; return CoreGeometryUtil.i(a, f.d, f.c, c); } else if (typeCast(RectangleGeometry.$, b.an) !== null) { let g = b.an; return RectUtil.r(g.e, c).containsPoint(a) && !RectUtil.r(g.e, -c).containsPoint(a); } else if (typeCast(EllipseGeometry.$, b.an) !== null) { let h = b.an; return ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c + c) * (h.c + c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d + c) * (h.d + c)))) <= 1 && ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c - c) * (h.c - c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d - c) * (h.d - c)))) >= 1; } return false; } static i(a, b, c, d) { let e = d * d; let f = b.x; let g = b.y; let h = c.x; let i = c.y; let j = a.x; let k = a.y; if (g == i) { let l = Math.abs(g - k) < d; let m = j >= Math.min(f, h) - d && j <= Math.max(f, h) + d; if (l && m) { return true; } else { return false; } } if (f == h) { let n = Math.abs(f - j) < d; let o = k >= Math.min(g, i) - d && k <= Math.max(g, i) + d; if (n && o) { return true; } else { return false; } } let p = h - f; let q = i - g; let r = p * p + q * q; if (r == 0) { return (j - f) * (j - f) + (k - g) * (k - g) < e; } let s = ((j - f) * p + (k - g) * q) / r; s = s < 0 ? 0 : (s > 1 ? 1 : s); let t = f + p * s; let u = g + q * s; let v = (t - j) * (t - j) + (u - k) * (u - k); if (v < e) { return true; } return false; } static l(a, b, c, d) { let e; let f; let g = d * d; let h = c.count; if (h == 0) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) < g; } let i = a.x; let j = a.y; for (let k = 0; k < h; k++) { if (k == 0) { f = c.item(k); e = b; } else { f = c.item(k); e = c.item(k - 1); } let l = e.x; let m = e.y; let n = f.x; let o = f.y; if (m == o) { let p = Math.abs(m - j) < d; let q = i >= Math.min(l, n) - d && i <= Math.max(l, n) + d; if (p && q) { return true; } else { continue; } } if (l == n) { let r = Math.abs(l - i) < d; let s = j >= Math.min(m, o) - d && j <= Math.max(m, o) + d; if (r && s) { return true; } else { continue; } } let t = n - l; let u = o - m; let v = t * t + u * u; if (v == 0) { return (i - l) * (i - l) + (j - m) * (j - m) < g; } let w = ((i - l) * t + (j - m) * u) / v; w = w < 0 ? 0 : (w > 1 ? 1 : w); let x = l + t * w; let y = m + u * w; let z = (x - i) * (x - i) + (y - j) * (y - j); if (z < g) { return true; } } return false; } static r(a) { if (isNaN_(a) || isInfinity(a)) { return a; } while (a > 360) { a -= 360; } while (a < 0) { a += 360; } return a; } static s(a) { if (isNaN_(a) || isInfinity(a)) { return a; } while (a > Math.PI * 2) { a -= Math.PI * 2; } while (a < 0) { a += Math.PI * 2; } return a; } static al(a, b, c, d, e) { let f = { $type: Point_$type, x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }; let g = b.x - a.x; let h = b.y - a.y; let i = Math.sqrt(g * g + h * h); let j = h; let k = g * -1; if (e == d) { j = h * -1; k = g; } let l = Math.max(Math.abs(j), Math.abs(k)); j = j / l; k = k / l; let m = Math.sqrt(j * j + k * k); let n = j / m; let o = k / m; let p = i / 2; let q = Math.sqrt(c * c - p * p); if (isNaN_(q)) { q = 0; } let r = q * n; let s = q * o; let t = { $type: Point_$type, x: f.x + r, y: f.y + s }; return t; } } CoreGeometryUtil.$t = markType(CoreGeometryUtil, 'CoreGeometryUtil'); CoreGeometryUtil.u = 100; return CoreGeometryUtil; })(); /** * @hidden */ export let RectUtil = /*@__PURE__*/ (() => { class RectUtil extends Base { static l(a) { if (a.isEmpty) { return { $type: Point_$type, x: NaN, y: NaN }; } return { $type: Point_$type, x: 0.5 * (a.left + a.right), y: 0.5 * (a.bottom + a.top) }; } static e(a) { if (a.isEmpty) { return 0; } return a.width * a.height; } static p(a) { if (a.isEmpty) { return a; } return new Rect(0, a.left, a.top, a.width, a.height); } static m(a, b) { if (a.containsPoint(b)) { return b; } let c = { $type: Point_$type, x: a.left + 0.5 * a.width, y: a.top + 0.5 * a.height }; let d = { $type: Point_$type, x: b.x - c.x, y: b.y - c.y }; let e; if (d.x != 0) { e = (a.left - c.x) / d.x; let f = c.y + e * d.y; if (f > a.top && f < a.bottom) { return e > 0 ? { $type: Point_$type, x: a.left, y: f } : { $type: Point_$type, x: a.right, y: c.y - e * d.y }; } } e = (a.top - c.y) / d.y; let g = c.x + e * d.x; return e > 0 ? { $type: Point_$type, x: g, y: a.top } : { $type: Point_$type, x: c.x - e * d.x, y: a.bottom }; } static g(a, b) { if (a.isEmpty) { return NaN; } return RectUtil.f(a, b.x, b.y); } static h(a, b) { if (a.isEmpty) { return Number.POSITIVE_INFINITY; } let c = RectUtil.f(a, b.left, b.top); if (c > 0) { c = Math.min(c, RectUtil.f(a, b.left, b.bottom)); } if (c > 0) { c = Math.min(c, RectUtil.f(a, b.right, b.bottom)); } if (c > 0) { c = Math.min(c, RectUtil.f(a, b.right, b.top)); } if (c > 0) { c = Math.min(c, RectUtil.f(b, a.left, a.top)); } if (c > 0) { c = Math.min(c, RectUtil.f(b, a.left, a.bottom)); } if (c > 0) { c = Math.min(c, RectUtil.f(b, a.right, a.bottom)); } if (c > 0) { c = Math.min(c, RectUtil.f(b, a.right, a.top)); } return c; } static f(a, b, c) { let d = b - a.left; let e = c - a.top; let f = a.width * d; let g = a.height * e; if (f > 0) { let h = a.width * a.width; if (f < h) { d -= (f / h) * a.width; } else { d -= a.width; } } if (g > 0) { let i = a.height * a.height; if (g < i) { e -= (g / i) * a.height; } else { e -= a.height; } } return d * d + e * e; } static a(a, b) { if (a.isEmpty || b.isEmpty) { return false; } if (a.left > b.left) { return false; } if (a.right < b.right) { return false; } if (a.top > b.top) { return false; } if (a.bottom < b.bottom) { return false; } return true; } static b(a, b) { if (a.isEmpty || b.isEmpty) { return false; } if (a.right < b.left) { return false; } if (a.left > b.right) { return false; } if (a.top > b.bottom) { return false; } if (a.bottom < b.top) { return false; } return true; } static i(a, b) { if (a.isEmpty || b.isEmpty) { return 0; } let c = Math.min(a.right, b.right) - Math.max(a.left, b.left); if (c <= 0) { return 0; } let d = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top); if (d <= 0) { return 0; } return c * d; } static q(a, b, c) { if (a.isEmpty) { return a; } return new Rect(0, a.x - b, a.y - c, Math.max(0, a.width + 2 * b), Math.max(0, a.height + 2 * c)); } static t(a, b, c) { a.x = a.x - b; a.y = a.y - c; let d = a.width + 2 * b; let e = a.height + 2 * c; a.width = d > 1 ? d : 1; a.height = e > 1 ? e : 1; return a; } static s(a, b, c) { a.x = a.x - b; a.y = a.y - c; let d = a.width + 2 * b; let e = a.height + 2 * c; a.width = d > 1 ? d : 1; a.height = e > 1 ? e : 1; return a; } static r(a, b) { let c = a.x - b; let d = a.y - b; let e = a.width + b + b; let f = a.height + b + b; let g = e > 0 ? e : 0; let h = f > 0 ? f : 0; return new Rect(0, c, d, g, h); } static y(a) { a.x = Math.round(a.x); a.y = Math.round(a.y); a.width = Math.round(a.width); a.height = Math.round(a.height); return a; } static c(a) { return a.x == 0 && a.y == 0 && a.width == 0 && a.height == 0; } static z(a) { let b = new Size(1, a.width, a.height); return b; } static u(a, b) { let c = RectUtil.v(a, RectUtil.z(b)); return c; } static v(a, b) { let c = a; c.x = a.x / b.width; c.y = a.y / b.height; c.width = a.width / b.width; c.height = a.height / b.height; return c; } static n(a) { let b = { $type: Point_$type, x: a.x, y: a.y }; return b; } static o(a) { let b = { $type: Point_$type, x: a.x + a.width, y: a.y }; return b; } static j(a) { let b = { $type: Point_$type, x: a.x, y: a.y + a.height }; return b; } static k(a) { let b = { $type: Point_$type, x: a.x + a.width, y: a.y + a.height }; return b; } static d(a) { let b = ((() => { let $ret = new List$1(Point_$type, 0); $ret.add(RectUtil.n(a)); $ret.add(RectUtil.o(a)); $ret.add(RectUtil.k(a)); $ret.add(RectUtil.j(a)); return $ret; })()); return b; } static w(a, b) { b = CoreGeometryUtil.r(b); if (b == 0 || b == 180) { return new Rect(0, a.left, a.top, a.width, a.height); } let c = RectUtil.l(a); if (b == 90 || b == 270) { let d = a.height / 2; let e = a.width / 2; return new Rect(0, c.x - d, c.y - e, a.height, a.width); } return RectUtil.x(a, c.x, c.y, b); } static x(a, b, c, d) { let e = RectUtil.d(a); let f = MathUtil.p(d); let g = Math.cos(f); let h = Math.sin(f); let i = 1.7976931348623157E+308; let j = 1.7976931348623157E+308; let k = -1.7976931348623157E+308; let l = -1.7976931348623157E+308; let m; for (let n = 0; n < e.count; n++) { m = e._inner[n]; let o = (g * (m.x - b) - h * (m.y - c) + b); let p = (h * (m.x - b) + g * (m.y - c) + c); i = Math.min(i, p); j = Math.min(j, o); k = Math.max(k, o); l = Math.max(l, p); } let q = new Rect(0, j, i, k - j, l - i); return q; } } RectUtil.$t = markType(RectUtil, 'RectUtil'); return RectUtil; })();