@sprawlify/primitives 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anatomy.cjs +3 -0
- package/dist/anatomy.d.cts +2 -0
- package/dist/anatomy.d.mts +2 -0
- package/dist/anatomy.mjs +3 -0
- package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
- package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
- package/dist/aria-hidden.cjs +4 -0
- package/dist/aria-hidden.d.cts +16 -0
- package/dist/aria-hidden.d.mts +16 -0
- package/dist/aria-hidden.mjs +4 -0
- package/dist/auto-resize-D3qHtFy1.mjs +114 -0
- package/dist/auto-resize-xzlPFDyD.cjs +125 -0
- package/dist/auto-resize.cjs +5 -0
- package/dist/auto-resize.d.cts +17 -0
- package/dist/auto-resize.d.mts +17 -0
- package/dist/auto-resize.mjs +4 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/collection-8XqaNHs_.mjs +1279 -0
- package/dist/collection-DIoIDISa.cjs +1326 -0
- package/dist/collection.cjs +11 -0
- package/dist/collection.d.cts +5 -0
- package/dist/collection.d.mts +5 -0
- package/dist/collection.mjs +4 -0
- package/dist/color-BkAP1Tkd.d.mts +60 -0
- package/dist/color-VKewNv2e.d.cts +60 -0
- package/dist/color-utils-Cc5GVXZh.mjs +657 -0
- package/dist/color-utils-LER_6Zwu.cjs +680 -0
- package/dist/color-utils.cjs +7 -0
- package/dist/color-utils.d.cts +19 -0
- package/dist/color-utils.d.mts +19 -0
- package/dist/color-utils.mjs +4 -0
- package/dist/core-30pJjyC2.d.mts +49 -0
- package/dist/core-CQFbMdTl.cjs +176 -0
- package/dist/core-CefBjbst.d.cts +49 -0
- package/dist/core-DCFNMTZF.mjs +129 -0
- package/dist/core.cjs +12 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.mts +3 -0
- package/dist/core.mjs +5 -0
- package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
- package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
- package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
- package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
- package/dist/create-props-BnF_vl-E.mjs +5 -0
- package/dist/create-props-YKy7JIKj.cjs +11 -0
- package/dist/data-url-C3ITPVRX.d.cts +10 -0
- package/dist/data-url-DLwZ9M77.d.mts +10 -0
- package/dist/date-utils-D2xPHa_I.cjs +738 -0
- package/dist/date-utils-wEa1hhpc.mjs +474 -0
- package/dist/date-utils.cjs +46 -0
- package/dist/date-utils.d.cts +101 -0
- package/dist/date-utils.d.mts +2 -0
- package/dist/date-utils.mjs +3 -0
- package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
- package/dist/defineProperty-DrXfyjd4.mjs +43 -0
- package/dist/dismissable-CTfKZ4OG.cjs +282 -0
- package/dist/dismissable-DDrx0xnH.mjs +271 -0
- package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
- package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
- package/dist/dismissable.cjs +7 -0
- package/dist/dismissable.d.cts +3 -0
- package/dist/dismissable.d.mts +3 -0
- package/dist/dismissable.mjs +6 -0
- package/dist/dom-query-CWZdWUGp.cjs +2141 -0
- package/dist/dom-query-DFCRhyj1.mjs +1374 -0
- package/dist/dom-query.cjs +130 -0
- package/dist/dom-query.d.cts +307 -0
- package/dist/dom-query.d.mts +307 -0
- package/dist/dom-query.mjs +3 -0
- package/dist/file-utils.cjs +220 -0
- package/dist/file-utils.d.cts +51 -0
- package/dist/file-utils.d.mts +51 -0
- package/dist/file-utils.mjs +210 -0
- package/dist/focus-trap-D-bypQEJ.mjs +485 -0
- package/dist/focus-trap-D4i52S9A.cjs +496 -0
- package/dist/focus-trap.cjs +5 -0
- package/dist/focus-trap.d.cts +88 -0
- package/dist/focus-trap.d.mts +88 -0
- package/dist/focus-trap.mjs +4 -0
- package/dist/focus-visible-DYTWdWpa.cjs +210 -0
- package/dist/focus-visible-irppYatv.mjs +175 -0
- package/dist/focus-visible.cjs +9 -0
- package/dist/focus-visible.d.cts +31 -0
- package/dist/focus-visible.d.mts +31 -0
- package/dist/focus-visible.mjs +4 -0
- package/dist/functions-BOkTDEFM.d.cts +15 -0
- package/dist/functions-IZtWcC8Q.d.mts +15 -0
- package/dist/highlight-word.cjs +100 -0
- package/dist/highlight-word.d.cts +24 -0
- package/dist/highlight-word.d.mts +24 -0
- package/dist/highlight-word.mjs +99 -0
- package/dist/hotkeys.cjs +758 -0
- package/dist/hotkeys.d.cts +130 -0
- package/dist/hotkeys.d.mts +130 -0
- package/dist/hotkeys.mjs +754 -0
- package/dist/i18n-utils.cjs +450 -0
- package/dist/i18n-utils.d.cts +61 -0
- package/dist/i18n-utils.d.mts +61 -0
- package/dist/i18n-utils.mjs +440 -0
- package/dist/index-BkzYij2j.d.mts +25 -0
- package/dist/index-Bqw3r34-.d.cts +1383 -0
- package/dist/index-C0MKXQmE.d.mts +1383 -0
- package/dist/index-C9-feK5c.d.cts +25 -0
- package/dist/index-CD5FN7kY.d.mts +114 -0
- package/dist/index-CJji6wHl.d.cts +15 -0
- package/dist/index-CNi5FkPe.d.mts +15 -0
- package/dist/index-D96rs8B0.d.mts +115 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/interact-outside-BplxR9cR.mjs +200 -0
- package/dist/interact-outside-C8-oFBpB.cjs +205 -0
- package/dist/interact-outside.cjs +5 -0
- package/dist/interact-outside.d.cts +2 -0
- package/dist/interact-outside.d.mts +2 -0
- package/dist/interact-outside.mjs +5 -0
- package/dist/json-tree-utils.cjs +1512 -0
- package/dist/json-tree-utils.d.cts +117 -0
- package/dist/json-tree-utils.d.mts +117 -0
- package/dist/json-tree-utils.mjs +1463 -0
- package/dist/list-collection-BIMJGQjn.d.cts +61 -0
- package/dist/list-collection-Db3eixRU.d.mts +61 -0
- package/dist/live-region-CcZPGo89.cjs +52 -0
- package/dist/live-region-CnPh21WH.mjs +46 -0
- package/dist/live-region.cjs +3 -0
- package/dist/live-region.d.cts +2 -0
- package/dist/live-region.d.mts +2 -0
- package/dist/live-region.mjs +3 -0
- package/dist/machines/accordion/index.cjs +328 -0
- package/dist/machines/accordion/index.d.cts +83 -0
- package/dist/machines/accordion/index.d.mts +83 -0
- package/dist/machines/accordion/index.mjs +322 -0
- package/dist/machines/async-list/index.cjs +311 -0
- package/dist/machines/async-list/index.d.cts +89 -0
- package/dist/machines/async-list/index.d.mts +89 -0
- package/dist/machines/async-list/index.mjs +310 -0
- package/dist/machines/avatar/index.cjs +169 -0
- package/dist/machines/avatar/index.d.cts +63 -0
- package/dist/machines/avatar/index.d.mts +63 -0
- package/dist/machines/avatar/index.mjs +165 -0
- package/dist/machines/bottom-sheet/index.cjs +676 -0
- package/dist/machines/bottom-sheet/index.d.cts +239 -0
- package/dist/machines/bottom-sheet/index.d.mts +239 -0
- package/dist/machines/bottom-sheet/index.mjs +672 -0
- package/dist/machines/carousel/index.cjs +859 -0
- package/dist/machines/carousel/index.d.cts +146 -0
- package/dist/machines/carousel/index.d.mts +146 -0
- package/dist/machines/carousel/index.mjs +851 -0
- package/dist/machines/checkbox/index.cjs +316 -0
- package/dist/machines/checkbox/index.d.cts +81 -0
- package/dist/machines/checkbox/index.d.mts +81 -0
- package/dist/machines/checkbox/index.mjs +312 -0
- package/dist/machines/clipboard/index.cjs +225 -0
- package/dist/machines/clipboard/index.d.cts +68 -0
- package/dist/machines/clipboard/index.d.mts +68 -0
- package/dist/machines/clipboard/index.mjs +219 -0
- package/dist/machines/collapsible/index.cjs +362 -0
- package/dist/machines/collapsible/index.d.cts +82 -0
- package/dist/machines/collapsible/index.d.mts +82 -0
- package/dist/machines/collapsible/index.mjs +358 -0
- package/dist/machines/color-picker/index.cjs +1529 -0
- package/dist/machines/color-picker/index.d.cts +205 -0
- package/dist/machines/color-picker/index.d.mts +205 -0
- package/dist/machines/color-picker/index.mjs +1514 -0
- package/dist/machines/combobox/index.cjs +1593 -0
- package/dist/machines/combobox/index.d.cts +214 -0
- package/dist/machines/combobox/index.d.mts +214 -0
- package/dist/machines/combobox/index.mjs +1582 -0
- package/dist/machines/date-picker/index.cjs +2177 -0
- package/dist/machines/date-picker/index.d.cts +350 -0
- package/dist/machines/date-picker/index.d.mts +350 -0
- package/dist/machines/date-picker/index.mjs +2161 -0
- package/dist/machines/dialog/index.cjs +325 -0
- package/dist/machines/dialog/index.d.cts +80 -0
- package/dist/machines/dialog/index.d.mts +80 -0
- package/dist/machines/dialog/index.mjs +321 -0
- package/dist/machines/editable/index.cjs +551 -0
- package/dist/machines/editable/index.d.cts +114 -0
- package/dist/machines/editable/index.d.mts +114 -0
- package/dist/machines/editable/index.mjs +547 -0
- package/dist/machines/floating-panel/index.cjs +995 -0
- package/dist/machines/floating-panel/index.d.cts +147 -0
- package/dist/machines/floating-panel/index.d.mts +147 -0
- package/dist/machines/floating-panel/index.mjs +988 -0
- package/dist/machines/hover-card/index.cjs +383 -0
- package/dist/machines/hover-card/index.d.cts +69 -0
- package/dist/machines/hover-card/index.d.mts +69 -0
- package/dist/machines/hover-card/index.mjs +379 -0
- package/dist/machines/image-cropper/index.cjs +1995 -0
- package/dist/machines/image-cropper/index.d.cts +182 -0
- package/dist/machines/image-cropper/index.d.mts +182 -0
- package/dist/machines/image-cropper/index.mjs +1990 -0
- package/dist/machines/listbox/index.cjs +794 -0
- package/dist/machines/listbox/index.d.cts +168 -0
- package/dist/machines/listbox/index.d.mts +168 -0
- package/dist/machines/listbox/index.mjs +782 -0
- package/dist/machines/marquee/index.cjs +395 -0
- package/dist/machines/marquee/index.d.cts +102 -0
- package/dist/machines/marquee/index.d.mts +102 -0
- package/dist/machines/marquee/index.mjs +391 -0
- package/dist/machines/menu/index.cjs +1298 -0
- package/dist/machines/menu/index.d.cts +175 -0
- package/dist/machines/menu/index.d.mts +175 -0
- package/dist/machines/menu/index.mjs +1286 -0
- package/dist/machines/navigation-menu/index.cjs +861 -0
- package/dist/machines/navigation-menu/index.d.cts +127 -0
- package/dist/machines/navigation-menu/index.d.mts +127 -0
- package/dist/machines/navigation-menu/index.mjs +857 -0
- package/dist/machines/number-input/index.cjs +996 -0
- package/dist/machines/number-input/index.d.cts +134 -0
- package/dist/machines/number-input/index.d.mts +134 -0
- package/dist/machines/number-input/index.mjs +991 -0
- package/dist/machines/pagination/index.cjs +419 -0
- package/dist/machines/pagination/index.d.cts +139 -0
- package/dist/machines/pagination/index.d.mts +139 -0
- package/dist/machines/pagination/index.mjs +411 -0
- package/dist/machines/password-input/index.cjs +228 -0
- package/dist/machines/password-input/index.d.cts +71 -0
- package/dist/machines/password-input/index.d.mts +71 -0
- package/dist/machines/password-input/index.mjs +224 -0
- package/dist/machines/pin-input/index.cjs +523 -0
- package/dist/machines/pin-input/index.d.cts +105 -0
- package/dist/machines/pin-input/index.d.mts +105 -0
- package/dist/machines/pin-input/index.mjs +519 -0
- package/dist/machines/popover/index.cjs +430 -0
- package/dist/machines/popover/index.d.cts +88 -0
- package/dist/machines/popover/index.d.mts +88 -0
- package/dist/machines/popover/index.mjs +426 -0
- package/dist/machines/presence/index.cjs +192 -0
- package/dist/machines/presence/index.d.cts +44 -0
- package/dist/machines/presence/index.d.mts +44 -0
- package/dist/machines/presence/index.mjs +190 -0
- package/dist/machines/progress/index.cjs +288 -0
- package/dist/machines/progress/index.d.cts +96 -0
- package/dist/machines/progress/index.d.mts +96 -0
- package/dist/machines/progress/index.mjs +284 -0
- package/dist/machines/qr-code/index.cjs +172 -0
- package/dist/machines/qr-code/index.d.cts +70 -0
- package/dist/machines/qr-code/index.d.mts +70 -0
- package/dist/machines/qr-code/index.mjs +167 -0
- package/dist/machines/radio-group/index.cjs +436 -0
- package/dist/machines/radio-group/index.d.cts +106 -0
- package/dist/machines/radio-group/index.d.mts +106 -0
- package/dist/machines/radio-group/index.mjs +430 -0
- package/dist/machines/rating-group/index.cjs +405 -0
- package/dist/machines/rating-group/index.d.cts +101 -0
- package/dist/machines/rating-group/index.d.mts +101 -0
- package/dist/machines/rating-group/index.mjs +399 -0
- package/dist/machines/scroll-area/index.cjs +857 -0
- package/dist/machines/scroll-area/index.d.cts +159 -0
- package/dist/machines/scroll-area/index.d.mts +159 -0
- package/dist/machines/scroll-area/index.mjs +853 -0
- package/dist/machines/select/index.cjs +1165 -0
- package/dist/machines/select/index.d.cts +183 -0
- package/dist/machines/select/index.d.mts +183 -0
- package/dist/machines/select/index.mjs +1154 -0
- package/dist/machines/signature-pad/index.cjs +334 -0
- package/dist/machines/signature-pad/index.d.cts +108 -0
- package/dist/machines/signature-pad/index.d.mts +108 -0
- package/dist/machines/signature-pad/index.mjs +328 -0
- package/dist/machines/slider/index.cjs +957 -0
- package/dist/machines/slider/index.d.cts +149 -0
- package/dist/machines/slider/index.d.mts +149 -0
- package/dist/machines/slider/index.mjs +949 -0
- package/dist/machines/splitter/index.cjs +1112 -0
- package/dist/machines/splitter/index.d.cts +155 -0
- package/dist/machines/splitter/index.d.mts +155 -0
- package/dist/machines/splitter/index.mjs +1103 -0
- package/dist/machines/steps/index.cjs +289 -0
- package/dist/machines/steps/index.d.cts +97 -0
- package/dist/machines/steps/index.d.mts +97 -0
- package/dist/machines/steps/index.mjs +285 -0
- package/dist/machines/switch/index.cjs +305 -0
- package/dist/machines/switch/index.d.cts +80 -0
- package/dist/machines/switch/index.d.mts +80 -0
- package/dist/machines/switch/index.mjs +301 -0
- package/dist/machines/tabs/index.cjs +508 -0
- package/dist/machines/tabs/index.d.cts +111 -0
- package/dist/machines/tabs/index.d.mts +111 -0
- package/dist/machines/tabs/index.mjs +500 -0
- package/dist/machines/tags-input/index.cjs +1127 -0
- package/dist/machines/tags-input/index.d.cts +179 -0
- package/dist/machines/tags-input/index.d.mts +179 -0
- package/dist/machines/tags-input/index.mjs +1121 -0
- package/dist/machines/timer/index.cjs +329 -0
- package/dist/machines/timer/index.d.cts +98 -0
- package/dist/machines/timer/index.d.mts +98 -0
- package/dist/machines/timer/index.mjs +324 -0
- package/dist/machines/toast/index.cjs +1155 -0
- package/dist/machines/toast/index.d.cts +195 -0
- package/dist/machines/toast/index.d.mts +195 -0
- package/dist/machines/toast/index.mjs +1151 -0
- package/dist/machines/toggle/index.cjs +103 -0
- package/dist/machines/toggle/index.d.cts +46 -0
- package/dist/machines/toggle/index.d.mts +46 -0
- package/dist/machines/toggle/index.mjs +99 -0
- package/dist/machines/toggle-group/index.cjs +328 -0
- package/dist/machines/toggle-group/index.d.cts +81 -0
- package/dist/machines/toggle-group/index.d.mts +81 -0
- package/dist/machines/toggle-group/index.mjs +322 -0
- package/dist/machines/tooltip/index.cjs +516 -0
- package/dist/machines/tooltip/index.d.cts +71 -0
- package/dist/machines/tooltip/index.d.mts +71 -0
- package/dist/machines/tooltip/index.mjs +512 -0
- package/dist/machines/tour/index.cjs +1108 -0
- package/dist/machines/tour/index.d.cts +206 -0
- package/dist/machines/tour/index.d.mts +206 -0
- package/dist/machines/tour/index.mjs +1101 -0
- package/dist/machines/tree-view/index.cjs +1271 -0
- package/dist/machines/tree-view/index.d.cts +215 -0
- package/dist/machines/tree-view/index.d.mts +215 -0
- package/dist/machines/tree-view/index.mjs +1263 -0
- package/dist/node-BctU8GXk.d.mts +24 -0
- package/dist/node-CSsuPZVZ.d.cts +24 -0
- package/dist/popper-BPJeAtcA.mjs +349 -0
- package/dist/popper-D0FAW_p7.cjs +373 -0
- package/dist/popper.cjs +8 -0
- package/dist/popper.d.cts +74 -0
- package/dist/popper.d.mts +2 -0
- package/dist/popper.mjs +5 -0
- package/dist/raf-BnlYUlDi.d.mts +15 -0
- package/dist/raf-Cd2FGy0z.d.cts +15 -0
- package/dist/rect-utils-0ellN0a_.mjs +854 -0
- package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
- package/dist/rect-utils.cjs +51 -0
- package/dist/rect-utils.d.cts +198 -0
- package/dist/rect-utils.d.mts +198 -0
- package/dist/rect-utils.mjs +3 -0
- package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
- package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
- package/dist/remove-scroll.cjs +0 -0
- package/dist/remove-scroll.d.cts +1 -0
- package/dist/remove-scroll.d.mts +1 -0
- package/dist/remove-scroll.mjs +1 -0
- package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
- package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
- package/dist/scroll-snap.cjs +7 -0
- package/dist/scroll-snap.d.cts +14 -0
- package/dist/scroll-snap.d.mts +14 -0
- package/dist/scroll-snap.mjs +4 -0
- package/dist/selection-BIhSzkF7.d.mts +50 -0
- package/dist/selection-CS1GBp8e.d.cts +50 -0
- package/dist/store-BZcXv49B.cjs +305 -0
- package/dist/store-DEojWy9H.mjs +263 -0
- package/dist/store.cjs +9 -0
- package/dist/store.d.cts +26 -0
- package/dist/store.d.mts +26 -0
- package/dist/store.mjs +3 -0
- package/dist/stringify-state.cjs +49 -0
- package/dist/stringify-state.d.cts +8 -0
- package/dist/stringify-state.d.mts +8 -0
- package/dist/stringify-state.mjs +46 -0
- package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
- package/dist/tree-collection-DP_eznnI.d.cts +78 -0
- package/dist/typeahead-BdNwVP09.d.cts +45 -0
- package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
- package/dist/types-BivBkYg9.d.cts +57 -0
- package/dist/types-Bl_6JtPQ.d.mts +57 -0
- package/dist/types-CPUMVt7c.d.mts +54 -0
- package/dist/types-CT_W6HWr.d.cts +54 -0
- package/dist/types-DDTcG99l.d.mts +201 -0
- package/dist/types-DejIu60O.d.cts +201 -0
- package/dist/types-DiIdKZ3K.d.cts +45 -0
- package/dist/types-GxLIgJib.d.cts +17 -0
- package/dist/types.cjs +15 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +14 -0
- package/dist/utils-BZyrxWWR.mjs +525 -0
- package/dist/utils-_6frwjgJ.cjs +1040 -0
- package/dist/utils.cjs +88 -0
- package/dist/utils.d.cts +144 -0
- package/dist/utils.d.mts +144 -0
- package/dist/utils.mjs +3 -0
- package/dist/wait-for-CMjPsqWk.d.cts +10 -0
- package/dist/wait-for-D2nkdD4z.d.mts +10 -0
- package/package.json +399 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
import { t as _defineProperty } from "./defineProperty-DrXfyjd4.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/rect-utils/affine-transform.ts
|
|
4
|
+
var AffineTransform = class AffineTransform {
|
|
5
|
+
constructor([m00, m01, m02, m10, m11, m12] = [
|
|
6
|
+
0,
|
|
7
|
+
0,
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
0
|
|
12
|
+
]) {
|
|
13
|
+
_defineProperty(this, "m00", void 0);
|
|
14
|
+
_defineProperty(this, "m01", void 0);
|
|
15
|
+
_defineProperty(this, "m02", void 0);
|
|
16
|
+
_defineProperty(this, "m10", void 0);
|
|
17
|
+
_defineProperty(this, "m11", void 0);
|
|
18
|
+
_defineProperty(this, "m12", void 0);
|
|
19
|
+
_defineProperty(this, "rotate", (...args) => {
|
|
20
|
+
return this.prepend(AffineTransform.rotate(...args));
|
|
21
|
+
});
|
|
22
|
+
_defineProperty(this, "scale", (...args) => {
|
|
23
|
+
return this.prepend(AffineTransform.scale(...args));
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "translate", (...args) => {
|
|
26
|
+
return this.prepend(AffineTransform.translate(...args));
|
|
27
|
+
});
|
|
28
|
+
this.m00 = m00;
|
|
29
|
+
this.m01 = m01;
|
|
30
|
+
this.m02 = m02;
|
|
31
|
+
this.m10 = m10;
|
|
32
|
+
this.m11 = m11;
|
|
33
|
+
this.m12 = m12;
|
|
34
|
+
}
|
|
35
|
+
applyTo(point) {
|
|
36
|
+
const { x, y } = point;
|
|
37
|
+
const { m00, m01, m02, m10, m11, m12 } = this;
|
|
38
|
+
return {
|
|
39
|
+
x: m00 * x + m01 * y + m02,
|
|
40
|
+
y: m10 * x + m11 * y + m12
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
prepend(other) {
|
|
44
|
+
return new AffineTransform([
|
|
45
|
+
this.m00 * other.m00 + this.m01 * other.m10,
|
|
46
|
+
this.m00 * other.m01 + this.m01 * other.m11,
|
|
47
|
+
this.m00 * other.m02 + this.m01 * other.m12 + this.m02,
|
|
48
|
+
this.m10 * other.m00 + this.m11 * other.m10,
|
|
49
|
+
this.m10 * other.m01 + this.m11 * other.m11,
|
|
50
|
+
this.m10 * other.m02 + this.m11 * other.m12 + this.m12
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
append(other) {
|
|
54
|
+
return new AffineTransform([
|
|
55
|
+
other.m00 * this.m00 + other.m01 * this.m10,
|
|
56
|
+
other.m00 * this.m01 + other.m01 * this.m11,
|
|
57
|
+
other.m00 * this.m02 + other.m01 * this.m12 + other.m02,
|
|
58
|
+
other.m10 * this.m00 + other.m11 * this.m10,
|
|
59
|
+
other.m10 * this.m01 + other.m11 * this.m11,
|
|
60
|
+
other.m10 * this.m02 + other.m11 * this.m12 + other.m12
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
get determinant() {
|
|
64
|
+
return this.m00 * this.m11 - this.m01 * this.m10;
|
|
65
|
+
}
|
|
66
|
+
get isInvertible() {
|
|
67
|
+
const det = this.determinant;
|
|
68
|
+
return isFinite(det) && isFinite(this.m02) && isFinite(this.m12) && det !== 0;
|
|
69
|
+
}
|
|
70
|
+
invert() {
|
|
71
|
+
const det = this.determinant;
|
|
72
|
+
return new AffineTransform([
|
|
73
|
+
this.m11 / det,
|
|
74
|
+
-this.m01 / det,
|
|
75
|
+
(this.m01 * this.m12 - this.m11 * this.m02) / det,
|
|
76
|
+
-this.m10 / det,
|
|
77
|
+
this.m00 / det,
|
|
78
|
+
(this.m10 * this.m02 - this.m00 * this.m12) / det
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
get array() {
|
|
82
|
+
return [
|
|
83
|
+
this.m00,
|
|
84
|
+
this.m01,
|
|
85
|
+
this.m02,
|
|
86
|
+
this.m10,
|
|
87
|
+
this.m11,
|
|
88
|
+
this.m12,
|
|
89
|
+
0,
|
|
90
|
+
0,
|
|
91
|
+
1
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
get float32Array() {
|
|
95
|
+
return new Float32Array(this.array);
|
|
96
|
+
}
|
|
97
|
+
static get identity() {
|
|
98
|
+
return new AffineTransform([
|
|
99
|
+
1,
|
|
100
|
+
0,
|
|
101
|
+
0,
|
|
102
|
+
0,
|
|
103
|
+
1,
|
|
104
|
+
0
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
static rotate(theta, origin) {
|
|
108
|
+
const rotation = new AffineTransform([
|
|
109
|
+
Math.cos(theta),
|
|
110
|
+
-Math.sin(theta),
|
|
111
|
+
0,
|
|
112
|
+
Math.sin(theta),
|
|
113
|
+
Math.cos(theta),
|
|
114
|
+
0
|
|
115
|
+
]);
|
|
116
|
+
if (origin && (origin.x !== 0 || origin.y !== 0)) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), rotation, AffineTransform.translate(-origin.x, -origin.y));
|
|
117
|
+
return rotation;
|
|
118
|
+
}
|
|
119
|
+
static scale(sx, sy = sx, origin = {
|
|
120
|
+
x: 0,
|
|
121
|
+
y: 0
|
|
122
|
+
}) {
|
|
123
|
+
const scale = new AffineTransform([
|
|
124
|
+
sx,
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
0,
|
|
128
|
+
sy,
|
|
129
|
+
0
|
|
130
|
+
]);
|
|
131
|
+
if (origin.x !== 0 || origin.y !== 0) return AffineTransform.multiply(AffineTransform.translate(origin.x, origin.y), scale, AffineTransform.translate(-origin.x, -origin.y));
|
|
132
|
+
return scale;
|
|
133
|
+
}
|
|
134
|
+
static translate(tx, ty) {
|
|
135
|
+
return new AffineTransform([
|
|
136
|
+
1,
|
|
137
|
+
0,
|
|
138
|
+
tx,
|
|
139
|
+
0,
|
|
140
|
+
1,
|
|
141
|
+
ty
|
|
142
|
+
]);
|
|
143
|
+
}
|
|
144
|
+
static multiply(...[first, ...rest]) {
|
|
145
|
+
if (!first) return AffineTransform.identity;
|
|
146
|
+
return rest.reduce((result, item) => result.prepend(item), first);
|
|
147
|
+
}
|
|
148
|
+
get a() {
|
|
149
|
+
return this.m00;
|
|
150
|
+
}
|
|
151
|
+
get b() {
|
|
152
|
+
return this.m10;
|
|
153
|
+
}
|
|
154
|
+
get c() {
|
|
155
|
+
return this.m01;
|
|
156
|
+
}
|
|
157
|
+
get d() {
|
|
158
|
+
return this.m11;
|
|
159
|
+
}
|
|
160
|
+
get tx() {
|
|
161
|
+
return this.m02;
|
|
162
|
+
}
|
|
163
|
+
get ty() {
|
|
164
|
+
return this.m12;
|
|
165
|
+
}
|
|
166
|
+
get scaleComponents() {
|
|
167
|
+
return {
|
|
168
|
+
x: this.a,
|
|
169
|
+
y: this.d
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
get translationComponents() {
|
|
173
|
+
return {
|
|
174
|
+
x: this.tx,
|
|
175
|
+
y: this.ty
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
get skewComponents() {
|
|
179
|
+
return {
|
|
180
|
+
x: this.c,
|
|
181
|
+
y: this.b
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
toString() {
|
|
185
|
+
return `matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.tx}, ${this.ty})`;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/shared/rect-utils/align.ts
|
|
191
|
+
function hAlign(a, ref, h) {
|
|
192
|
+
let x = ref.minX;
|
|
193
|
+
if (h === "left-inside") x = ref.minX;
|
|
194
|
+
if (h === "left-outside") x = ref.minX - ref.width;
|
|
195
|
+
if (h === "right-inside") x = ref.maxX - ref.width;
|
|
196
|
+
if (h === "right-outside") x = ref.maxX;
|
|
197
|
+
if (h === "center") x = ref.midX - ref.width / 2;
|
|
198
|
+
return {
|
|
199
|
+
...a,
|
|
200
|
+
x
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function vAlign(a, ref, v) {
|
|
204
|
+
let y = ref.minY;
|
|
205
|
+
if (v === "top-inside") y = ref.minY;
|
|
206
|
+
if (v === "top-outside") y = ref.minY - a.height;
|
|
207
|
+
if (v === "bottom-inside") y = ref.maxY - a.height;
|
|
208
|
+
if (v === "bottom-outside") y = ref.maxY;
|
|
209
|
+
if (v === "center") y = ref.midY - a.height / 2;
|
|
210
|
+
return {
|
|
211
|
+
...a,
|
|
212
|
+
y
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function alignRect(a, ref, options) {
|
|
216
|
+
const { h, v } = options;
|
|
217
|
+
return vAlign(hAlign(a, ref, h), ref, v);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/shared/rect-utils/angle.ts
|
|
222
|
+
function getPointAngle(rect, point, reference = rect.center) {
|
|
223
|
+
const x = point.x - reference.x;
|
|
224
|
+
const y = point.y - reference.y;
|
|
225
|
+
return 360 - (Math.atan2(x, y) * (180 / Math.PI) + 180);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/shared/rect-utils/clamp.ts
|
|
230
|
+
const clamp = (value, min$2, max$1) => Math.min(Math.max(value, min$2), max$1);
|
|
231
|
+
const clampPoint = (position, size, boundaryRect) => {
|
|
232
|
+
return {
|
|
233
|
+
x: clamp(position.x, boundaryRect.x, boundaryRect.x + boundaryRect.width - size.width),
|
|
234
|
+
y: clamp(position.y, boundaryRect.y, boundaryRect.y + boundaryRect.height - size.height)
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
const defaultMinSize = {
|
|
238
|
+
width: 0,
|
|
239
|
+
height: 0
|
|
240
|
+
};
|
|
241
|
+
const defaultMaxSize = {
|
|
242
|
+
width: Infinity,
|
|
243
|
+
height: Infinity
|
|
244
|
+
};
|
|
245
|
+
const clampSize = (size, minSize = defaultMinSize, maxSize = defaultMaxSize) => {
|
|
246
|
+
return {
|
|
247
|
+
width: Math.min(Math.max(size.width, minSize.width), maxSize.width),
|
|
248
|
+
height: Math.min(Math.max(size.height, minSize.height), maxSize.height)
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/shared/rect-utils/rect.ts
|
|
254
|
+
const createPoint = (x, y) => ({
|
|
255
|
+
x,
|
|
256
|
+
y
|
|
257
|
+
});
|
|
258
|
+
const subtractPoints = (a, b) => {
|
|
259
|
+
if (!b) return a;
|
|
260
|
+
return createPoint(a.x - b.x, a.y - b.y);
|
|
261
|
+
};
|
|
262
|
+
const addPoints = (a, b) => createPoint(a.x + b.x, a.y + b.y);
|
|
263
|
+
function isPoint(v) {
|
|
264
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y");
|
|
265
|
+
}
|
|
266
|
+
function createRect(r) {
|
|
267
|
+
const { x, y, width, height } = r;
|
|
268
|
+
const midX = x + width / 2;
|
|
269
|
+
const midY = y + height / 2;
|
|
270
|
+
return {
|
|
271
|
+
x,
|
|
272
|
+
y,
|
|
273
|
+
width,
|
|
274
|
+
height,
|
|
275
|
+
minX: x,
|
|
276
|
+
minY: y,
|
|
277
|
+
maxX: x + width,
|
|
278
|
+
maxY: y + height,
|
|
279
|
+
midX,
|
|
280
|
+
midY,
|
|
281
|
+
center: createPoint(midX, midY)
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function isRect(v) {
|
|
285
|
+
return Reflect.has(v, "x") && Reflect.has(v, "y") && Reflect.has(v, "width") && Reflect.has(v, "height");
|
|
286
|
+
}
|
|
287
|
+
function getRectCenters(v) {
|
|
288
|
+
return {
|
|
289
|
+
top: createPoint(v.midX, v.minY),
|
|
290
|
+
right: createPoint(v.maxX, v.midY),
|
|
291
|
+
bottom: createPoint(v.midX, v.maxY),
|
|
292
|
+
left: createPoint(v.minX, v.midY)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function getRectCorners(v) {
|
|
296
|
+
return {
|
|
297
|
+
top: createPoint(v.minX, v.minY),
|
|
298
|
+
right: createPoint(v.maxX, v.minY),
|
|
299
|
+
bottom: createPoint(v.maxX, v.maxY),
|
|
300
|
+
left: createPoint(v.minX, v.maxY)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function getRectEdges(v) {
|
|
304
|
+
const c = getRectCorners(v);
|
|
305
|
+
return {
|
|
306
|
+
top: [c.top, c.right],
|
|
307
|
+
right: [c.right, c.bottom],
|
|
308
|
+
bottom: [c.left, c.bottom],
|
|
309
|
+
left: [c.top, c.left]
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/shared/rect-utils/intersection.ts
|
|
315
|
+
function intersects(a, b) {
|
|
316
|
+
return a.x < b.maxX && a.y < b.maxY && a.maxX > b.x && a.maxY > b.y;
|
|
317
|
+
}
|
|
318
|
+
function intersection(a, b) {
|
|
319
|
+
const x = Math.max(a.x, b.x);
|
|
320
|
+
const y = Math.max(a.y, b.y);
|
|
321
|
+
const x2 = Math.min(a.x + a.width, b.x + b.width);
|
|
322
|
+
const y2 = Math.min(a.y + a.height, b.y + b.height);
|
|
323
|
+
return createRect({
|
|
324
|
+
x,
|
|
325
|
+
y,
|
|
326
|
+
width: x2 - x,
|
|
327
|
+
height: y2 - y
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function collisions(a, b) {
|
|
331
|
+
return {
|
|
332
|
+
top: a.minY <= b.minY,
|
|
333
|
+
right: a.maxX >= b.maxX,
|
|
334
|
+
bottom: a.maxY >= b.maxY,
|
|
335
|
+
left: a.minX <= b.minX
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/shared/rect-utils/distance.ts
|
|
341
|
+
function distance(a, b = {
|
|
342
|
+
x: 0,
|
|
343
|
+
y: 0
|
|
344
|
+
}) {
|
|
345
|
+
return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
|
|
346
|
+
}
|
|
347
|
+
function distanceFromPoint(r, p) {
|
|
348
|
+
let x = 0;
|
|
349
|
+
let y = 0;
|
|
350
|
+
if (p.x < r.x) x = r.x - p.x;
|
|
351
|
+
else if (p.x > r.maxX) x = p.x - r.maxX;
|
|
352
|
+
if (p.y < r.y) y = r.y - p.y;
|
|
353
|
+
else if (p.y > r.maxY) y = p.y - r.maxY;
|
|
354
|
+
return {
|
|
355
|
+
x,
|
|
356
|
+
y,
|
|
357
|
+
value: distance({
|
|
358
|
+
x,
|
|
359
|
+
y
|
|
360
|
+
})
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function distanceFromRect(a, b) {
|
|
364
|
+
if (intersects(a, b)) return {
|
|
365
|
+
x: 0,
|
|
366
|
+
y: 0,
|
|
367
|
+
value: 0
|
|
368
|
+
};
|
|
369
|
+
const left = a.x < b.x ? a : b;
|
|
370
|
+
const right = b.x < a.x ? a : b;
|
|
371
|
+
const upper = a.y < b.y ? a : b;
|
|
372
|
+
const lower = b.y < a.y ? a : b;
|
|
373
|
+
let x = left.x === right.x ? 0 : right.x - left.maxX;
|
|
374
|
+
x = Math.max(0, x);
|
|
375
|
+
let y = upper.y === lower.y ? 0 : lower.y - upper.maxY;
|
|
376
|
+
y = Math.max(0, y);
|
|
377
|
+
return {
|
|
378
|
+
x,
|
|
379
|
+
y,
|
|
380
|
+
value: distance({
|
|
381
|
+
x,
|
|
382
|
+
y
|
|
383
|
+
})
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function distanceBtwEdges(a, b) {
|
|
387
|
+
return {
|
|
388
|
+
left: b.x - a.x,
|
|
389
|
+
top: b.y - a.y,
|
|
390
|
+
right: a.maxX - b.maxX,
|
|
391
|
+
bottom: a.maxY - b.maxY
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/shared/rect-utils/closest.ts
|
|
397
|
+
function closest(...pts) {
|
|
398
|
+
return (a) => {
|
|
399
|
+
const ds = pts.map((b) => distance(b, a));
|
|
400
|
+
const c = Math.min.apply(Math, ds);
|
|
401
|
+
return pts[ds.indexOf(c)];
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function closestSideToRect(ref, r) {
|
|
405
|
+
if (r.maxX <= ref.minX) return "left";
|
|
406
|
+
if (r.minX >= ref.maxX) return "right";
|
|
407
|
+
if (r.maxY <= ref.minY) return "top";
|
|
408
|
+
if (r.minY >= ref.maxY) return "bottom";
|
|
409
|
+
return "left";
|
|
410
|
+
}
|
|
411
|
+
function closestSideToPoint(ref, p) {
|
|
412
|
+
const { x, y } = p;
|
|
413
|
+
const dl = x - ref.minX;
|
|
414
|
+
const dr = ref.maxX - x;
|
|
415
|
+
const dt = y - ref.minY;
|
|
416
|
+
const db = ref.maxY - y;
|
|
417
|
+
let closest$1 = dl;
|
|
418
|
+
let side = "left";
|
|
419
|
+
if (dr < closest$1) {
|
|
420
|
+
closest$1 = dr;
|
|
421
|
+
side = "right";
|
|
422
|
+
}
|
|
423
|
+
if (dt < closest$1) {
|
|
424
|
+
closest$1 = dt;
|
|
425
|
+
side = "top";
|
|
426
|
+
}
|
|
427
|
+
if (db < closest$1) side = "bottom";
|
|
428
|
+
return side;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/shared/rect-utils/constrain.ts
|
|
433
|
+
const constrainRect = (rect, boundary) => {
|
|
434
|
+
return {
|
|
435
|
+
x: Math.max(boundary.x, Math.min(rect.x, boundary.x + boundary.width - rect.width)),
|
|
436
|
+
y: Math.max(boundary.y, Math.min(rect.y, boundary.y + boundary.height - rect.height)),
|
|
437
|
+
width: Math.min(rect.width, boundary.width),
|
|
438
|
+
height: Math.min(rect.height, boundary.height)
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/shared/rect-utils/contains.ts
|
|
444
|
+
function containsPoint(r, p) {
|
|
445
|
+
return r.minX <= p.x && p.x <= r.maxX && r.minY <= p.y && p.y <= r.maxY;
|
|
446
|
+
}
|
|
447
|
+
function containsRect(a, b) {
|
|
448
|
+
return Object.values(getRectCorners(b)).every((c) => containsPoint(a, c));
|
|
449
|
+
}
|
|
450
|
+
function contains(r, v) {
|
|
451
|
+
return isRect(v) ? containsRect(r, v) : containsPoint(r, v);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/shared/rect-utils/equality.ts
|
|
456
|
+
const isSizeEqual = (a, b) => {
|
|
457
|
+
return a.width === b?.width && a.height === b?.height;
|
|
458
|
+
};
|
|
459
|
+
const isPointEqual = (a, b) => {
|
|
460
|
+
return a.x === b?.x && a.y === b?.y;
|
|
461
|
+
};
|
|
462
|
+
const isRectEqual = (a, b) => {
|
|
463
|
+
return isPointEqual(a, b) && isSizeEqual(a, b);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
//#endregion
|
|
467
|
+
//#region src/shared/rect-utils/from-element.ts
|
|
468
|
+
const styleCache = /* @__PURE__ */ new WeakMap();
|
|
469
|
+
function getCacheComputedStyle(el) {
|
|
470
|
+
if (!styleCache.has(el)) {
|
|
471
|
+
const win = el.ownerDocument.defaultView || window;
|
|
472
|
+
styleCache.set(el, win.getComputedStyle(el));
|
|
473
|
+
}
|
|
474
|
+
return styleCache.get(el);
|
|
475
|
+
}
|
|
476
|
+
function getElementRect(el, opts = {}) {
|
|
477
|
+
return createRect(getClientRect(el, opts));
|
|
478
|
+
}
|
|
479
|
+
function getClientRect(el, opts = {}) {
|
|
480
|
+
const { excludeScrollbar = false, excludeBorders = false } = opts;
|
|
481
|
+
const { x, y, width, height } = el.getBoundingClientRect();
|
|
482
|
+
const r = {
|
|
483
|
+
x,
|
|
484
|
+
y,
|
|
485
|
+
width,
|
|
486
|
+
height
|
|
487
|
+
};
|
|
488
|
+
const { borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth } = getCacheComputedStyle(el);
|
|
489
|
+
const borderXWidth = sum(borderLeftWidth, borderRightWidth);
|
|
490
|
+
const borderYWidth = sum(borderTopWidth, borderBottomWidth);
|
|
491
|
+
if (excludeBorders) {
|
|
492
|
+
r.width -= borderXWidth;
|
|
493
|
+
r.height -= borderYWidth;
|
|
494
|
+
r.x += px(borderLeftWidth);
|
|
495
|
+
r.y += px(borderTopWidth);
|
|
496
|
+
}
|
|
497
|
+
if (excludeScrollbar) {
|
|
498
|
+
const scrollbarWidth = el.offsetWidth - el.clientWidth - borderXWidth;
|
|
499
|
+
const scrollbarHeight = el.offsetHeight - el.clientHeight - borderYWidth;
|
|
500
|
+
r.width -= scrollbarWidth;
|
|
501
|
+
r.height -= scrollbarHeight;
|
|
502
|
+
}
|
|
503
|
+
return r;
|
|
504
|
+
}
|
|
505
|
+
const px = (v) => parseFloat(v.replace("px", ""));
|
|
506
|
+
const sum = (...vals) => vals.reduce((sum$1, v) => sum$1 + (v ? px(v) : 0), 0);
|
|
507
|
+
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/shared/rect-utils/from-points.ts
|
|
510
|
+
function getRectFromPoints(...pts) {
|
|
511
|
+
const xs = pts.map((p) => p.x);
|
|
512
|
+
const ys = pts.map((p) => p.y);
|
|
513
|
+
const x = Math.min(...xs);
|
|
514
|
+
const y = Math.min(...ys);
|
|
515
|
+
return createRect({
|
|
516
|
+
x,
|
|
517
|
+
y,
|
|
518
|
+
width: Math.max(...xs) - x,
|
|
519
|
+
height: Math.max(...ys) - y
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/shared/rect-utils/union.ts
|
|
525
|
+
const { min: min$1, max } = Math;
|
|
526
|
+
function union(...rs) {
|
|
527
|
+
return getRectFromPoints({
|
|
528
|
+
x: min$1(...rs.map((r) => r.minX)),
|
|
529
|
+
y: min$1(...rs.map((r) => r.minY))
|
|
530
|
+
}, {
|
|
531
|
+
x: max(...rs.map((r) => r.maxX)),
|
|
532
|
+
y: max(...rs.map((r) => r.maxY))
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/shared/rect-utils/from-range.ts
|
|
538
|
+
function fromRange(range) {
|
|
539
|
+
let rs = [];
|
|
540
|
+
const rects = Array.from(range.getClientRects());
|
|
541
|
+
if (rects.length) {
|
|
542
|
+
rs = rs.concat(rects.map(createRect));
|
|
543
|
+
return union.apply(void 0, rs);
|
|
544
|
+
}
|
|
545
|
+
let start = range.startContainer;
|
|
546
|
+
if (start.nodeType === Node.TEXT_NODE) start = start.parentNode;
|
|
547
|
+
if (start instanceof HTMLElement) {
|
|
548
|
+
const r = getElementRect(start);
|
|
549
|
+
rs.push({
|
|
550
|
+
...r,
|
|
551
|
+
x: r.maxX,
|
|
552
|
+
width: 0
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return union.apply(void 0, rs);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/shared/rect-utils/from-rotation.ts
|
|
560
|
+
function toRad(d) {
|
|
561
|
+
return d % 360 * Math.PI / 180;
|
|
562
|
+
}
|
|
563
|
+
function rotate(a, d, c) {
|
|
564
|
+
const r = toRad(d);
|
|
565
|
+
const sin = Math.sin(r);
|
|
566
|
+
const cos = Math.cos(r);
|
|
567
|
+
const x = a.x - c.x;
|
|
568
|
+
const y = a.y - c.y;
|
|
569
|
+
return {
|
|
570
|
+
x: c.x + x * cos - y * sin,
|
|
571
|
+
y: c.y + x * sin + y * cos
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function getRotationRect(r, deg) {
|
|
575
|
+
const rr = Object.values(getRectCorners(r)).map((p) => rotate(p, deg, r.center));
|
|
576
|
+
const xs = rr.map((p) => p.x);
|
|
577
|
+
const ys = rr.map((p) => p.y);
|
|
578
|
+
const minX = Math.min(...xs);
|
|
579
|
+
const minY = Math.min(...ys);
|
|
580
|
+
const maxX = Math.max(...xs);
|
|
581
|
+
const maxY = Math.max(...ys);
|
|
582
|
+
return createRect({
|
|
583
|
+
x: minX,
|
|
584
|
+
y: minY,
|
|
585
|
+
width: maxX - minX,
|
|
586
|
+
height: maxY - minY
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/shared/rect-utils/from-window.ts
|
|
592
|
+
function getWindowRect(win, opts = {}) {
|
|
593
|
+
return createRect(getViewportRect(win, opts));
|
|
594
|
+
}
|
|
595
|
+
function getViewportRect(win, opts) {
|
|
596
|
+
const { excludeScrollbar = false } = opts;
|
|
597
|
+
const { innerWidth, innerHeight, document: doc, visualViewport } = win;
|
|
598
|
+
const rect = {
|
|
599
|
+
x: 0,
|
|
600
|
+
y: 0,
|
|
601
|
+
width: visualViewport?.width || innerWidth,
|
|
602
|
+
height: visualViewport?.height || innerHeight
|
|
603
|
+
};
|
|
604
|
+
if (excludeScrollbar) {
|
|
605
|
+
const scrollbarWidth = innerWidth - doc.documentElement.clientWidth;
|
|
606
|
+
const scrollbarHeight = innerHeight - doc.documentElement.clientHeight;
|
|
607
|
+
rect.width -= scrollbarWidth;
|
|
608
|
+
rect.height -= scrollbarHeight;
|
|
609
|
+
}
|
|
610
|
+
return rect;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/shared/rect-utils/operations.ts
|
|
615
|
+
const isSymmetric = (v) => "dx" in v || "dy" in v;
|
|
616
|
+
function inset(r, i) {
|
|
617
|
+
const { top = 0, right = 0, bottom = 0, left = 0 } = isSymmetric(i) ? {
|
|
618
|
+
left: i.dx,
|
|
619
|
+
right: i.dx,
|
|
620
|
+
top: i.dy,
|
|
621
|
+
bottom: i.dy
|
|
622
|
+
} : i;
|
|
623
|
+
return createRect({
|
|
624
|
+
x: r.x + left,
|
|
625
|
+
y: r.y + top,
|
|
626
|
+
width: r.width - left - right,
|
|
627
|
+
height: r.height - top - bottom
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function expand(r, v) {
|
|
631
|
+
return inset(r, typeof v === "number" ? {
|
|
632
|
+
dx: -v,
|
|
633
|
+
dy: -v
|
|
634
|
+
} : v);
|
|
635
|
+
}
|
|
636
|
+
function shrink(r, v) {
|
|
637
|
+
return inset(r, typeof v === "number" ? {
|
|
638
|
+
dx: -v,
|
|
639
|
+
dy: -v
|
|
640
|
+
} : v);
|
|
641
|
+
}
|
|
642
|
+
function shift(r, o) {
|
|
643
|
+
const { x = 0, y = 0 } = o;
|
|
644
|
+
return createRect({
|
|
645
|
+
x: r.x + x,
|
|
646
|
+
y: r.y + y,
|
|
647
|
+
width: r.width,
|
|
648
|
+
height: r.height
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/shared/rect-utils/polygon.ts
|
|
654
|
+
function getElementPolygon(rectValue, placement) {
|
|
655
|
+
const { top, right, left, bottom } = getRectCorners(createRect(rectValue));
|
|
656
|
+
const [base] = placement.split("-");
|
|
657
|
+
return {
|
|
658
|
+
top: [
|
|
659
|
+
left,
|
|
660
|
+
top,
|
|
661
|
+
right,
|
|
662
|
+
bottom
|
|
663
|
+
],
|
|
664
|
+
right: [
|
|
665
|
+
top,
|
|
666
|
+
right,
|
|
667
|
+
bottom,
|
|
668
|
+
left
|
|
669
|
+
],
|
|
670
|
+
bottom: [
|
|
671
|
+
top,
|
|
672
|
+
left,
|
|
673
|
+
bottom,
|
|
674
|
+
right
|
|
675
|
+
],
|
|
676
|
+
left: [
|
|
677
|
+
right,
|
|
678
|
+
top,
|
|
679
|
+
left,
|
|
680
|
+
bottom
|
|
681
|
+
]
|
|
682
|
+
}[base];
|
|
683
|
+
}
|
|
684
|
+
function isPointInPolygon(polygon, point) {
|
|
685
|
+
const { x, y } = point;
|
|
686
|
+
let c = false;
|
|
687
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
688
|
+
const xi = polygon[i].x;
|
|
689
|
+
const yi = polygon[i].y;
|
|
690
|
+
const xj = polygon[j].x;
|
|
691
|
+
const yj = polygon[j].y;
|
|
692
|
+
if (yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi) c = !c;
|
|
693
|
+
}
|
|
694
|
+
return c;
|
|
695
|
+
}
|
|
696
|
+
function createPolygonElement() {
|
|
697
|
+
const id = "debug-polygon";
|
|
698
|
+
const existingPolygon = document.getElementById(id);
|
|
699
|
+
if (existingPolygon) return existingPolygon;
|
|
700
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
701
|
+
Object.assign(svg.style, {
|
|
702
|
+
top: "0",
|
|
703
|
+
left: "0",
|
|
704
|
+
width: "100%",
|
|
705
|
+
height: "100%",
|
|
706
|
+
opacity: "0.15",
|
|
707
|
+
position: "fixed",
|
|
708
|
+
pointerEvents: "none",
|
|
709
|
+
fill: "red"
|
|
710
|
+
});
|
|
711
|
+
const polygon = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
|
|
712
|
+
polygon.setAttribute("id", id);
|
|
713
|
+
polygon.setAttribute("points", "0,0 0,0");
|
|
714
|
+
svg.appendChild(polygon);
|
|
715
|
+
document.body.appendChild(svg);
|
|
716
|
+
return polygon;
|
|
717
|
+
}
|
|
718
|
+
function debugPolygon(polygon) {
|
|
719
|
+
const el = createPolygonElement();
|
|
720
|
+
const points = polygon.map((point) => `${point.x},${point.y}`).join(" ");
|
|
721
|
+
el.setAttribute("points", points);
|
|
722
|
+
return () => {
|
|
723
|
+
el.remove();
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/shared/rect-utils/compass.ts
|
|
729
|
+
const compassDirectionMap = {
|
|
730
|
+
n: {
|
|
731
|
+
x: .5,
|
|
732
|
+
y: 0
|
|
733
|
+
},
|
|
734
|
+
ne: {
|
|
735
|
+
x: 1,
|
|
736
|
+
y: 0
|
|
737
|
+
},
|
|
738
|
+
e: {
|
|
739
|
+
x: 1,
|
|
740
|
+
y: .5
|
|
741
|
+
},
|
|
742
|
+
se: {
|
|
743
|
+
x: 1,
|
|
744
|
+
y: 1
|
|
745
|
+
},
|
|
746
|
+
s: {
|
|
747
|
+
x: .5,
|
|
748
|
+
y: 1
|
|
749
|
+
},
|
|
750
|
+
sw: {
|
|
751
|
+
x: 0,
|
|
752
|
+
y: 1
|
|
753
|
+
},
|
|
754
|
+
w: {
|
|
755
|
+
x: 0,
|
|
756
|
+
y: .5
|
|
757
|
+
},
|
|
758
|
+
nw: {
|
|
759
|
+
x: 0,
|
|
760
|
+
y: 0
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
const oppositeDirectionMap = {
|
|
764
|
+
n: "s",
|
|
765
|
+
ne: "sw",
|
|
766
|
+
e: "w",
|
|
767
|
+
se: "nw",
|
|
768
|
+
s: "n",
|
|
769
|
+
sw: "ne",
|
|
770
|
+
w: "e",
|
|
771
|
+
nw: "se"
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/shared/rect-utils/resize.ts
|
|
776
|
+
const { sign, abs, min } = Math;
|
|
777
|
+
function getRectExtentPoint(rect, direction) {
|
|
778
|
+
const { minX, minY, maxX, maxY, midX, midY } = rect;
|
|
779
|
+
return {
|
|
780
|
+
x: direction.includes("w") ? minX : direction.includes("e") ? maxX : midX,
|
|
781
|
+
y: direction.includes("n") ? minY : direction.includes("s") ? maxY : midY
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
function getOppositeDirection(direction) {
|
|
785
|
+
return oppositeDirectionMap[direction];
|
|
786
|
+
}
|
|
787
|
+
function resizeRect(rect, offset, direction, opts) {
|
|
788
|
+
const { scalingOriginMode, lockAspectRatio } = opts;
|
|
789
|
+
const extent = getRectExtentPoint(rect, direction);
|
|
790
|
+
const oppositeExtent = getRectExtentPoint(rect, getOppositeDirection(direction));
|
|
791
|
+
if (scalingOriginMode === "center") offset = {
|
|
792
|
+
x: offset.x * 2,
|
|
793
|
+
y: offset.y * 2
|
|
794
|
+
};
|
|
795
|
+
const newExtent = {
|
|
796
|
+
x: extent.x + offset.x,
|
|
797
|
+
y: extent.y + offset.y
|
|
798
|
+
};
|
|
799
|
+
const multiplier = {
|
|
800
|
+
x: compassDirectionMap[direction].x * 2 - 1,
|
|
801
|
+
y: compassDirectionMap[direction].y * 2 - 1
|
|
802
|
+
};
|
|
803
|
+
const newSize = {
|
|
804
|
+
width: newExtent.x - oppositeExtent.x,
|
|
805
|
+
height: newExtent.y - oppositeExtent.y
|
|
806
|
+
};
|
|
807
|
+
const scaleX = multiplier.x * newSize.width / rect.width;
|
|
808
|
+
const scaleY = multiplier.y * newSize.height / rect.height;
|
|
809
|
+
const largestMagnitude = abs(scaleX) > abs(scaleY) ? scaleX : scaleY;
|
|
810
|
+
const scale = lockAspectRatio ? {
|
|
811
|
+
x: largestMagnitude,
|
|
812
|
+
y: largestMagnitude
|
|
813
|
+
} : {
|
|
814
|
+
x: extent.x === oppositeExtent.x ? 1 : scaleX,
|
|
815
|
+
y: extent.y === oppositeExtent.y ? 1 : scaleY
|
|
816
|
+
};
|
|
817
|
+
if (extent.y === oppositeExtent.y) scale.y = abs(scale.y);
|
|
818
|
+
else if (sign(scale.y) !== sign(scaleY)) scale.y *= -1;
|
|
819
|
+
if (extent.x === oppositeExtent.x) scale.x = abs(scale.x);
|
|
820
|
+
else if (sign(scale.x) !== sign(scaleX)) scale.x *= -1;
|
|
821
|
+
switch (scalingOriginMode) {
|
|
822
|
+
case "extent": return transformRect(rect, AffineTransform.scale(scale.x, scale.y, oppositeExtent), false);
|
|
823
|
+
case "center": return transformRect(rect, AffineTransform.scale(scale.x, scale.y, {
|
|
824
|
+
x: rect.midX,
|
|
825
|
+
y: rect.midY
|
|
826
|
+
}), false);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function createRectFromPoints(initialPoint, finalPoint, normalized = true) {
|
|
830
|
+
if (normalized) return {
|
|
831
|
+
x: min(finalPoint.x, initialPoint.x),
|
|
832
|
+
y: min(finalPoint.y, initialPoint.y),
|
|
833
|
+
width: abs(finalPoint.x - initialPoint.x),
|
|
834
|
+
height: abs(finalPoint.y - initialPoint.y)
|
|
835
|
+
};
|
|
836
|
+
return {
|
|
837
|
+
x: initialPoint.x,
|
|
838
|
+
y: initialPoint.y,
|
|
839
|
+
width: finalPoint.x - initialPoint.x,
|
|
840
|
+
height: finalPoint.y - initialPoint.y
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
function transformRect(rect, transform, normalized = true) {
|
|
844
|
+
return createRectFromPoints(transform.applyTo({
|
|
845
|
+
x: rect.minX,
|
|
846
|
+
y: rect.minY
|
|
847
|
+
}), transform.applyTo({
|
|
848
|
+
x: rect.maxX,
|
|
849
|
+
y: rect.maxY
|
|
850
|
+
}), normalized);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
//#endregion
|
|
854
|
+
export { distanceBtwEdges as A, getRectCorners as B, containsPoint as C, closestSideToPoint as D, closest as E, intersects as F, clampPoint as G, isPoint as H, addPoints as I, alignRect as J, clampSize as K, createPoint as L, distanceFromRect as M, collisions as N, closestSideToRect as O, intersection as P, createRect as R, contains as S, constrainRect as T, isRect as U, getRectEdges as V, subtractPoints as W, AffineTransform as Y, getRectFromPoints as _, expand as a, isRectEqual as b, shift as c, getWindowRect as d, getRotationRect as f, union as g, fromRange as h, isPointInPolygon as i, distanceFromPoint as j, distance as k, shrink as l, toRad as m, debugPolygon as n, inset as o, rotate as p, getPointAngle as q, getElementPolygon as r, isSymmetric as s, resizeRect as t, getViewportRect as u, getElementRect as v, containsRect as w, isSizeEqual as x, isPointEqual as y, getRectCenters as z };
|