UNPKG

@core-graphics/rect

Version:
36 lines (33 loc) 1.29 kB
export { f as fromElement, b as fromRange, a as fromWindow, g as getElementRect, c as getWindowRect } from '../../dist/from-window-e2a75bcf.esm.js'; import { _ as _toConsumableArray } from '../../dist/from-points-e5b0935a.esm.js'; export { f as fromPoints } from '../../dist/from-points-e5b0935a.esm.js'; import { R as Rect } from '../../dist/lite-3fdd983e.esm.js'; import '../../dist/createForOfIteratorHelper-20bcc2b4.esm.js'; import '../../dist/unsupportedIterableToArray-9785118b.esm.js'; import '@core-graphics/point'; import '@core-graphics/size'; function fromRotation(r, deg) { var rect = Rect.cast(r); var rotatedRect = rect.cornerPoints.map(function (p) { return p.rotate(deg, rect.centerPoint).value; }); var minX = Math.min.apply(Math, _toConsumableArray(rotatedRect.map(function (p) { return p.x; }))); var minY = Math.min.apply(Math, _toConsumableArray(rotatedRect.map(function (p) { return p.y; }))); var maxX = Math.max.apply(Math, _toConsumableArray(rotatedRect.map(function (p) { return p.x; }))); var maxY = Math.max.apply(Math, _toConsumableArray(rotatedRect.map(function (p) { return p.y; }))); return new Rect({ x: minX, y: minY, width: maxX - minX, height: maxY - minY }); } export { fromRotation };