qauMaWeb/node_modules/.cache/babel-loader/bf4aaf81166a2cdac6062bd5978...

1 line
22 KiB
JSON
Raw Normal View History

2024-10-13 18:02:27 +08:00
{"ast":null,"code":"import * as matrix from './matrix.js';\nimport Point from './Point.js';\nvar mathMin = Math.min;\nvar mathMax = Math.max;\nvar lt = new Point();\nvar rb = new Point();\nvar lb = new Point();\nvar rt = new Point();\nvar minTv = new Point();\nvar maxTv = new Point();\n\nvar BoundingRect = function () {\n function BoundingRect(x, y, width, height) {\n if (width < 0) {\n x = x + width;\n width = -width;\n }\n\n if (height < 0) {\n y = y + height;\n height = -height;\n }\n\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n }\n\n BoundingRect.prototype.union = function (other) {\n var x = mathMin(other.x, this.x);\n var y = mathMin(other.y, this.y);\n\n if (isFinite(this.x) && isFinite(this.width)) {\n this.width = mathMax(other.x + other.width, this.x + this.width) - x;\n } else {\n this.width = other.width;\n }\n\n if (isFinite(this.y) && isFinite(this.height)) {\n this.height = mathMax(other.y + other.height, this.y + this.height) - y;\n } else {\n this.height = other.height;\n }\n\n this.x = x;\n this.y = y;\n };\n\n BoundingRect.prototype.applyTransform = function (m) {\n BoundingRect.applyTransform(this, this, m);\n };\n\n BoundingRect.prototype.calculateTransform = function (b) {\n var a = this;\n var sx = b.width / a.width;\n var sy = b.height / a.height;\n var m = matrix.create();\n matrix.translate(m, m, [-a.x, -a.y]);\n matrix.scale(m, m, [sx, sy]);\n matrix.translate(m, m, [b.x, b.y]);\n return m;\n };\n\n BoundingRect.prototype.intersect = function (b, mtv) {\n if (!b) {\n return false;\n }\n\n if (!(b instanceof BoundingRect)) {\n b = BoundingRect.create(b);\n }\n\n var a = this;\n var ax0 = a.x;\n var ax1 = a.x + a.width;\n var ay0 = a.y;\n var ay1 = a.y + a.height;\n var bx0 = b.x;\n var bx1 = b.x + b.width;\n var by0 = b.y;\n var by1 = b.y + b.height;\n var overlap = !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);\n\n if (mtv) {\n var dMin = Infinity;\n var dMax = 0;\n var d0 = Math.abs(ax1 - bx0);\n var d1 = Math.abs(bx1 - ax0);\n var d2 = Math.abs(ay1 - by0);\n var d3 = Math.abs(by1 - ay0);\n var dx = Math.min(d0, d1);\n var dy = Math.min(d2, d3);\n\n if (ax1 < bx0 || bx1 < ax0) {\n if (dx > dMax) {\n dMax = dx;\n\n if (d0 < d1) {\n Point.set(maxTv, -d0, 0);\n } else {\n Point.set(maxTv, d1, 0);\n }\n }\n } else {\n if (dx < dMin) {\n dMin = dx;\n\n if (d0 < d1) {\n Point.set(minTv, d0, 0);\n } else {\n Point.set(minTv, -d1, 0);\n }\n }\n }\n\n if (ay1 < by0 || by1 < ay0) {\n if (dy > dMax) {\n dMax = dy;\n\n if (d2 < d3) {\n Point.set(maxTv, 0, -d2);\n } else {\n Point.set(maxTv, 0, d3);\n }\n }\n } else {\n if (dx < dMin) {\n dMin = dx;\n\n if (d2 < d3) {\n Point.set(minTv, 0, d2);\n } else {\n Point.set(minTv, 0, -d3);\n }\n }\n }\n }\n\n if (mtv) {\n Point.copy(mtv, overlap ? minTv : maxTv);\n }\n\n return overlap;\n };\n\n BoundingRect.prototype.contain = function (x, y) {\n var rect = this;\n return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;\n };\n\n BoundingRect.prototype.clone = function () {\n return new BoundingRect(this.x, this.y, this.width, this.height);\n };\n\n BoundingRect.prototype.copy = function (other) {\n BoundingRect.copy(this, other);\n };\n\n BoundingRect.prototype.plain = function () {\n return {\n x: this.x,\n y: this.y,\n width: this.width,\n height: this.height\n };\n };\n\n BoundingRect.prototype.isFinite = function () {\n return isFinite(this.x) && isFinite(this.y) && isFinite(this.width)