@dwelle/excalidraw 0.5.0-da1c822 → 0.5.0-e56eec7
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/CHANGELOG.md +13 -2
- package/dist/browser/dev/excalidraw-assets-dev/{blockDiagram-91b80b7a-RHODGCTM.js → blockDiagram-91b80b7a-NRABZKZA.js} +6 -6
- package/dist/browser/dev/excalidraw-assets-dev/{c4Diagram-b2a90758-W7NCR7LR.js → c4Diagram-b2a90758-56M32CJD.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-TKRIVTWP.js → chunk-5EDB2FTV.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-52OGG53V.js → chunk-6VTJEXQH.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-J5HRUYQR.js → chunk-AKQDHN2W.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/chunk-AKQDHN2W.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-GF7VCOUM.js → chunk-C4OL7SRI.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-BESQLMCW.js → chunk-E47I6Q7O.js} +5 -5
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-UETNA2WX.js → chunk-KDIPICHB.js} +6377 -4340
- package/dist/browser/dev/excalidraw-assets-dev/chunk-KDIPICHB.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-5747M6KP.js → chunk-OH2YDYHX.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-GPOYIZPX.js → chunk-PXBR5CBM.js} +28 -28
- package/dist/browser/dev/excalidraw-assets-dev/chunk-PXBR5CBM.js.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-GCA4S2OA.js → chunk-RTA6DTUV.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-DQOPSCYA.js → chunk-TTH3BTHQ.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-B2MHJWXZ.js → chunk-U4N7TEPH.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-QFS4M5OJ.js → chunk-V3PA4IDR.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-SLLUETBM.js → chunk-WFT6ZJE6.js} +7 -7
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-PPHFJLL7.js → chunk-XZKEYTKS.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{chunk-USLWOHUZ.js → chunk-YC6VTXEO.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{classDiagram-30eddba6-GJGBT4TV.js → classDiagram-30eddba6-EZJVINS6.js} +6 -6
- package/dist/browser/dev/excalidraw-assets-dev/{classDiagram-v2-f2df5561-LYWTIPJA.js → classDiagram-v2-f2df5561-XSUIN44A.js} +9 -9
- package/dist/browser/dev/excalidraw-assets-dev/{directory-open-01563666-UREMLRIT.js → directory-open-01563666-KOK2HSB6.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{directory-open-4ed118d0-UN3BUDZZ.js → directory-open-4ed118d0-P3Q3CLF3.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/dist-O6HOTHQF.js +10 -0
- package/dist/browser/dev/excalidraw-assets-dev/{en-UW5C5KGW.js → en-PSBMWL4S.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{erDiagram-47591fe2-Z7U2XW2Y.js → erDiagram-47591fe2-U7FLWOG3.js} +5 -5
- package/dist/browser/dev/excalidraw-assets-dev/{file-open-002ab408-4QG336MG.js → file-open-002ab408-EQEHGU2J.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{file-open-7c801643-3QI4ICCL.js → file-open-7c801643-QQT6O7P5.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{file-save-3189631c-TNNERCWV.js → file-save-3189631c-YXX2C7C6.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{file-save-745eba88-JFMH565P.js → file-save-745eba88-7G554KTZ.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{flowDiagram-5540d9b9-PARVG263.js → flowDiagram-5540d9b9-F2VP4JAA.js} +10 -10
- package/dist/browser/dev/excalidraw-assets-dev/{flowDiagram-v2-3b53844e-ZJOPVRMB.js → flowDiagram-v2-3b53844e-2WQZZRND.js} +10 -10
- package/dist/browser/dev/excalidraw-assets-dev/{flowchart-elk-definition-5fe447d6-ULPNBSZX.js → flowchart-elk-definition-5fe447d6-IW6O2F6C.js} +6 -6
- package/dist/browser/dev/excalidraw-assets-dev/{ganttDiagram-9a3bba1f-ESSYVTJ4.js → ganttDiagram-9a3bba1f-B5RH7ZAO.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{gitGraphDiagram-96e6b4ee-6V6VVNNP.js → gitGraphDiagram-96e6b4ee-INGQRNLZ.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{image-ZNQQXS62.css → image-FDQLNM24.css} +39 -16
- package/dist/browser/dev/excalidraw-assets-dev/image-FDQLNM24.css.map +7 -0
- package/dist/browser/dev/excalidraw-assets-dev/{image-3LTGFHLF.js → image-GMAHLVER.js} +6 -6
- package/dist/browser/dev/excalidraw-assets-dev/{image-blob-reduce.esm-KTX27DAY.js → image-blob-reduce.esm-OX75MRP3.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{infoDiagram-bcd20f53-I22FLFX3.js → infoDiagram-bcd20f53-43FMAUOR.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{journeyDiagram-4fe6b3dc-WAO6F52C.js → journeyDiagram-4fe6b3dc-KFVOUX4I.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{katex-NWA2YFOP.js → katex-A3GRORPB.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{mindmap-definition-f354de21-K74IKX4Y.js → mindmap-definition-f354de21-D7S3CRQ4.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{pica-3TH2EGXR.js → pica-ZAD7MTGA.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{pieDiagram-79897490-DOB2LVE5.js → pieDiagram-79897490-OON2CRZ5.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{quadrantDiagram-62f64e94-MJV2X7WI.js → quadrantDiagram-62f64e94-5APTNVVS.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{requirementDiagram-05bf5f74-H4YM3XN7.js → requirementDiagram-05bf5f74-FM7WZVKU.js} +5 -5
- package/dist/browser/dev/excalidraw-assets-dev/{roundRect-4S3QV2NZ.js → roundRect-AYYHVX5X.js} +2 -2
- package/dist/browser/dev/excalidraw-assets-dev/{sankeyDiagram-97764748-7X74ABAN.js → sankeyDiagram-97764748-5HLEFFGY.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{sequenceDiagram-acc0e65c-PPDIJFQP.js → sequenceDiagram-acc0e65c-4ZRSNGPV.js} +4 -4
- package/dist/browser/dev/excalidraw-assets-dev/{stateDiagram-0ff1cf1a-JVBR7N35.js → stateDiagram-0ff1cf1a-OLTPYRPP.js} +6 -6
- package/dist/browser/dev/excalidraw-assets-dev/{stateDiagram-v2-9a9d610d-QYAJLQJH.js → stateDiagram-v2-9a9d610d-N3XOTAEE.js} +9 -9
- package/dist/browser/dev/excalidraw-assets-dev/{timeline-definition-fea2a41d-GL7U3WDB.js → timeline-definition-fea2a41d-5PDFIYJQ.js} +3 -3
- package/dist/browser/dev/excalidraw-assets-dev/{xychartDiagram-ab372869-4U4JE4TW.js → xychartDiagram-ab372869-VIWBP45Y.js} +4 -4
- package/dist/browser/dev/index.css +38 -15
- package/dist/browser/dev/index.css.map +2 -2
- package/dist/browser/dev/index.js +9 -5
- package/dist/browser/prod/excalidraw-assets/ar-SA-JA6F2FMJ-MVAFRXH2.js +10 -0
- package/dist/browser/prod/excalidraw-assets/az-AZ-GVIENQVH-DULWV7IG.js +1 -0
- package/dist/browser/prod/excalidraw-assets/bg-BG-YFNNHCEP-TOMMDX7A.js +5 -0
- package/dist/browser/prod/excalidraw-assets/{blockDiagram-91b80b7a-BO7MW3VX.js → blockDiagram-91b80b7a-ZBW6LBXS.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/bn-BD-LMEIWSRD-U6EPN6XJ.js +5 -0
- package/dist/browser/prod/excalidraw-assets/{c4Diagram-b2a90758-VCUPBVHR.js → c4Diagram-b2a90758-GET6IFET.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/ca-ES-C2WGCLOT-4Q2376G3.js +8 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-O77Z7CWL.js → chunk-2UGPV7X3.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-B7CDQVNY.js → chunk-364WSJPQ.js} +21 -21
- package/dist/browser/prod/excalidraw-assets/{chunk-NM5B2RBP.js → chunk-4FM7RPKW.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-CVEF66PS.js → chunk-4SHJFNCN.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-22FVL4I7.js → chunk-6TNDONBF.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-QLNFR4AJ.js → chunk-BJTCWAK5.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/chunk-CKRG5LOX.js +335 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-3HZHH3PT.js → chunk-IW42BK4V.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-4JYQ3563.js → chunk-MRQWXP64.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-VXFFPRP2.js → chunk-OG2UUKMT.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/chunk-Q6QP4TRB.js +11 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-V7HUISEN.js → chunk-QBYA3CCP.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-5PWM36DG.js → chunk-S3O7MXSU.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/chunk-SJBOQTFA.js +1 -0
- package/dist/browser/prod/excalidraw-assets/{chunk-3VCRCP5J.js → chunk-T7MBBIYG.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-HPA5W5VE.js → chunk-X7R4RA7C.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{chunk-7UJZVYSR.js → chunk-Y3NNVSMP.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{classDiagram-30eddba6-VXGNM3LI.js → classDiagram-30eddba6-MJ5GZSCE.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{classDiagram-v2-f2df5561-YALTASVE.js → classDiagram-v2-f2df5561-FU5PRXDD.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/cs-CZ-F2NDIQMB-4NMYRMO2.js +11 -0
- package/dist/browser/prod/excalidraw-assets/da-DK-WBEQB3CJ-6YAF4DNI.js +5 -0
- package/dist/browser/prod/excalidraw-assets/de-DE-VEIMCP7R-NSRLPHDI.js +8 -0
- package/dist/browser/prod/excalidraw-assets/{directory-open-01563666-JWXY2QSC.js → directory-open-01563666-UG2J4T6L.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{directory-open-4ed118d0-6AL5X37W.js → directory-open-4ed118d0-FGQD6TMW.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/dist-LI3DBBWR.js +1 -0
- package/dist/browser/prod/excalidraw-assets/el-GR-TKRKG5GQ-6N4GY2DI.js +10 -0
- package/dist/browser/prod/excalidraw-assets/{en-CPU3UVKT.js → en-MPFDZHEH.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/en-Q552WR7L-QAV42NF3.js +1 -0
- package/dist/browser/prod/excalidraw-assets/{erDiagram-47591fe2-GKYANCN7.js → erDiagram-47591fe2-YGAMNOK6.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/es-ES-TOLWEZNW-ODY4LX7F.js +9 -0
- package/dist/browser/prod/excalidraw-assets/eu-ES-7CDRJQWJ-KF3KSB2X.js +11 -0
- package/dist/browser/prod/excalidraw-assets/fa-IR-527E2XGU-WLLGMWYR.js +8 -0
- package/dist/browser/prod/excalidraw-assets/fi-FI-NLQ7RQGZ-EZLGQEWF.js +6 -0
- package/dist/browser/prod/excalidraw-assets/{file-open-002ab408-3EPJOH45.js → file-open-002ab408-WLX7QPS6.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{file-open-7c801643-QIP6HK4D.js → file-open-7c801643-YB6IH3XI.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{file-save-3189631c-4TQJBQCS.js → file-save-3189631c-MRYCXU63.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{file-save-745eba88-C4L3ZGCC.js → file-save-745eba88-UZEDMFLR.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{flowDiagram-5540d9b9-QBRW5SLP.js → flowDiagram-5540d9b9-V23UQWYJ.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/flowDiagram-v2-3b53844e-UDC2ZAFT.js +1 -0
- package/dist/browser/prod/excalidraw-assets/{flowchart-elk-definition-5fe447d6-YYO2EYKS.js → flowchart-elk-definition-5fe447d6-N3ISH6AG.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/fr-FR-KUHO4FLU-2OW7FE5V.js +9 -0
- package/dist/browser/prod/excalidraw-assets/{ganttDiagram-9a3bba1f-3B2DUUUQ.js → ganttDiagram-9a3bba1f-7SAN2TXA.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{gitGraphDiagram-96e6b4ee-G6CKXXWQ.js → gitGraphDiagram-96e6b4ee-EXV6PWXL.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/gl-ES-NEXX3VBB-TESFDR6O.js +10 -0
- package/dist/browser/prod/excalidraw-assets/he-IL-MED2VGBZ-N4VYRCHF.js +10 -0
- package/dist/browser/prod/excalidraw-assets/hi-IN-5V633W7V-4VXVQ6GE.js +4 -0
- package/dist/browser/prod/excalidraw-assets/hu-HU-2FOZGVGR-7CHHZRPD.js +7 -0
- package/dist/browser/prod/excalidraw-assets/id-ID-I6BOLXTF-ULJRGCTU.js +10 -0
- package/dist/browser/prod/excalidraw-assets/image-ZKACJTPS.js +1 -0
- package/dist/browser/prod/excalidraw-assets/{image-blob-reduce.esm-5DTGAOOI.js → image-blob-reduce.esm-GOFU5DPX.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{infoDiagram-bcd20f53-WJTZJERL.js → infoDiagram-bcd20f53-LJZ36XP5.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/it-IT-WKPQOK4P-C3FTW2QG.js +11 -0
- package/dist/browser/prod/excalidraw-assets/ja-JP-VKA4ISRU-EBXFDMUP.js +8 -0
- package/dist/browser/prod/excalidraw-assets/{journeyDiagram-4fe6b3dc-JF22KXXQ.js → journeyDiagram-4fe6b3dc-TFRSU2KH.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/kaa-IKPRSBNY-URJPWZZH.js +1 -0
- package/dist/browser/prod/excalidraw-assets/kab-KAB-IE4PHQTZ-OMISFOMM.js +8 -0
- package/dist/browser/prod/excalidraw-assets/{katex-N6R5DPQX.js → katex-HAQKNIIQ.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/kk-KZ-MNJT6XSV-56OVE4EH.js +1 -0
- package/dist/browser/prod/excalidraw-assets/km-KH-LADGDFXV-KI7V2Z5A.js +11 -0
- package/dist/browser/prod/excalidraw-assets/ko-KR-XD7AVF2F-EFYGITKM.js +9 -0
- package/dist/browser/prod/excalidraw-assets/ku-TR-4XBHKDQA-U25XLPMW.js +9 -0
- package/dist/browser/prod/excalidraw-assets/lt-LT-QC35R4YH-6TDSRONI.js +3 -0
- package/dist/browser/prod/excalidraw-assets/lv-LV-GSD5D3BA-KMXM2FQ7.js +7 -0
- package/dist/browser/prod/excalidraw-assets/{mindmap-definition-f354de21-7SH5STU3.js → mindmap-definition-f354de21-J3C2WSJB.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/mr-IN-KOLSWM7Y-NVYC6JCO.js +13 -0
- package/dist/browser/prod/excalidraw-assets/my-MM-M53KMUET-A2ORJJ2D.js +1 -0
- package/dist/browser/prod/excalidraw-assets/nb-NO-XXC6U37A-L4O4DGCC.js +10 -0
- package/dist/browser/prod/excalidraw-assets/nl-NL-HCCJQEUO-7Q2LV5NM.js +8 -0
- package/dist/browser/prod/excalidraw-assets/nn-NO-6P7Z2PI2-TUT2PFEE.js +8 -0
- package/dist/browser/prod/excalidraw-assets/oc-FR-JRJKPLNT-SBQHJH7X.js +8 -0
- package/dist/browser/prod/excalidraw-assets/pa-IN-LZWLEPIB-7NKOXI65.js +4 -0
- package/dist/browser/prod/excalidraw-assets/percentages-UCQDHIQF-Q4IM6ZEB.js +1 -0
- package/dist/browser/prod/excalidraw-assets/{pica-KWHN2PJ6.js → pica-ABPXE5C5.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{pieDiagram-79897490-5O5EBEQB.js → pieDiagram-79897490-FMJ3ZAF7.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/pl-PL-3WBLCXI2-E2SMTIVM.js +9 -0
- package/dist/browser/prod/excalidraw-assets/pt-BR-O3ZPTUNW-RS7M7EKX.js +9 -0
- package/dist/browser/prod/excalidraw-assets/pt-PT-7AQTSAFO-AEANJ2UN.js +9 -0
- package/dist/browser/prod/excalidraw-assets/{quadrantDiagram-62f64e94-JTY6WOKB.js → quadrantDiagram-62f64e94-YI32TPUI.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{requirementDiagram-05bf5f74-TSFQFY5X.js → requirementDiagram-05bf5f74-UO2ATL3U.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/ro-RO-HJ65JYWV-35XNZ4QJ.js +11 -0
- package/dist/browser/prod/excalidraw-assets/{roundRect-PUCZURYS.js → roundRect-UKQBLFKQ.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/ru-RU-P7ROIYNC-ERPG3GJT.js +9 -0
- package/dist/browser/prod/excalidraw-assets/{sankeyDiagram-97764748-7G2R6W67.js → sankeyDiagram-97764748-3RR36435.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{sequenceDiagram-acc0e65c-CTANNZCO.js → sequenceDiagram-acc0e65c-G2Q6J4UN.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/si-LK-7ZSWVION-YHKN25MU.js +1 -0
- package/dist/browser/prod/excalidraw-assets/sk-SK-NXVBGLYY-IKQZT26E.js +6 -0
- package/dist/browser/prod/excalidraw-assets/sl-SI-VFTWOYNP-UPLNMI3E.js +6 -0
- package/dist/browser/prod/excalidraw-assets/{stateDiagram-0ff1cf1a-I5COLKZ4.js → stateDiagram-0ff1cf1a-QEYVXCSB.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/{stateDiagram-v2-9a9d610d-IIHI3AJN.js → stateDiagram-v2-9a9d610d-3VKD7UYK.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/sv-SE-YONBLQNW-ZG4TE7PV.js +10 -0
- package/dist/browser/prod/excalidraw-assets/ta-IN-BSETPMLX-FC54FMQJ.js +9 -0
- package/dist/browser/prod/excalidraw-assets/th-TH-URTRDITB-K6QQ2PRO.js +2 -0
- package/dist/browser/prod/excalidraw-assets/{timeline-definition-fea2a41d-CXTGKWI4.js → timeline-definition-fea2a41d-H4D6IYVJ.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/tr-TR-N5SCAVTB-HMUEG6DN.js +7 -0
- package/dist/browser/prod/excalidraw-assets/uk-UA-LBCYVSQZ-DEJZCNRZ.js +6 -0
- package/dist/browser/prod/excalidraw-assets/vi-VN-POZWLIUU-EY6QFLQV.js +5 -0
- package/dist/browser/prod/excalidraw-assets/{xychartDiagram-ab372869-QZGPPHJP.js → xychartDiagram-ab372869-SUXFHV53.js} +1 -1
- package/dist/browser/prod/excalidraw-assets/zh-CN-FUF5V3SC-5UIL2T3T.js +10 -0
- package/dist/browser/prod/excalidraw-assets/zh-HK-OB4VW42C-3ID2CCZJ.js +1 -0
- package/dist/browser/prod/excalidraw-assets/zh-TW-5JPVKOM7-VUPJBABS.js +9 -0
- package/dist/browser/prod/index.css +1 -1
- package/dist/browser/prod/index.js +128 -1
- package/dist/dev/{en-R7FEFJGC.json → en-Q552WR7L.json} +1 -1
- package/dist/dev/index.css +38 -15
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +4575 -2598
- package/dist/dev/index.js.map +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.d.ts +4 -4
- package/dist/excalidraw/actions/actionAddToLibrary.js +4 -3
- package/dist/excalidraw/actions/actionAlign.d.ts +20 -20
- package/dist/excalidraw/actions/actionAlign.js +7 -6
- package/dist/excalidraw/actions/actionBoundText.d.ts +7 -7
- package/dist/excalidraw/actions/actionBoundText.js +8 -4
- package/dist/excalidraw/actions/actionCanvas.d.ts +49 -49
- package/dist/excalidraw/actions/actionCanvas.js +16 -13
- package/dist/excalidraw/actions/actionClipboard.d.ts +24 -24
- package/dist/excalidraw/actions/actionClipboard.js +14 -13
- package/dist/excalidraw/actions/actionDeleteSelected.d.ts +8 -8
- package/dist/excalidraw/actions/actionDeleteSelected.js +6 -3
- package/dist/excalidraw/actions/actionDistribute.d.ts +8 -8
- package/dist/excalidraw/actions/actionDistribute.js +3 -2
- package/dist/excalidraw/actions/actionDuplicateSelection.d.ts +5 -6
- package/dist/excalidraw/actions/actionDuplicateSelection.js +7 -3
- package/dist/excalidraw/actions/actionElementLock.d.ts +8 -8
- package/dist/excalidraw/actions/actionElementLock.js +3 -2
- package/dist/excalidraw/actions/actionExport.d.ts +36 -36
- package/dist/excalidraw/actions/actionExport.js +15 -11
- package/dist/excalidraw/actions/actionFinalize.d.ts +8 -8
- package/dist/excalidraw/actions/actionFinalize.js +9 -5
- package/dist/excalidraw/actions/actionFlip.d.ts +9 -9
- package/dist/excalidraw/actions/actionFlip.js +10 -9
- package/dist/excalidraw/actions/actionFrame.d.ts +14 -169
- package/dist/excalidraw/actions/actionFrame.js +7 -6
- package/dist/excalidraw/actions/actionGroup.d.ts +11 -321
- package/dist/excalidraw/actions/actionGroup.js +9 -11
- package/dist/excalidraw/actions/actionHistory.d.ts +3 -2
- package/dist/excalidraw/actions/actionHistory.js +27 -28
- package/dist/excalidraw/actions/actionLinearEditor.d.ts +2 -2
- package/dist/excalidraw/actions/actionLinearEditor.js +2 -1
- package/dist/excalidraw/actions/actionLink.d.ts +5 -5
- package/dist/excalidraw/actions/actionLink.js +2 -1
- package/dist/excalidraw/actions/actionMenu.d.ts +8 -8
- package/dist/excalidraw/actions/actionMenu.js +4 -3
- package/dist/excalidraw/actions/actionNavigate.d.ts +3 -3
- package/dist/excalidraw/actions/actionNavigate.js +3 -2
- package/dist/excalidraw/actions/actionProperties.d.ts +32 -32
- package/dist/excalidraw/actions/actionProperties.js +18 -13
- package/dist/excalidraw/actions/actionSelectAll.d.ts +4 -4
- package/dist/excalidraw/actions/actionSelectAll.js +2 -1
- package/dist/excalidraw/actions/actionStyles.d.ts +9 -12
- package/dist/excalidraw/actions/actionStyles.js +4 -3
- package/dist/excalidraw/actions/actionToggleGridMode.d.ts +6 -4
- package/dist/excalidraw/actions/actionToggleGridMode.js +6 -2
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
- package/dist/excalidraw/actions/actionToggleObjectsSnapMode.js +2 -1
- package/dist/excalidraw/actions/actionToggleStats.d.ts +4 -4
- package/dist/excalidraw/actions/actionToggleStats.js +2 -1
- package/dist/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
- package/dist/excalidraw/actions/actionToggleViewMode.js +2 -1
- package/dist/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
- package/dist/excalidraw/actions/actionToggleZenMode.js +2 -1
- package/dist/excalidraw/actions/actionZindex.d.ts +19 -19
- package/dist/excalidraw/actions/actionZindex.js +5 -4
- package/dist/excalidraw/actions/manager.d.ts +3 -3
- package/dist/excalidraw/actions/types.d.ts +4 -4
- package/dist/excalidraw/appState.d.ts +5 -5
- package/dist/excalidraw/change.d.ts +191 -0
- package/dist/excalidraw/change.js +894 -0
- package/dist/excalidraw/components/App.d.ts +22 -7
- package/dist/excalidraw/components/App.js +340 -130
- package/dist/excalidraw/components/CommandPalette/CommandPalette.js +1 -0
- package/dist/excalidraw/components/HelpDialog.js +1 -1
- package/dist/excalidraw/components/Sidebar/Sidebar.d.ts +2 -2
- package/dist/excalidraw/components/Stack.d.ts +2 -2
- package/dist/excalidraw/components/ToolButton.d.ts +1 -0
- package/dist/excalidraw/components/ToolButton.js +1 -1
- package/dist/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
- package/dist/excalidraw/components/canvases/InteractiveCanvas.js +1 -0
- package/dist/excalidraw/components/hyperlink/Hyperlink.js +3 -3
- package/dist/excalidraw/components/hyperlink/helpers.js +2 -3
- package/dist/excalidraw/components/icons.d.ts +1 -0
- package/dist/excalidraw/components/icons.js +1 -0
- package/dist/excalidraw/components/main-menu/DefaultItems.d.ts +1 -1
- package/dist/excalidraw/constants.d.ts +3 -3
- package/dist/excalidraw/constants.js +6 -3
- package/dist/excalidraw/data/reconcile.d.ts +6 -0
- package/dist/excalidraw/data/reconcile.js +49 -0
- package/dist/excalidraw/data/restore.d.ts +3 -3
- package/dist/excalidraw/data/restore.js +6 -7
- package/dist/excalidraw/data/transform.d.ts +1 -1
- package/dist/excalidraw/data/transform.js +4 -3
- package/dist/excalidraw/data/url.d.ts +1 -0
- package/dist/excalidraw/data/url.js +4 -1
- package/dist/excalidraw/element/binding.d.ts +64 -9
- package/dist/excalidraw/element/binding.js +634 -96
- package/dist/excalidraw/element/bounds.d.ts +0 -1
- package/dist/excalidraw/element/bounds.js +0 -3
- package/dist/excalidraw/element/collision.d.ts +14 -19
- package/dist/excalidraw/element/collision.js +36 -713
- package/dist/excalidraw/element/embeddable.d.ts +7 -4
- package/dist/excalidraw/element/embeddable.js +88 -27
- package/dist/excalidraw/element/index.d.ts +0 -1
- package/dist/excalidraw/element/index.js +0 -1
- package/dist/excalidraw/element/linearElementEditor.d.ts +11 -11
- package/dist/excalidraw/element/linearElementEditor.js +7 -5
- package/dist/excalidraw/element/mutateElement.d.ts +1 -2
- package/dist/excalidraw/element/newElement.d.ts +1 -1
- package/dist/excalidraw/element/newElement.js +2 -1
- package/dist/excalidraw/element/resizeElements.d.ts +1 -1
- package/dist/excalidraw/element/resizeElements.js +110 -86
- package/dist/excalidraw/element/resizeTest.d.ts +4 -4
- package/dist/excalidraw/element/resizeTest.js +55 -8
- package/dist/excalidraw/element/sizeHelpers.js +3 -0
- package/dist/excalidraw/element/textElement.d.ts +1 -2
- package/dist/excalidraw/element/textElement.js +5 -34
- package/dist/excalidraw/element/transformHandles.d.ts +22 -4
- package/dist/excalidraw/element/transformHandles.js +24 -3
- package/dist/excalidraw/element/typeChecks.d.ts +2 -2
- package/dist/excalidraw/element/types.d.ts +19 -6
- package/dist/excalidraw/errors.d.ts +3 -0
- package/dist/excalidraw/errors.js +3 -0
- package/dist/excalidraw/fractionalIndex.d.ts +40 -0
- package/dist/excalidraw/fractionalIndex.js +241 -0
- package/dist/excalidraw/frame.d.ts +1 -1
- package/dist/excalidraw/groups.d.ts +2 -0
- package/dist/excalidraw/groups.js +17 -0
- package/dist/excalidraw/history.d.ts +34 -46
- package/dist/excalidraw/history.js +100 -167
- package/dist/excalidraw/hooks/useEmitter.d.ts +2 -0
- package/dist/excalidraw/hooks/useEmitter.js +13 -0
- package/dist/excalidraw/index.d.ts +2 -0
- package/dist/excalidraw/index.js +2 -0
- package/dist/excalidraw/locales/en.json +1 -1
- package/dist/excalidraw/renderer/interactiveScene.d.ts +1 -1
- package/dist/excalidraw/renderer/interactiveScene.js +8 -7
- package/dist/excalidraw/renderer/staticScene.js +14 -3
- package/dist/excalidraw/renderer/staticSvgScene.js +10 -0
- package/dist/excalidraw/scene/Scene.d.ts +7 -6
- package/dist/excalidraw/scene/Scene.js +31 -16
- package/dist/excalidraw/scene/export.js +2 -1
- package/dist/excalidraw/scene/types.d.ts +2 -1
- package/dist/excalidraw/store.d.ts +99 -0
- package/dist/excalidraw/store.js +269 -0
- package/dist/excalidraw/types.d.ts +18 -4
- package/dist/excalidraw/utils.d.ts +6 -0
- package/dist/excalidraw/utils.js +7 -0
- package/dist/excalidraw/zindex.d.ts +2 -2
- package/dist/excalidraw/zindex.js +9 -13
- package/dist/prod/{en-R7FEFJGC.json → en-Q552WR7L.json} +1 -1
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +44 -44
- package/dist/utils/collision.d.ts +4 -0
- package/dist/utils/collision.js +48 -0
- package/dist/utils/geometry/geometry.d.ts +71 -0
- package/dist/utils/geometry/geometry.js +674 -0
- package/dist/utils/geometry/shape.d.ts +56 -0
- package/dist/utils/geometry/shape.js +168 -0
- package/history.ts +161 -216
- package/package.json +2 -1
- package/dist/browser/dev/excalidraw-assets-dev/chunk-GPOYIZPX.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-J5HRUYQR.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/chunk-UETNA2WX.js.map +0 -7
- package/dist/browser/dev/excalidraw-assets-dev/dist-Y7S5GOTG.js +0 -10
- package/dist/browser/dev/excalidraw-assets-dev/image-ZNQQXS62.css.map +0 -7
- package/dist/browser/prod/excalidraw-assets/chunk-EEN6AFMH.js +0 -269
- package/dist/browser/prod/excalidraw-assets/dist-7FHVDAZ2.js +0 -1
- package/dist/browser/prod/excalidraw-assets/flowDiagram-v2-3b53844e-CRHRHP7H.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-VXYNPVOG.js +0 -1
- package/dist/browser/prod/excalidraw-assets/image-WE6NA2G6.css +0 -1
- /package/dist/browser/dev/excalidraw-assets-dev/{blockDiagram-91b80b7a-RHODGCTM.js.map → blockDiagram-91b80b7a-NRABZKZA.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{c4Diagram-b2a90758-W7NCR7LR.js.map → c4Diagram-b2a90758-56M32CJD.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-TKRIVTWP.js.map → chunk-5EDB2FTV.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-52OGG53V.js.map → chunk-6VTJEXQH.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-GF7VCOUM.js.map → chunk-C4OL7SRI.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-BESQLMCW.js.map → chunk-E47I6Q7O.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-5747M6KP.js.map → chunk-OH2YDYHX.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-GCA4S2OA.js.map → chunk-RTA6DTUV.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-DQOPSCYA.js.map → chunk-TTH3BTHQ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-B2MHJWXZ.js.map → chunk-U4N7TEPH.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-QFS4M5OJ.js.map → chunk-V3PA4IDR.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-SLLUETBM.js.map → chunk-WFT6ZJE6.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-PPHFJLL7.js.map → chunk-XZKEYTKS.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{chunk-USLWOHUZ.js.map → chunk-YC6VTXEO.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{classDiagram-30eddba6-GJGBT4TV.js.map → classDiagram-30eddba6-EZJVINS6.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{classDiagram-v2-f2df5561-LYWTIPJA.js.map → classDiagram-v2-f2df5561-XSUIN44A.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{directory-open-01563666-UREMLRIT.js.map → directory-open-01563666-KOK2HSB6.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{directory-open-4ed118d0-UN3BUDZZ.js.map → directory-open-4ed118d0-P3Q3CLF3.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{dist-Y7S5GOTG.js.map → dist-O6HOTHQF.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{en-UW5C5KGW.js.map → en-PSBMWL4S.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{erDiagram-47591fe2-Z7U2XW2Y.js.map → erDiagram-47591fe2-U7FLWOG3.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{file-open-002ab408-4QG336MG.js.map → file-open-002ab408-EQEHGU2J.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{file-open-7c801643-3QI4ICCL.js.map → file-open-7c801643-QQT6O7P5.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{file-save-3189631c-TNNERCWV.js.map → file-save-3189631c-YXX2C7C6.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{file-save-745eba88-JFMH565P.js.map → file-save-745eba88-7G554KTZ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{flowDiagram-5540d9b9-PARVG263.js.map → flowDiagram-5540d9b9-F2VP4JAA.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{flowDiagram-v2-3b53844e-ZJOPVRMB.js.map → flowDiagram-v2-3b53844e-2WQZZRND.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{flowchart-elk-definition-5fe447d6-ULPNBSZX.js.map → flowchart-elk-definition-5fe447d6-IW6O2F6C.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{ganttDiagram-9a3bba1f-ESSYVTJ4.js.map → ganttDiagram-9a3bba1f-B5RH7ZAO.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{gitGraphDiagram-96e6b4ee-6V6VVNNP.js.map → gitGraphDiagram-96e6b4ee-INGQRNLZ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-3LTGFHLF.js.map → image-GMAHLVER.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{image-blob-reduce.esm-KTX27DAY.js.map → image-blob-reduce.esm-OX75MRP3.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{infoDiagram-bcd20f53-I22FLFX3.js.map → infoDiagram-bcd20f53-43FMAUOR.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{journeyDiagram-4fe6b3dc-WAO6F52C.js.map → journeyDiagram-4fe6b3dc-KFVOUX4I.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{katex-NWA2YFOP.js.map → katex-A3GRORPB.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{mindmap-definition-f354de21-K74IKX4Y.js.map → mindmap-definition-f354de21-D7S3CRQ4.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{pica-3TH2EGXR.js.map → pica-ZAD7MTGA.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{pieDiagram-79897490-DOB2LVE5.js.map → pieDiagram-79897490-OON2CRZ5.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{quadrantDiagram-62f64e94-MJV2X7WI.js.map → quadrantDiagram-62f64e94-5APTNVVS.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{requirementDiagram-05bf5f74-H4YM3XN7.js.map → requirementDiagram-05bf5f74-FM7WZVKU.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{roundRect-4S3QV2NZ.js.map → roundRect-AYYHVX5X.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{sankeyDiagram-97764748-7X74ABAN.js.map → sankeyDiagram-97764748-5HLEFFGY.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{sequenceDiagram-acc0e65c-PPDIJFQP.js.map → sequenceDiagram-acc0e65c-4ZRSNGPV.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{stateDiagram-0ff1cf1a-JVBR7N35.js.map → stateDiagram-0ff1cf1a-OLTPYRPP.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{stateDiagram-v2-9a9d610d-QYAJLQJH.js.map → stateDiagram-v2-9a9d610d-N3XOTAEE.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{timeline-definition-fea2a41d-GL7U3WDB.js.map → timeline-definition-fea2a41d-5PDFIYJQ.js.map} +0 -0
- /package/dist/browser/dev/excalidraw-assets-dev/{xychartDiagram-ab372869-4U4JE4TW.js.map → xychartDiagram-ab372869-VIWBP45Y.js.map} +0 -0
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { distance2d } from "../../excalidraw/math";
|
|
2
|
+
const DEFAULT_THRESHOLD = 10e-5;
|
|
3
|
+
/**
|
|
4
|
+
* utils
|
|
5
|
+
*/
|
|
6
|
+
// the two vectors are ao and bo
|
|
7
|
+
export const cross = (a, b, o) => {
|
|
8
|
+
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
9
|
+
};
|
|
10
|
+
export const isClosed = (polygon) => {
|
|
11
|
+
const first = polygon[0];
|
|
12
|
+
const last = polygon[polygon.length - 1];
|
|
13
|
+
return first[0] === last[0] && first[1] === last[1];
|
|
14
|
+
};
|
|
15
|
+
export const close = (polygon) => {
|
|
16
|
+
return isClosed(polygon) ? polygon : [...polygon, polygon[0]];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* angles
|
|
20
|
+
*/
|
|
21
|
+
// convert radians to degress
|
|
22
|
+
export const angleToDegrees = (angle) => {
|
|
23
|
+
return (angle * 180) / Math.PI;
|
|
24
|
+
};
|
|
25
|
+
// convert degrees to radians
|
|
26
|
+
export const angleToRadians = (angle) => {
|
|
27
|
+
return (angle / 180) * Math.PI;
|
|
28
|
+
};
|
|
29
|
+
// return the angle of reflection given an angle of incidence and a surface angle in degrees
|
|
30
|
+
export const angleReflect = (incidenceAngle, surfaceAngle) => {
|
|
31
|
+
const a = surfaceAngle * 2 - incidenceAngle;
|
|
32
|
+
return a >= 360 ? a - 360 : a < 0 ? a + 360 : a;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* points
|
|
36
|
+
*/
|
|
37
|
+
const rotate = (point, angle) => {
|
|
38
|
+
return [
|
|
39
|
+
point[0] * Math.cos(angle) - point[1] * Math.sin(angle),
|
|
40
|
+
point[0] * Math.sin(angle) + point[1] * Math.cos(angle),
|
|
41
|
+
];
|
|
42
|
+
};
|
|
43
|
+
const isOrigin = (point) => {
|
|
44
|
+
return point[0] === 0 && point[1] === 0;
|
|
45
|
+
};
|
|
46
|
+
// rotate a given point about a given origin at the given angle
|
|
47
|
+
export const pointRotate = (point, angle, origin) => {
|
|
48
|
+
const r = angleToRadians(angle);
|
|
49
|
+
if (!origin || isOrigin(origin)) {
|
|
50
|
+
return rotate(point, r);
|
|
51
|
+
}
|
|
52
|
+
return rotate(point.map((c, i) => c - origin[i]), r).map((c, i) => c + origin[i]);
|
|
53
|
+
};
|
|
54
|
+
// translate a point by an angle (in degrees) and distance
|
|
55
|
+
export const pointTranslate = (point, angle = 0, distance = 0) => {
|
|
56
|
+
const r = angleToRadians(angle);
|
|
57
|
+
return [
|
|
58
|
+
point[0] + distance * Math.cos(r),
|
|
59
|
+
point[1] + distance * Math.sin(r),
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
export const pointInverse = (point) => {
|
|
63
|
+
return [-point[0], -point[1]];
|
|
64
|
+
};
|
|
65
|
+
export const pointAdd = (pointA, pointB) => {
|
|
66
|
+
return [pointA[0] + pointB[0], pointA[1] + pointB[1]];
|
|
67
|
+
};
|
|
68
|
+
export const distanceToPoint = (p1, p2) => {
|
|
69
|
+
return distance2d(...p1, ...p2);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* lines
|
|
73
|
+
*/
|
|
74
|
+
// return the angle of a line, in degrees
|
|
75
|
+
export const lineAngle = (line) => {
|
|
76
|
+
return angleToDegrees(Math.atan2(line[1][1] - line[0][1], line[1][0] - line[0][0]));
|
|
77
|
+
};
|
|
78
|
+
// get the distance between the endpoints of a line segment
|
|
79
|
+
export const lineLength = (line) => {
|
|
80
|
+
return Math.sqrt(Math.pow(line[1][0] - line[0][0], 2) + Math.pow(line[1][1] - line[0][1], 2));
|
|
81
|
+
};
|
|
82
|
+
// get the midpoint of a line segment
|
|
83
|
+
export const lineMidpoint = (line) => {
|
|
84
|
+
return [
|
|
85
|
+
(line[0][0] + line[1][0]) / 2,
|
|
86
|
+
(line[0][1] + line[1][1]) / 2,
|
|
87
|
+
];
|
|
88
|
+
};
|
|
89
|
+
// return the coordinates resulting from rotating the given line about an origin by an angle in degrees
|
|
90
|
+
// note that when the origin is not given, the midpoint of the given line is used as the origin
|
|
91
|
+
export const lineRotate = (line, angle, origin) => {
|
|
92
|
+
return line.map((point) => pointRotate(point, angle, origin || lineMidpoint(line)));
|
|
93
|
+
};
|
|
94
|
+
// returns the coordinates resulting from translating a line by an angle in degrees and a distance.
|
|
95
|
+
export const lineTranslate = (line, angle, distance) => {
|
|
96
|
+
return line.map((point) => pointTranslate(point, angle, distance));
|
|
97
|
+
};
|
|
98
|
+
export const lineInterpolate = (line, clamp = false) => {
|
|
99
|
+
const [[x1, y1], [x2, y2]] = line;
|
|
100
|
+
return (t) => {
|
|
101
|
+
const t0 = clamp ? (t < 0 ? 0 : t > 1 ? 1 : t) : t;
|
|
102
|
+
return [(x2 - x1) * t0 + x1, (y2 - y1) * t0 + y1];
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* curves
|
|
107
|
+
*/
|
|
108
|
+
function clone(p) {
|
|
109
|
+
return [...p];
|
|
110
|
+
}
|
|
111
|
+
export const curveToBezier = (pointsIn, curveTightness = 0) => {
|
|
112
|
+
const len = pointsIn.length;
|
|
113
|
+
if (len < 3) {
|
|
114
|
+
throw new Error("A curve must have at least three points.");
|
|
115
|
+
}
|
|
116
|
+
const out = [];
|
|
117
|
+
if (len === 3) {
|
|
118
|
+
out.push(clone(pointsIn[0]), clone(pointsIn[1]), clone(pointsIn[2]), clone(pointsIn[2]));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const points = [];
|
|
122
|
+
points.push(pointsIn[0], pointsIn[0]);
|
|
123
|
+
for (let i = 1; i < pointsIn.length; i++) {
|
|
124
|
+
points.push(pointsIn[i]);
|
|
125
|
+
if (i === pointsIn.length - 1) {
|
|
126
|
+
points.push(pointsIn[i]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const b = [];
|
|
130
|
+
const s = 1 - curveTightness;
|
|
131
|
+
out.push(clone(points[0]));
|
|
132
|
+
for (let i = 1; i + 2 < points.length; i++) {
|
|
133
|
+
const cachedVertArray = points[i];
|
|
134
|
+
b[0] = [cachedVertArray[0], cachedVertArray[1]];
|
|
135
|
+
b[1] = [
|
|
136
|
+
cachedVertArray[0] + (s * points[i + 1][0] - s * points[i - 1][0]) / 6,
|
|
137
|
+
cachedVertArray[1] + (s * points[i + 1][1] - s * points[i - 1][1]) / 6,
|
|
138
|
+
];
|
|
139
|
+
b[2] = [
|
|
140
|
+
points[i + 1][0] + (s * points[i][0] - s * points[i + 2][0]) / 6,
|
|
141
|
+
points[i + 1][1] + (s * points[i][1] - s * points[i + 2][1]) / 6,
|
|
142
|
+
];
|
|
143
|
+
b[3] = [points[i + 1][0], points[i + 1][1]];
|
|
144
|
+
out.push(b[1], b[2], b[3]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
};
|
|
149
|
+
export const curveRotate = (curve, angle, origin) => {
|
|
150
|
+
return curve.map((p) => pointRotate(p, angle, origin));
|
|
151
|
+
};
|
|
152
|
+
export const cubicBezierPoint = (t, controlPoints) => {
|
|
153
|
+
const [p0, p1, p2, p3] = controlPoints;
|
|
154
|
+
const x = Math.pow(1 - t, 3) * p0[0] +
|
|
155
|
+
3 * Math.pow(1 - t, 2) * t * p1[0] +
|
|
156
|
+
3 * (1 - t) * Math.pow(t, 2) * p2[0] +
|
|
157
|
+
Math.pow(t, 3) * p3[0];
|
|
158
|
+
const y = Math.pow(1 - t, 3) * p0[1] +
|
|
159
|
+
3 * Math.pow(1 - t, 2) * t * p1[1] +
|
|
160
|
+
3 * (1 - t) * Math.pow(t, 2) * p2[1] +
|
|
161
|
+
Math.pow(t, 3) * p3[1];
|
|
162
|
+
return [x, y];
|
|
163
|
+
};
|
|
164
|
+
const solveCubicEquation = (a, b, c, d) => {
|
|
165
|
+
// This function solves the cubic equation ax^3 + bx^2 + cx + d = 0
|
|
166
|
+
const roots = [];
|
|
167
|
+
const discriminant = 18 * a * b * c * d -
|
|
168
|
+
4 * Math.pow(b, 3) * d +
|
|
169
|
+
Math.pow(b, 2) * Math.pow(c, 2) -
|
|
170
|
+
4 * a * Math.pow(c, 3) -
|
|
171
|
+
27 * Math.pow(a, 2) * Math.pow(d, 2);
|
|
172
|
+
if (discriminant >= 0) {
|
|
173
|
+
const C = Math.cbrt((discriminant + Math.sqrt(discriminant)) / 2);
|
|
174
|
+
const D = Math.cbrt((discriminant - Math.sqrt(discriminant)) / 2);
|
|
175
|
+
const root1 = (-b - C - D) / (3 * a);
|
|
176
|
+
const root2 = (-b + (C + D) / 2) / (3 * a);
|
|
177
|
+
const root3 = (-b + (C + D) / 2) / (3 * a);
|
|
178
|
+
roots.push(root1, root2, root3);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const realPart = -b / (3 * a);
|
|
182
|
+
const root1 = 2 * Math.sqrt(-b / (3 * a)) * Math.cos(Math.acos(realPart) / 3);
|
|
183
|
+
const root2 = 2 *
|
|
184
|
+
Math.sqrt(-b / (3 * a)) *
|
|
185
|
+
Math.cos((Math.acos(realPart) + 2 * Math.PI) / 3);
|
|
186
|
+
const root3 = 2 *
|
|
187
|
+
Math.sqrt(-b / (3 * a)) *
|
|
188
|
+
Math.cos((Math.acos(realPart) + 4 * Math.PI) / 3);
|
|
189
|
+
roots.push(root1, root2, root3);
|
|
190
|
+
}
|
|
191
|
+
return roots;
|
|
192
|
+
};
|
|
193
|
+
const findClosestParameter = (point, controlPoints) => {
|
|
194
|
+
// This function finds the parameter t that minimizes the distance between the point
|
|
195
|
+
// and any point on the cubic Bezier curve.
|
|
196
|
+
const [p0, p1, p2, p3] = controlPoints;
|
|
197
|
+
// Use the direct formula to find the parameter t
|
|
198
|
+
const a = p3[0] - 3 * p2[0] + 3 * p1[0] - p0[0];
|
|
199
|
+
const b = 3 * p2[0] - 6 * p1[0] + 3 * p0[0];
|
|
200
|
+
const c = 3 * p1[0] - 3 * p0[0];
|
|
201
|
+
const d = p0[0] - point[0];
|
|
202
|
+
const rootsX = solveCubicEquation(a, b, c, d);
|
|
203
|
+
// Do the same for the y-coordinate
|
|
204
|
+
const e = p3[1] - 3 * p2[1] + 3 * p1[1] - p0[1];
|
|
205
|
+
const f = 3 * p2[1] - 6 * p1[1] + 3 * p0[1];
|
|
206
|
+
const g = 3 * p1[1] - 3 * p0[1];
|
|
207
|
+
const h = p0[1] - point[1];
|
|
208
|
+
const rootsY = solveCubicEquation(e, f, g, h);
|
|
209
|
+
// Select the real root that is between 0 and 1 (inclusive)
|
|
210
|
+
const validRootsX = rootsX.filter((root) => root >= 0 && root <= 1);
|
|
211
|
+
const validRootsY = rootsY.filter((root) => root >= 0 && root <= 1);
|
|
212
|
+
if (validRootsX.length === 0 || validRootsY.length === 0) {
|
|
213
|
+
// No valid roots found, use the midpoint as a fallback
|
|
214
|
+
return 0.5;
|
|
215
|
+
}
|
|
216
|
+
// Choose the parameter t that minimizes the distance
|
|
217
|
+
let minDistance = Infinity;
|
|
218
|
+
let closestT = 0;
|
|
219
|
+
for (const rootX of validRootsX) {
|
|
220
|
+
for (const rootY of validRootsY) {
|
|
221
|
+
const distance = Math.sqrt((rootX - point[0]) ** 2 + (rootY - point[1]) ** 2);
|
|
222
|
+
if (distance < minDistance) {
|
|
223
|
+
minDistance = distance;
|
|
224
|
+
closestT = (rootX + rootY) / 2; // Use the average for a smoother result
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return closestT;
|
|
229
|
+
};
|
|
230
|
+
export const cubicBezierDistance = (point, controlPoints) => {
|
|
231
|
+
// Calculate the closest point on the Bezier curve to the given point
|
|
232
|
+
const t = findClosestParameter(point, controlPoints);
|
|
233
|
+
// Calculate the coordinates of the closest point on the curve
|
|
234
|
+
const [closestX, closestY] = cubicBezierPoint(t, controlPoints);
|
|
235
|
+
// Calculate the distance between the given point and the closest point on the curve
|
|
236
|
+
const distance = Math.sqrt((point[0] - closestX) ** 2 + (point[1] - closestY) ** 2);
|
|
237
|
+
return distance;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* polygons
|
|
241
|
+
*/
|
|
242
|
+
export const polygonRotate = (polygon, angle, origin) => {
|
|
243
|
+
return polygon.map((p) => pointRotate(p, angle, origin));
|
|
244
|
+
};
|
|
245
|
+
export const polygonBounds = (polygon) => {
|
|
246
|
+
let xMin = Infinity;
|
|
247
|
+
let xMax = -Infinity;
|
|
248
|
+
let yMin = Infinity;
|
|
249
|
+
let yMax = -Infinity;
|
|
250
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
251
|
+
const p = polygon[i];
|
|
252
|
+
const x = p[0];
|
|
253
|
+
const y = p[1];
|
|
254
|
+
if (x != null && isFinite(x) && y != null && isFinite(y)) {
|
|
255
|
+
if (x < xMin) {
|
|
256
|
+
xMin = x;
|
|
257
|
+
}
|
|
258
|
+
if (x > xMax) {
|
|
259
|
+
xMax = x;
|
|
260
|
+
}
|
|
261
|
+
if (y < yMin) {
|
|
262
|
+
yMin = y;
|
|
263
|
+
}
|
|
264
|
+
if (y > yMax) {
|
|
265
|
+
yMax = y;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return [
|
|
270
|
+
[xMin, yMin],
|
|
271
|
+
[xMax, yMax],
|
|
272
|
+
];
|
|
273
|
+
};
|
|
274
|
+
export const polygonCentroid = (vertices) => {
|
|
275
|
+
let a = 0;
|
|
276
|
+
let x = 0;
|
|
277
|
+
let y = 0;
|
|
278
|
+
const l = vertices.length;
|
|
279
|
+
for (let i = 0; i < l; i++) {
|
|
280
|
+
const s = i === l - 1 ? 0 : i + 1;
|
|
281
|
+
const v0 = vertices[i];
|
|
282
|
+
const v1 = vertices[s];
|
|
283
|
+
const f = v0[0] * v1[1] - v1[0] * v0[1];
|
|
284
|
+
a += f;
|
|
285
|
+
x += (v0[0] + v1[0]) * f;
|
|
286
|
+
y += (v0[1] + v1[1]) * f;
|
|
287
|
+
}
|
|
288
|
+
const d = a * 3;
|
|
289
|
+
return [x / d, y / d];
|
|
290
|
+
};
|
|
291
|
+
export const polygonScale = (polygon, scale, origin) => {
|
|
292
|
+
if (!origin) {
|
|
293
|
+
origin = polygonCentroid(polygon);
|
|
294
|
+
}
|
|
295
|
+
const p = [];
|
|
296
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
297
|
+
const v = polygon[i];
|
|
298
|
+
const d = lineLength([origin, v]);
|
|
299
|
+
const a = lineAngle([origin, v]);
|
|
300
|
+
p[i] = pointTranslate(origin, a, d * scale);
|
|
301
|
+
}
|
|
302
|
+
return p;
|
|
303
|
+
};
|
|
304
|
+
export const polygonScaleX = (polygon, scale, origin) => {
|
|
305
|
+
if (!origin) {
|
|
306
|
+
origin = polygonCentroid(polygon);
|
|
307
|
+
}
|
|
308
|
+
const p = [];
|
|
309
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
310
|
+
const v = polygon[i];
|
|
311
|
+
const d = lineLength([origin, v]);
|
|
312
|
+
const a = lineAngle([origin, v]);
|
|
313
|
+
const t = pointTranslate(origin, a, d * scale);
|
|
314
|
+
p[i] = [t[0], v[1]];
|
|
315
|
+
}
|
|
316
|
+
return p;
|
|
317
|
+
};
|
|
318
|
+
export const polygonScaleY = (polygon, scale, origin) => {
|
|
319
|
+
if (!origin) {
|
|
320
|
+
origin = polygonCentroid(polygon);
|
|
321
|
+
}
|
|
322
|
+
const p = [];
|
|
323
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
324
|
+
const v = polygon[i];
|
|
325
|
+
const d = lineLength([origin, v]);
|
|
326
|
+
const a = lineAngle([origin, v]);
|
|
327
|
+
const t = pointTranslate(origin, a, d * scale);
|
|
328
|
+
p[i] = [v[0], t[1]];
|
|
329
|
+
}
|
|
330
|
+
return p;
|
|
331
|
+
};
|
|
332
|
+
export const polygonReflectX = (polygon, reflectFactor = 1) => {
|
|
333
|
+
const [[min], [max]] = polygonBounds(polygon);
|
|
334
|
+
const p = [];
|
|
335
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
336
|
+
const [x, y] = polygon[i];
|
|
337
|
+
const r = [min + max - x, y];
|
|
338
|
+
if (reflectFactor === 0) {
|
|
339
|
+
p[i] = [x, y];
|
|
340
|
+
}
|
|
341
|
+
else if (reflectFactor === 1) {
|
|
342
|
+
p[i] = r;
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const t = lineInterpolate([[x, y], r]);
|
|
346
|
+
p[i] = t(Math.max(Math.min(reflectFactor, 1), 0));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return p;
|
|
350
|
+
};
|
|
351
|
+
export const polygonReflectY = (polygon, reflectFactor = 1) => {
|
|
352
|
+
const [[, min], [, max]] = polygonBounds(polygon);
|
|
353
|
+
const p = [];
|
|
354
|
+
for (let i = 0, l = polygon.length; i < l; i++) {
|
|
355
|
+
const [x, y] = polygon[i];
|
|
356
|
+
const r = [x, min + max - y];
|
|
357
|
+
if (reflectFactor === 0) {
|
|
358
|
+
p[i] = [x, y];
|
|
359
|
+
}
|
|
360
|
+
else if (reflectFactor === 1) {
|
|
361
|
+
p[i] = r;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
const t = lineInterpolate([[x, y], r]);
|
|
365
|
+
p[i] = t(Math.max(Math.min(reflectFactor, 1), 0));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return p;
|
|
369
|
+
};
|
|
370
|
+
export const polygonTranslate = (polygon, angle, distance) => {
|
|
371
|
+
return polygon.map((p) => pointTranslate(p, angle, distance));
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* ellipses
|
|
375
|
+
*/
|
|
376
|
+
export const ellipseAxes = (ellipse) => {
|
|
377
|
+
const widthGreaterThanHeight = ellipse.halfWidth > ellipse.halfHeight;
|
|
378
|
+
const majorAxis = widthGreaterThanHeight
|
|
379
|
+
? ellipse.halfWidth * 2
|
|
380
|
+
: ellipse.halfHeight * 2;
|
|
381
|
+
const minorAxis = widthGreaterThanHeight
|
|
382
|
+
? ellipse.halfHeight * 2
|
|
383
|
+
: ellipse.halfWidth * 2;
|
|
384
|
+
return {
|
|
385
|
+
majorAxis,
|
|
386
|
+
minorAxis,
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
export const ellipseFocusToCenter = (ellipse) => {
|
|
390
|
+
const { majorAxis, minorAxis } = ellipseAxes(ellipse);
|
|
391
|
+
return Math.sqrt(majorAxis ** 2 - minorAxis ** 2);
|
|
392
|
+
};
|
|
393
|
+
export const ellipseExtremes = (ellipse) => {
|
|
394
|
+
const { center, angle } = ellipse;
|
|
395
|
+
const { majorAxis, minorAxis } = ellipseAxes(ellipse);
|
|
396
|
+
const cos = Math.cos(angle);
|
|
397
|
+
const sin = Math.sin(angle);
|
|
398
|
+
const sqSum = majorAxis ** 2 + minorAxis ** 2;
|
|
399
|
+
const sqDiff = (majorAxis ** 2 - minorAxis ** 2) * Math.cos(2 * angle);
|
|
400
|
+
const yMax = Math.sqrt((sqSum - sqDiff) / 2);
|
|
401
|
+
const xAtYMax = (yMax * sqSum * sin * cos) /
|
|
402
|
+
(majorAxis ** 2 * sin ** 2 + minorAxis ** 2 * cos ** 2);
|
|
403
|
+
const xMax = Math.sqrt((sqSum + sqDiff) / 2);
|
|
404
|
+
const yAtXMax = (xMax * sqSum * sin * cos) /
|
|
405
|
+
(majorAxis ** 2 * cos ** 2 + minorAxis ** 2 * sin ** 2);
|
|
406
|
+
return [
|
|
407
|
+
pointAdd([xAtYMax, yMax], center),
|
|
408
|
+
pointAdd(pointInverse([xAtYMax, yMax]), center),
|
|
409
|
+
pointAdd([xMax, yAtXMax], center),
|
|
410
|
+
pointAdd([xMax, yAtXMax], center),
|
|
411
|
+
];
|
|
412
|
+
};
|
|
413
|
+
export const pointRelativeToCenter = (point, center, angle) => {
|
|
414
|
+
const translated = pointAdd(point, pointInverse(center));
|
|
415
|
+
const rotated = pointRotate(translated, -angleToDegrees(angle));
|
|
416
|
+
return rotated;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* relationships
|
|
420
|
+
*/
|
|
421
|
+
const topPointFirst = (line) => {
|
|
422
|
+
return line[1][1] > line[0][1] ? line : [line[1], line[0]];
|
|
423
|
+
};
|
|
424
|
+
export const pointLeftofLine = (point, line) => {
|
|
425
|
+
const t = topPointFirst(line);
|
|
426
|
+
return cross(point, t[1], t[0]) < 0;
|
|
427
|
+
};
|
|
428
|
+
export const pointRightofLine = (point, line) => {
|
|
429
|
+
const t = topPointFirst(line);
|
|
430
|
+
return cross(point, t[1], t[0]) > 0;
|
|
431
|
+
};
|
|
432
|
+
export const distanceToSegment = (point, line) => {
|
|
433
|
+
const [x, y] = point;
|
|
434
|
+
const [[x1, y1], [x2, y2]] = line;
|
|
435
|
+
const A = x - x1;
|
|
436
|
+
const B = y - y1;
|
|
437
|
+
const C = x2 - x1;
|
|
438
|
+
const D = y2 - y1;
|
|
439
|
+
const dot = A * C + B * D;
|
|
440
|
+
const len_sq = C * C + D * D;
|
|
441
|
+
let param = -1;
|
|
442
|
+
if (len_sq !== 0) {
|
|
443
|
+
param = dot / len_sq;
|
|
444
|
+
}
|
|
445
|
+
let xx;
|
|
446
|
+
let yy;
|
|
447
|
+
if (param < 0) {
|
|
448
|
+
xx = x1;
|
|
449
|
+
yy = y1;
|
|
450
|
+
}
|
|
451
|
+
else if (param > 1) {
|
|
452
|
+
xx = x2;
|
|
453
|
+
yy = y2;
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
xx = x1 + param * C;
|
|
457
|
+
yy = y1 + param * D;
|
|
458
|
+
}
|
|
459
|
+
const dx = x - xx;
|
|
460
|
+
const dy = y - yy;
|
|
461
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
462
|
+
};
|
|
463
|
+
export const pointOnLine = (point, line, threshold = DEFAULT_THRESHOLD) => {
|
|
464
|
+
const distance = distanceToSegment(point, line);
|
|
465
|
+
if (distance === 0) {
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
return distance < threshold;
|
|
469
|
+
};
|
|
470
|
+
export const pointOnPolyline = (point, polyline, threshold = DEFAULT_THRESHOLD) => {
|
|
471
|
+
return polyline.some((line) => pointOnLine(point, line, threshold));
|
|
472
|
+
};
|
|
473
|
+
export const lineIntersectsLine = (lineA, lineB) => {
|
|
474
|
+
const [[a0x, a0y], [a1x, a1y]] = lineA;
|
|
475
|
+
const [[b0x, b0y], [b1x, b1y]] = lineB;
|
|
476
|
+
// shared points
|
|
477
|
+
if (a0x === b0x && a0y === b0y) {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
if (a1x === b1x && a1y === b1y) {
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
// point on line
|
|
484
|
+
if (pointOnLine(lineA[0], lineB) || pointOnLine(lineA[1], lineB)) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
if (pointOnLine(lineB[0], lineA) || pointOnLine(lineB[1], lineA)) {
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
const denom = (b1y - b0y) * (a1x - a0x) - (b1x - b0x) * (a1y - a0y);
|
|
491
|
+
if (denom === 0) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
const deltaY = a0y - b0y;
|
|
495
|
+
const deltaX = a0x - b0x;
|
|
496
|
+
const numer0 = (b1x - b0x) * deltaY - (b1y - b0y) * deltaX;
|
|
497
|
+
const numer1 = (a1x - a0x) * deltaY - (a1y - a0y) * deltaX;
|
|
498
|
+
const quotA = numer0 / denom;
|
|
499
|
+
const quotB = numer1 / denom;
|
|
500
|
+
return quotA > 0 && quotA < 1 && quotB > 0 && quotB < 1;
|
|
501
|
+
};
|
|
502
|
+
export const lineIntersectsPolygon = (line, polygon) => {
|
|
503
|
+
let intersects = false;
|
|
504
|
+
const closed = close(polygon);
|
|
505
|
+
for (let i = 0, l = closed.length - 1; i < l; i++) {
|
|
506
|
+
const v0 = closed[i];
|
|
507
|
+
const v1 = closed[i + 1];
|
|
508
|
+
if (lineIntersectsLine(line, [v0, v1]) ||
|
|
509
|
+
(pointOnLine(v0, line) && pointOnLine(v1, line))) {
|
|
510
|
+
intersects = true;
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return intersects;
|
|
515
|
+
};
|
|
516
|
+
export const pointInBezierEquation = (p0, p1, p2, p3, [mx, my], lineThreshold) => {
|
|
517
|
+
// B(t) = p0 * (1-t)^3 + 3p1 * t * (1-t)^2 + 3p2 * t^2 * (1-t) + p3 * t^3
|
|
518
|
+
const equation = (t, idx) => Math.pow(1 - t, 3) * p3[idx] +
|
|
519
|
+
3 * t * Math.pow(1 - t, 2) * p2[idx] +
|
|
520
|
+
3 * Math.pow(t, 2) * (1 - t) * p1[idx] +
|
|
521
|
+
p0[idx] * Math.pow(t, 3);
|
|
522
|
+
const lineSegmentPoints = [];
|
|
523
|
+
let t = 0;
|
|
524
|
+
while (t <= 1.0) {
|
|
525
|
+
const tx = equation(t, 0);
|
|
526
|
+
const ty = equation(t, 1);
|
|
527
|
+
const diff = Math.sqrt(Math.pow(tx - mx, 2) + Math.pow(ty - my, 2));
|
|
528
|
+
if (diff < lineThreshold) {
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
lineSegmentPoints.push([tx, ty]);
|
|
532
|
+
t += 0.1;
|
|
533
|
+
}
|
|
534
|
+
// check the distance from line segments to the given point
|
|
535
|
+
return false;
|
|
536
|
+
};
|
|
537
|
+
export const cubicBezierEquation = (curve) => {
|
|
538
|
+
const [p0, p1, p2, p3] = curve;
|
|
539
|
+
// B(t) = p0 * (1-t)^3 + 3p1 * t * (1-t)^2 + 3p2 * t^2 * (1-t) + p3 * t^3
|
|
540
|
+
return (t, idx) => Math.pow(1 - t, 3) * p3[idx] +
|
|
541
|
+
3 * t * Math.pow(1 - t, 2) * p2[idx] +
|
|
542
|
+
3 * Math.pow(t, 2) * (1 - t) * p1[idx] +
|
|
543
|
+
p0[idx] * Math.pow(t, 3);
|
|
544
|
+
};
|
|
545
|
+
export const polyLineFromCurve = (curve, segments = 10) => {
|
|
546
|
+
const equation = cubicBezierEquation(curve);
|
|
547
|
+
let startingPoint = [equation(0, 0), equation(0, 1)];
|
|
548
|
+
const lineSegments = [];
|
|
549
|
+
let t = 0;
|
|
550
|
+
const increment = 1 / segments;
|
|
551
|
+
for (let i = 0; i < segments; i++) {
|
|
552
|
+
t += increment;
|
|
553
|
+
if (t <= 1) {
|
|
554
|
+
const nextPoint = [equation(t, 0), equation(t, 1)];
|
|
555
|
+
lineSegments.push([startingPoint, nextPoint]);
|
|
556
|
+
startingPoint = nextPoint;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return lineSegments;
|
|
560
|
+
};
|
|
561
|
+
export const pointOnCurve = (point, curve, threshold = DEFAULT_THRESHOLD) => {
|
|
562
|
+
return pointOnPolyline(point, polyLineFromCurve(curve), threshold);
|
|
563
|
+
};
|
|
564
|
+
export const pointOnPolycurve = (point, polycurve, threshold = DEFAULT_THRESHOLD) => {
|
|
565
|
+
return polycurve.some((curve) => pointOnCurve(point, curve, threshold));
|
|
566
|
+
};
|
|
567
|
+
export const pointInPolygon = (point, polygon) => {
|
|
568
|
+
const x = point[0];
|
|
569
|
+
const y = point[1];
|
|
570
|
+
let inside = false;
|
|
571
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
572
|
+
const xi = polygon[i][0];
|
|
573
|
+
const yi = polygon[i][1];
|
|
574
|
+
const xj = polygon[j][0];
|
|
575
|
+
const yj = polygon[j][1];
|
|
576
|
+
if (((yi > y && yj <= y) || (yi <= y && yj > y)) &&
|
|
577
|
+
x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {
|
|
578
|
+
inside = !inside;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return inside;
|
|
582
|
+
};
|
|
583
|
+
export const pointOnPolygon = (point, polygon, threshold = DEFAULT_THRESHOLD) => {
|
|
584
|
+
let on = false;
|
|
585
|
+
const closed = close(polygon);
|
|
586
|
+
for (let i = 0, l = closed.length - 1; i < l; i++) {
|
|
587
|
+
if (pointOnLine(point, [closed[i], closed[i + 1]], threshold)) {
|
|
588
|
+
on = true;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return on;
|
|
593
|
+
};
|
|
594
|
+
export const polygonInPolygon = (polygonA, polygonB) => {
|
|
595
|
+
let inside = true;
|
|
596
|
+
const closed = close(polygonA);
|
|
597
|
+
for (let i = 0, l = closed.length - 1; i < l; i++) {
|
|
598
|
+
const v0 = closed[i];
|
|
599
|
+
// Points test
|
|
600
|
+
if (!pointInPolygon(v0, polygonB)) {
|
|
601
|
+
inside = false;
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
// Lines test
|
|
605
|
+
if (lineIntersectsPolygon([v0, closed[i + 1]], polygonB)) {
|
|
606
|
+
inside = false;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return inside;
|
|
611
|
+
};
|
|
612
|
+
export const polygonIntersectPolygon = (polygonA, polygonB) => {
|
|
613
|
+
let intersects = false;
|
|
614
|
+
let onCount = 0;
|
|
615
|
+
const closed = close(polygonA);
|
|
616
|
+
for (let i = 0, l = closed.length - 1; i < l; i++) {
|
|
617
|
+
const v0 = closed[i];
|
|
618
|
+
const v1 = closed[i + 1];
|
|
619
|
+
if (lineIntersectsPolygon([v0, v1], polygonB)) {
|
|
620
|
+
intersects = true;
|
|
621
|
+
break;
|
|
622
|
+
}
|
|
623
|
+
if (pointOnPolygon(v0, polygonB)) {
|
|
624
|
+
++onCount;
|
|
625
|
+
}
|
|
626
|
+
if (onCount === 2) {
|
|
627
|
+
intersects = true;
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return intersects;
|
|
632
|
+
};
|
|
633
|
+
const distanceToEllipse = (point, ellipse) => {
|
|
634
|
+
const { angle, halfWidth, halfHeight, center } = ellipse;
|
|
635
|
+
const a = halfWidth;
|
|
636
|
+
const b = halfHeight;
|
|
637
|
+
const [rotatedPointX, rotatedPointY] = pointRelativeToCenter(point, center, angle);
|
|
638
|
+
const px = Math.abs(rotatedPointX);
|
|
639
|
+
const py = Math.abs(rotatedPointY);
|
|
640
|
+
let tx = 0.707;
|
|
641
|
+
let ty = 0.707;
|
|
642
|
+
for (let i = 0; i < 3; i++) {
|
|
643
|
+
const x = a * tx;
|
|
644
|
+
const y = b * ty;
|
|
645
|
+
const ex = ((a * a - b * b) * tx ** 3) / a;
|
|
646
|
+
const ey = ((b * b - a * a) * ty ** 3) / b;
|
|
647
|
+
const rx = x - ex;
|
|
648
|
+
const ry = y - ey;
|
|
649
|
+
const qx = px - ex;
|
|
650
|
+
const qy = py - ey;
|
|
651
|
+
const r = Math.hypot(ry, rx);
|
|
652
|
+
const q = Math.hypot(qy, qx);
|
|
653
|
+
tx = Math.min(1, Math.max(0, ((qx * r) / q + ex) / a));
|
|
654
|
+
ty = Math.min(1, Math.max(0, ((qy * r) / q + ey) / b));
|
|
655
|
+
const t = Math.hypot(ty, tx);
|
|
656
|
+
tx /= t;
|
|
657
|
+
ty /= t;
|
|
658
|
+
}
|
|
659
|
+
const [minX, minY] = [
|
|
660
|
+
a * tx * Math.sign(rotatedPointX),
|
|
661
|
+
b * ty * Math.sign(rotatedPointY),
|
|
662
|
+
];
|
|
663
|
+
return distanceToPoint([rotatedPointX, rotatedPointY], [minX, minY]);
|
|
664
|
+
};
|
|
665
|
+
export const pointOnEllipse = (point, ellipse, threshold = DEFAULT_THRESHOLD) => {
|
|
666
|
+
return distanceToEllipse(point, ellipse) <= threshold;
|
|
667
|
+
};
|
|
668
|
+
export const pointInEllipse = (point, ellipse) => {
|
|
669
|
+
const { center, angle, halfWidth, halfHeight } = ellipse;
|
|
670
|
+
const [rotatedPointX, rotatedPointY] = pointRelativeToCenter(point, center, angle);
|
|
671
|
+
return ((rotatedPointX / halfWidth) * (rotatedPointX / halfWidth) +
|
|
672
|
+
(rotatedPointY / halfHeight) * (rotatedPointY / halfHeight) <=
|
|
673
|
+
1);
|
|
674
|
+
};
|