UNPKG

@core-graphics/rect

Version:
200 lines (153 loc) 6.6 kB
import { _ as _defineProperty, a as _classCallCheck, R as Rect$1 } from './lite-3fdd983e.esm.js'; import { alignHorizontal, alignVertical, align } from '../align/dist/core-graphics-rect-align.esm.js'; import { containsPoint, containsRect, contains } from '../contains/dist/core-graphics-rect-contains.esm.js'; import { distanceFromPoint, distanceFromRect } from '../distance/dist/core-graphics-rect-distance.esm.js'; import { intersection, collisions, intersects } from '../intersection/dist/core-graphics-rect-intersection.esm.js'; import { egdeInset, inset, shift } from '../operations/dist/core-graphics-rect-operations.esm.js'; import { f as fromElement, a as fromWindow, b as fromRange, u as union } from './from-window-e2a75bcf.esm.js'; import { f as fromPoints } from './from-points-e5b0935a.esm.js'; import '@core-graphics/point'; import '@core-graphics/size'; import './createForOfIteratorHelper-20bcc2b4.esm.js'; import './unsupportedIterableToArray-9785118b.esm.js'; function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } /** * A structure that contains the location and dimensions of a rectangle. */ var Rect = /*#__PURE__*/function (_RectLite) { _inherits(Rect, _RectLite); var _super = _createSuper(Rect); function Rect() { var _this; _classCallCheck(this, Rect); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "egdeInset", function (inset) { return _this.set(egdeInset(_assertThisInitialized(_this), inset)); }); _defineProperty(_assertThisInitialized(_this), "inset", function (value) { return _this.set(inset(_assertThisInitialized(_this), value)); }); _defineProperty(_assertThisInitialized(_this), "shift", function (offset) { return _this.set(shift(_assertThisInitialized(_this), offset)); }); _defineProperty(_assertThisInitialized(_this), "containsPoint", function (point) { return containsPoint(_assertThisInitialized(_this), point); }); _defineProperty(_assertThisInitialized(_this), "containsRect", function (rectOrValue) { return containsRect(_assertThisInitialized(_this), rectOrValue); }); _defineProperty(_assertThisInitialized(_this), "contains", function (pointOrRect) { return contains(_assertThisInitialized(_this), pointOrRect); }); _defineProperty(_assertThisInitialized(_this), "intersection", function (rect) { return _this.set(intersection(_assertThisInitialized(_this), rect)); }); _defineProperty(_assertThisInitialized(_this), "intersects", function (rect) { return intersects(_assertThisInitialized(_this), rect); }); _defineProperty(_assertThisInitialized(_this), "distanceFromPoint", function (point) { return distanceFromPoint(_assertThisInitialized(_this), point); }); _defineProperty(_assertThisInitialized(_this), "distanceFromRect", function (rectOrValue) { return distanceFromRect(_assertThisInitialized(_this), rectOrValue); }); _defineProperty(_assertThisInitialized(_this), "horizontalAlignTo", function (rect, align) { return _this.set(alignHorizontal(_assertThisInitialized(_this), rect, align)); }); _defineProperty(_assertThisInitialized(_this), "verticalAlignTo", function (rect, align) { return _this.set(alignVertical(_assertThisInitialized(_this), rect, align)); }); _defineProperty(_assertThisInitialized(_this), "alignTo", function (rect, opts) { return _this.set(align(_assertThisInitialized(_this), rect, opts)); }); return _this; } return Rect; }(Rect$1); _defineProperty(Rect, "fromPoints", function () { return new Rect(fromPoints.apply(void 0, arguments)); }); _defineProperty(Rect, "create", function (rect) { return new Rect(rect); }); _defineProperty(Rect, "fromElement", function (el) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return new Rect(fromElement(el, opts)); }); _defineProperty(Rect, "fromWindow", function (win) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return new Rect(fromWindow(win, opts)); }); _defineProperty(Rect, "fromRange", function (range) { return new Rect(fromRange(range)); }); _defineProperty(Rect, "intersection", intersection); _defineProperty(Rect, "collisions", collisions); _defineProperty(Rect, "union", union); _defineProperty(Rect, "intersects", intersects); export { Rect };