ducjs 1.0.0

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.
Files changed (707) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/flatbuffers/duc/alternate-units.d.ts +21 -0
  4. package/dist/flatbuffers/duc/alternate-units.js +66 -0
  5. package/dist/flatbuffers/duc/angular-unit-system.d.ts +17 -0
  6. package/dist/flatbuffers/duc/angular-unit-system.js +50 -0
  7. package/dist/flatbuffers/duc/angular-units-format.d.ts +7 -0
  8. package/dist/flatbuffers/duc/angular-units-format.js +10 -0
  9. package/dist/flatbuffers/duc/axis.d.ts +5 -0
  10. package/dist/flatbuffers/duc/axis.js +8 -0
  11. package/dist/flatbuffers/duc/bezier-mirroring.d.ts +5 -0
  12. package/dist/flatbuffers/duc/bezier-mirroring.js +8 -0
  13. package/dist/flatbuffers/duc/blending.d.ts +9 -0
  14. package/dist/flatbuffers/duc/blending.js +12 -0
  15. package/dist/flatbuffers/duc/block-attachment.d.ts +4 -0
  16. package/dist/flatbuffers/duc/block-attachment.js +7 -0
  17. package/dist/flatbuffers/duc/boolean-operation.d.ts +6 -0
  18. package/dist/flatbuffers/duc/boolean-operation.js +9 -0
  19. package/dist/flatbuffers/duc/bound-element.d.ts +17 -0
  20. package/dist/flatbuffers/duc/bound-element.js +48 -0
  21. package/dist/flatbuffers/duc/checkpoint.d.ts +22 -0
  22. package/dist/flatbuffers/duc/checkpoint.js +75 -0
  23. package/dist/flatbuffers/duc/column-layout.d.ts +22 -0
  24. package/dist/flatbuffers/duc/column-layout.js +72 -0
  25. package/dist/flatbuffers/duc/column-type.d.ts +5 -0
  26. package/dist/flatbuffers/duc/column-type.js +8 -0
  27. package/dist/flatbuffers/duc/custom-hatch-pattern.d.ts +23 -0
  28. package/dist/flatbuffers/duc/custom-hatch-pattern.js +71 -0
  29. package/dist/flatbuffers/duc/datum-bracket-style.d.ts +5 -0
  30. package/dist/flatbuffers/duc/datum-bracket-style.js +8 -0
  31. package/dist/flatbuffers/duc/datum-reference.d.ts +17 -0
  32. package/dist/flatbuffers/duc/datum-reference.js +49 -0
  33. package/dist/flatbuffers/duc/datum-target-type.d.ts +6 -0
  34. package/dist/flatbuffers/duc/datum-target-type.js +9 -0
  35. package/dist/flatbuffers/duc/decimal-separator.d.ts +4 -0
  36. package/dist/flatbuffers/duc/decimal-separator.js +7 -0
  37. package/dist/flatbuffers/duc/delta.d.ts +20 -0
  38. package/dist/flatbuffers/duc/delta.js +64 -0
  39. package/dist/flatbuffers/duc/dictionary-entry.d.ts +17 -0
  40. package/dist/flatbuffers/duc/dictionary-entry.js +49 -0
  41. package/dist/flatbuffers/duc/dimension-baseline-data.d.ts +14 -0
  42. package/dist/flatbuffers/duc/dimension-baseline-data.js +40 -0
  43. package/dist/flatbuffers/duc/dimension-bindings.d.ts +17 -0
  44. package/dist/flatbuffers/duc/dimension-bindings.js +50 -0
  45. package/dist/flatbuffers/duc/dimension-continue-data.d.ts +14 -0
  46. package/dist/flatbuffers/duc/dimension-continue-data.js +40 -0
  47. package/dist/flatbuffers/duc/dimension-definition-points.d.ts +21 -0
  48. package/dist/flatbuffers/duc/dimension-definition-points.js +64 -0
  49. package/dist/flatbuffers/duc/dimension-ext-line-style.d.ts +18 -0
  50. package/dist/flatbuffers/duc/dimension-ext-line-style.js +57 -0
  51. package/dist/flatbuffers/duc/dimension-fit-rule.d.ts +6 -0
  52. package/dist/flatbuffers/duc/dimension-fit-rule.js +9 -0
  53. package/dist/flatbuffers/duc/dimension-fit-style.d.ts +19 -0
  54. package/dist/flatbuffers/duc/dimension-fit-style.js +58 -0
  55. package/dist/flatbuffers/duc/dimension-line-style.d.ts +16 -0
  56. package/dist/flatbuffers/duc/dimension-line-style.js +49 -0
  57. package/dist/flatbuffers/duc/dimension-symbol-style.d.ts +22 -0
  58. package/dist/flatbuffers/duc/dimension-symbol-style.js +72 -0
  59. package/dist/flatbuffers/duc/dimension-text-placement.d.ts +5 -0
  60. package/dist/flatbuffers/duc/dimension-text-placement.js +8 -0
  61. package/dist/flatbuffers/duc/dimension-tolerance-style.d.ts +24 -0
  62. package/dist/flatbuffers/duc/dimension-tolerance-style.js +71 -0
  63. package/dist/flatbuffers/duc/dimension-type.d.ts +15 -0
  64. package/dist/flatbuffers/duc/dimension-type.js +18 -0
  65. package/dist/flatbuffers/duc/dimension-units-format.d.ts +7 -0
  66. package/dist/flatbuffers/duc/dimension-units-format.js +10 -0
  67. package/dist/flatbuffers/duc/dimension-validation-rules.d.ts +25 -0
  68. package/dist/flatbuffers/duc/dimension-validation-rules.js +74 -0
  69. package/dist/flatbuffers/duc/duc-arrow-element.d.ts +16 -0
  70. package/dist/flatbuffers/duc/duc-arrow-element.js +49 -0
  71. package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.d.ts +16 -0
  72. package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.js +44 -0
  73. package/dist/flatbuffers/duc/duc-block-attribute-definition.d.ts +22 -0
  74. package/dist/flatbuffers/duc/duc-block-attribute-definition.js +64 -0
  75. package/dist/flatbuffers/duc/duc-block-duplication-array.d.ts +19 -0
  76. package/dist/flatbuffers/duc/duc-block-duplication-array.js +64 -0
  77. package/dist/flatbuffers/duc/duc-block-instance-element.d.ts +30 -0
  78. package/dist/flatbuffers/duc/duc-block-instance-element.js +94 -0
  79. package/dist/flatbuffers/duc/duc-block.d.ts +34 -0
  80. package/dist/flatbuffers/duc/duc-block.js +111 -0
  81. package/dist/flatbuffers/duc/duc-common-style.d.ts +16 -0
  82. package/dist/flatbuffers/duc/duc-common-style.js +44 -0
  83. package/dist/flatbuffers/duc/duc-dimension-element.d.ts +45 -0
  84. package/dist/flatbuffers/duc/duc-dimension-element.js +120 -0
  85. package/dist/flatbuffers/duc/duc-dimension-style.d.ts +28 -0
  86. package/dist/flatbuffers/duc/duc-dimension-style.js +76 -0
  87. package/dist/flatbuffers/duc/duc-doc-element.d.ts +33 -0
  88. package/dist/flatbuffers/duc/duc-doc-element.js +95 -0
  89. package/dist/flatbuffers/duc/duc-doc-style.d.ts +19 -0
  90. package/dist/flatbuffers/duc/duc-doc-style.js +52 -0
  91. package/dist/flatbuffers/duc/duc-element-base.d.ts +88 -0
  92. package/dist/flatbuffers/duc/duc-element-base.js +269 -0
  93. package/dist/flatbuffers/duc/duc-element-styles-base.d.ts +30 -0
  94. package/dist/flatbuffers/duc/duc-element-styles-base.js +103 -0
  95. package/dist/flatbuffers/duc/duc-ellipse-element.d.ts +22 -0
  96. package/dist/flatbuffers/duc/duc-ellipse-element.js +73 -0
  97. package/dist/flatbuffers/duc/duc-embeddable-element.d.ts +14 -0
  98. package/dist/flatbuffers/duc/duc-embeddable-element.js +41 -0
  99. package/dist/flatbuffers/duc/duc-external-file-data.d.ts +27 -0
  100. package/dist/flatbuffers/duc/duc-external-file-data.js +92 -0
  101. package/dist/flatbuffers/duc/duc-external-file-entry.d.ts +16 -0
  102. package/dist/flatbuffers/duc/duc-external-file-entry.js +44 -0
  103. package/dist/flatbuffers/duc/duc-feature-control-frame-element.d.ts +31 -0
  104. package/dist/flatbuffers/duc/duc-feature-control-frame-element.js +89 -0
  105. package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +25 -0
  106. package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +68 -0
  107. package/dist/flatbuffers/duc/duc-frame-element.d.ts +14 -0
  108. package/dist/flatbuffers/duc/duc-frame-element.js +41 -0
  109. package/dist/flatbuffers/duc/duc-free-draw-element.d.ts +52 -0
  110. package/dist/flatbuffers/duc/duc-free-draw-element.js +154 -0
  111. package/dist/flatbuffers/duc/duc-free-draw-ends.d.ts +18 -0
  112. package/dist/flatbuffers/duc/duc-free-draw-ends.js +56 -0
  113. package/dist/flatbuffers/duc/duc-global-state.d.ts +37 -0
  114. package/dist/flatbuffers/duc/duc-global-state.js +121 -0
  115. package/dist/flatbuffers/duc/duc-group.d.ts +16 -0
  116. package/dist/flatbuffers/duc/duc-group.js +44 -0
  117. package/dist/flatbuffers/duc/duc-hatch-style.d.ts +28 -0
  118. package/dist/flatbuffers/duc/duc-hatch-style.js +79 -0
  119. package/dist/flatbuffers/duc/duc-head.d.ts +19 -0
  120. package/dist/flatbuffers/duc/duc-head.js +57 -0
  121. package/dist/flatbuffers/duc/duc-image-element.d.ts +35 -0
  122. package/dist/flatbuffers/duc/duc-image-element.js +91 -0
  123. package/dist/flatbuffers/duc/duc-image-filter.d.ts +15 -0
  124. package/dist/flatbuffers/duc/duc-image-filter.js +48 -0
  125. package/dist/flatbuffers/duc/duc-layer-overrides.d.ts +16 -0
  126. package/dist/flatbuffers/duc/duc-layer-overrides.js +44 -0
  127. package/dist/flatbuffers/duc/duc-layer.d.ts +21 -0
  128. package/dist/flatbuffers/duc/duc-layer.js +59 -0
  129. package/dist/flatbuffers/duc/duc-leader-element.d.ts +22 -0
  130. package/dist/flatbuffers/duc/duc-leader-element.js +60 -0
  131. package/dist/flatbuffers/duc/duc-leader-style.d.ts +30 -0
  132. package/dist/flatbuffers/duc/duc-leader-style.js +87 -0
  133. package/dist/flatbuffers/duc/duc-line-reference.d.ts +15 -0
  134. package/dist/flatbuffers/duc/duc-line-reference.js +43 -0
  135. package/dist/flatbuffers/duc/duc-line.d.ts +15 -0
  136. package/dist/flatbuffers/duc/duc-line.js +43 -0
  137. package/dist/flatbuffers/duc/duc-linear-element-base.d.ts +38 -0
  138. package/dist/flatbuffers/duc/duc-linear-element-base.js +124 -0
  139. package/dist/flatbuffers/duc/duc-linear-element.d.ts +16 -0
  140. package/dist/flatbuffers/duc/duc-linear-element.js +49 -0
  141. package/dist/flatbuffers/duc/duc-local-state.d.ts +68 -0
  142. package/dist/flatbuffers/duc/duc-local-state.js +206 -0
  143. package/dist/flatbuffers/duc/duc-mermaid-element.d.ts +23 -0
  144. package/dist/flatbuffers/duc/duc-mermaid-element.js +65 -0
  145. package/dist/flatbuffers/duc/duc-parametric-element.d.ts +16 -0
  146. package/dist/flatbuffers/duc/duc-parametric-element.js +44 -0
  147. package/dist/flatbuffers/duc/duc-path.d.ts +26 -0
  148. package/dist/flatbuffers/duc/duc-path.js +69 -0
  149. package/dist/flatbuffers/duc/duc-pdf-element.d.ts +17 -0
  150. package/dist/flatbuffers/duc/duc-pdf-element.js +49 -0
  151. package/dist/flatbuffers/duc/duc-plot-element.d.ts +19 -0
  152. package/dist/flatbuffers/duc/duc-plot-element.js +52 -0
  153. package/dist/flatbuffers/duc/duc-plot-style.d.ts +14 -0
  154. package/dist/flatbuffers/duc/duc-plot-style.js +41 -0
  155. package/dist/flatbuffers/duc/duc-point-binding.d.ts +26 -0
  156. package/dist/flatbuffers/duc/duc-point-binding.js +73 -0
  157. package/dist/flatbuffers/duc/duc-point.d.ts +18 -0
  158. package/dist/flatbuffers/duc/duc-point.js +57 -0
  159. package/dist/flatbuffers/duc/duc-polygon-element.d.ts +16 -0
  160. package/dist/flatbuffers/duc/duc-polygon-element.js +49 -0
  161. package/dist/flatbuffers/duc/duc-rectangle-element.d.ts +14 -0
  162. package/dist/flatbuffers/duc/duc-rectangle-element.js +41 -0
  163. package/dist/flatbuffers/duc/duc-region.d.ts +19 -0
  164. package/dist/flatbuffers/duc/duc-region.js +51 -0
  165. package/dist/flatbuffers/duc/duc-stack-base.d.ts +27 -0
  166. package/dist/flatbuffers/duc/duc-stack-base.js +78 -0
  167. package/dist/flatbuffers/duc/duc-stack-element-base.d.ts +23 -0
  168. package/dist/flatbuffers/duc/duc-stack-element-base.js +65 -0
  169. package/dist/flatbuffers/duc/duc-stack-like-styles.d.ts +16 -0
  170. package/dist/flatbuffers/duc/duc-stack-like-styles.js +48 -0
  171. package/dist/flatbuffers/duc/duc-table-auto-size.d.ts +15 -0
  172. package/dist/flatbuffers/duc/duc-table-auto-size.js +48 -0
  173. package/dist/flatbuffers/duc/duc-table-cell-entry.d.ts +16 -0
  174. package/dist/flatbuffers/duc/duc-table-cell-entry.js +44 -0
  175. package/dist/flatbuffers/duc/duc-table-cell-span.d.ts +15 -0
  176. package/dist/flatbuffers/duc/duc-table-cell-span.js +48 -0
  177. package/dist/flatbuffers/duc/duc-table-cell-style.d.ts +22 -0
  178. package/dist/flatbuffers/duc/duc-table-cell-style.js +59 -0
  179. package/dist/flatbuffers/duc/duc-table-cell.d.ts +27 -0
  180. package/dist/flatbuffers/duc/duc-table-cell.js +72 -0
  181. package/dist/flatbuffers/duc/duc-table-column-entry.d.ts +16 -0
  182. package/dist/flatbuffers/duc/duc-table-column-entry.js +44 -0
  183. package/dist/flatbuffers/duc/duc-table-column.d.ts +18 -0
  184. package/dist/flatbuffers/duc/duc-table-column.js +51 -0
  185. package/dist/flatbuffers/duc/duc-table-element.d.ts +51 -0
  186. package/dist/flatbuffers/duc/duc-table-element.js +167 -0
  187. package/dist/flatbuffers/duc/duc-table-row-entry.d.ts +16 -0
  188. package/dist/flatbuffers/duc/duc-table-row-entry.js +44 -0
  189. package/dist/flatbuffers/duc/duc-table-row.d.ts +18 -0
  190. package/dist/flatbuffers/duc/duc-table-row.js +51 -0
  191. package/dist/flatbuffers/duc/duc-table-style.d.ts +23 -0
  192. package/dist/flatbuffers/duc/duc-table-style.js +65 -0
  193. package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.d.ts +14 -0
  194. package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.js +40 -0
  195. package/dist/flatbuffers/duc/duc-text-dynamic-element-source.d.ts +17 -0
  196. package/dist/flatbuffers/duc/duc-text-dynamic-element-source.js +49 -0
  197. package/dist/flatbuffers/duc/duc-text-dynamic-part.d.ts +22 -0
  198. package/dist/flatbuffers/duc/duc-text-dynamic-part.js +58 -0
  199. package/dist/flatbuffers/duc/duc-text-dynamic-source-data.d.ts +9 -0
  200. package/dist/flatbuffers/duc/duc-text-dynamic-source-data.js +26 -0
  201. package/dist/flatbuffers/duc/duc-text-dynamic-source.d.ts +19 -0
  202. package/dist/flatbuffers/duc/duc-text-dynamic-source.js +58 -0
  203. package/dist/flatbuffers/duc/duc-text-element.d.ts +33 -0
  204. package/dist/flatbuffers/duc/duc-text-element.js +94 -0
  205. package/dist/flatbuffers/duc/duc-text-style.d.ts +44 -0
  206. package/dist/flatbuffers/duc/duc-text-style.js +128 -0
  207. package/dist/flatbuffers/duc/duc-ucs.d.ts +16 -0
  208. package/dist/flatbuffers/duc/duc-ucs.js +49 -0
  209. package/dist/flatbuffers/duc/duc-view.d.ts +24 -0
  210. package/dist/flatbuffers/duc/duc-view.js +71 -0
  211. package/dist/flatbuffers/duc/duc-viewport-element.d.ts +36 -0
  212. package/dist/flatbuffers/duc/duc-viewport-element.js +102 -0
  213. package/dist/flatbuffers/duc/duc-viewport-style.d.ts +16 -0
  214. package/dist/flatbuffers/duc/duc-viewport-style.js +49 -0
  215. package/dist/flatbuffers/duc/duc-xray-element.d.ts +23 -0
  216. package/dist/flatbuffers/duc/duc-xray-element.js +66 -0
  217. package/dist/flatbuffers/duc/duc-xray-style.d.ts +17 -0
  218. package/dist/flatbuffers/duc/duc-xray-style.js +49 -0
  219. package/dist/flatbuffers/duc/dynamic-snap-settings.d.ts +17 -0
  220. package/dist/flatbuffers/duc/dynamic-snap-settings.js +56 -0
  221. package/dist/flatbuffers/duc/element-background.d.ts +14 -0
  222. package/dist/flatbuffers/duc/element-background.js +41 -0
  223. package/dist/flatbuffers/duc/element-content-base.d.ts +29 -0
  224. package/dist/flatbuffers/duc/element-content-base.js +80 -0
  225. package/dist/flatbuffers/duc/element-content-preference.d.ts +8 -0
  226. package/dist/flatbuffers/duc/element-content-preference.js +11 -0
  227. package/dist/flatbuffers/duc/element-stroke.d.ts +24 -0
  228. package/dist/flatbuffers/duc/element-stroke.js +66 -0
  229. package/dist/flatbuffers/duc/element-wrapper.d.ts +16 -0
  230. package/dist/flatbuffers/duc/element-wrapper.js +49 -0
  231. package/dist/flatbuffers/duc/element.d.ts +49 -0
  232. package/dist/flatbuffers/duc/element.js +106 -0
  233. package/dist/flatbuffers/duc/exported-data-state.d.ts +87 -0
  234. package/dist/flatbuffers/duc/exported-data-state.js +290 -0
  235. package/dist/flatbuffers/duc/fcfbetween-modifier.d.ts +17 -0
  236. package/dist/flatbuffers/duc/fcfbetween-modifier.js +48 -0
  237. package/dist/flatbuffers/duc/fcfdatum-definition.d.ts +16 -0
  238. package/dist/flatbuffers/duc/fcfdatum-definition.js +43 -0
  239. package/dist/flatbuffers/duc/fcfdatum-style.d.ts +14 -0
  240. package/dist/flatbuffers/duc/fcfdatum-style.js +41 -0
  241. package/dist/flatbuffers/duc/fcfframe-modifiers.d.ts +22 -0
  242. package/dist/flatbuffers/duc/fcfframe-modifiers.js +65 -0
  243. package/dist/flatbuffers/duc/fcflayout-style.d.ts +17 -0
  244. package/dist/flatbuffers/duc/fcflayout-style.js +56 -0
  245. package/dist/flatbuffers/duc/fcfprojected-zone-modifier.d.ts +13 -0
  246. package/dist/flatbuffers/duc/fcfprojected-zone-modifier.js +40 -0
  247. package/dist/flatbuffers/duc/fcfsegment-row.d.ts +17 -0
  248. package/dist/flatbuffers/duc/fcfsegment-row.js +55 -0
  249. package/dist/flatbuffers/duc/fcfsymbol-style.d.ts +13 -0
  250. package/dist/flatbuffers/duc/fcfsymbol-style.js +40 -0
  251. package/dist/flatbuffers/duc/feature-control-frame-segment.d.ts +22 -0
  252. package/dist/flatbuffers/duc/feature-control-frame-segment.js +65 -0
  253. package/dist/flatbuffers/duc/feature-modifier.d.ts +18 -0
  254. package/dist/flatbuffers/duc/feature-modifier.js +21 -0
  255. package/dist/flatbuffers/duc/gdt-symbol.d.ts +22 -0
  256. package/dist/flatbuffers/duc/gdt-symbol.js +25 -0
  257. package/dist/flatbuffers/duc/geometric-point.d.ts +10 -0
  258. package/dist/flatbuffers/duc/geometric-point.js +27 -0
  259. package/dist/flatbuffers/duc/grid-display-type.d.ts +6 -0
  260. package/dist/flatbuffers/duc/grid-display-type.js +9 -0
  261. package/dist/flatbuffers/duc/grid-settings.d.ts +54 -0
  262. package/dist/flatbuffers/duc/grid-settings.js +165 -0
  263. package/dist/flatbuffers/duc/grid-style.d.ts +26 -0
  264. package/dist/flatbuffers/duc/grid-style.js +74 -0
  265. package/dist/flatbuffers/duc/grid-type.d.ts +7 -0
  266. package/dist/flatbuffers/duc/grid-type.js +10 -0
  267. package/dist/flatbuffers/duc/handle-type.d.ts +4 -0
  268. package/dist/flatbuffers/duc/handle-type.js +7 -0
  269. package/dist/flatbuffers/duc/hatch-pattern-line.d.ts +35 -0
  270. package/dist/flatbuffers/duc/hatch-pattern-line.js +93 -0
  271. package/dist/flatbuffers/duc/hatch-style.d.ts +5 -0
  272. package/dist/flatbuffers/duc/hatch-style.js +8 -0
  273. package/dist/flatbuffers/duc/identified-common-style.d.ts +16 -0
  274. package/dist/flatbuffers/duc/identified-common-style.js +44 -0
  275. package/dist/flatbuffers/duc/identified-dimension-style.d.ts +16 -0
  276. package/dist/flatbuffers/duc/identified-dimension-style.js +44 -0
  277. package/dist/flatbuffers/duc/identified-doc-style.d.ts +16 -0
  278. package/dist/flatbuffers/duc/identified-doc-style.js +44 -0
  279. package/dist/flatbuffers/duc/identified-fcfstyle.d.ts +16 -0
  280. package/dist/flatbuffers/duc/identified-fcfstyle.js +44 -0
  281. package/dist/flatbuffers/duc/identified-grid-settings.d.ts +16 -0
  282. package/dist/flatbuffers/duc/identified-grid-settings.js +44 -0
  283. package/dist/flatbuffers/duc/identified-hatch-style.d.ts +16 -0
  284. package/dist/flatbuffers/duc/identified-hatch-style.js +44 -0
  285. package/dist/flatbuffers/duc/identified-leader-style.d.ts +16 -0
  286. package/dist/flatbuffers/duc/identified-leader-style.js +44 -0
  287. package/dist/flatbuffers/duc/identified-snap-settings.d.ts +16 -0
  288. package/dist/flatbuffers/duc/identified-snap-settings.js +44 -0
  289. package/dist/flatbuffers/duc/identified-stack-like-style.d.ts +16 -0
  290. package/dist/flatbuffers/duc/identified-stack-like-style.js +44 -0
  291. package/dist/flatbuffers/duc/identified-table-style.d.ts +16 -0
  292. package/dist/flatbuffers/duc/identified-table-style.js +44 -0
  293. package/dist/flatbuffers/duc/identified-text-style.d.ts +16 -0
  294. package/dist/flatbuffers/duc/identified-text-style.js +44 -0
  295. package/dist/flatbuffers/duc/identified-ucs.d.ts +16 -0
  296. package/dist/flatbuffers/duc/identified-ucs.js +44 -0
  297. package/dist/flatbuffers/duc/identified-view.d.ts +16 -0
  298. package/dist/flatbuffers/duc/identified-view.js +44 -0
  299. package/dist/flatbuffers/duc/identified-viewport-style.d.ts +16 -0
  300. package/dist/flatbuffers/duc/identified-viewport-style.js +44 -0
  301. package/dist/flatbuffers/duc/identified-xray-style.d.ts +16 -0
  302. package/dist/flatbuffers/duc/identified-xray-style.js +44 -0
  303. package/dist/flatbuffers/duc/identifier.d.ts +20 -0
  304. package/dist/flatbuffers/duc/identifier.js +57 -0
  305. package/dist/flatbuffers/duc/image-crop.d.ts +23 -0
  306. package/dist/flatbuffers/duc/image-crop.js +80 -0
  307. package/dist/flatbuffers/duc/image-status.d.ts +5 -0
  308. package/dist/flatbuffers/duc/image-status.js +8 -0
  309. package/dist/flatbuffers/duc/isometric-grid-settings.d.ts +15 -0
  310. package/dist/flatbuffers/duc/isometric-grid-settings.js +48 -0
  311. package/dist/flatbuffers/duc/jsonpatch-operation.d.ts +23 -0
  312. package/dist/flatbuffers/duc/jsonpatch-operation.js +64 -0
  313. package/dist/flatbuffers/duc/layer-snap-filters.d.ts +23 -0
  314. package/dist/flatbuffers/duc/layer-snap-filters.js +76 -0
  315. package/dist/flatbuffers/duc/layer-validation-rules.d.ts +17 -0
  316. package/dist/flatbuffers/duc/layer-validation-rules.js +54 -0
  317. package/dist/flatbuffers/duc/leader-block-content.d.ts +25 -0
  318. package/dist/flatbuffers/duc/leader-block-content.js +85 -0
  319. package/dist/flatbuffers/duc/leader-content-data.d.ts +9 -0
  320. package/dist/flatbuffers/duc/leader-content-data.js +26 -0
  321. package/dist/flatbuffers/duc/leader-content-type.d.ts +4 -0
  322. package/dist/flatbuffers/duc/leader-content-type.js +7 -0
  323. package/dist/flatbuffers/duc/leader-content.d.ts +19 -0
  324. package/dist/flatbuffers/duc/leader-content.js +58 -0
  325. package/dist/flatbuffers/duc/leader-text-block-content.d.ts +14 -0
  326. package/dist/flatbuffers/duc/leader-text-block-content.js +40 -0
  327. package/dist/flatbuffers/duc/line-head.d.ts +17 -0
  328. package/dist/flatbuffers/duc/line-head.js +20 -0
  329. package/dist/flatbuffers/duc/line-spacing-type.d.ts +5 -0
  330. package/dist/flatbuffers/duc/line-spacing-type.js +8 -0
  331. package/dist/flatbuffers/duc/line-spacing.d.ts +16 -0
  332. package/dist/flatbuffers/duc/line-spacing.js +49 -0
  333. package/dist/flatbuffers/duc/linear-unit-system.d.ts +24 -0
  334. package/dist/flatbuffers/duc/linear-unit-system.js +75 -0
  335. package/dist/flatbuffers/duc/margins.d.ts +19 -0
  336. package/dist/flatbuffers/duc/margins.js +64 -0
  337. package/dist/flatbuffers/duc/mark-ellipse-center.d.ts +4 -0
  338. package/dist/flatbuffers/duc/mark-ellipse-center.js +7 -0
  339. package/dist/flatbuffers/duc/material-condition.d.ts +5 -0
  340. package/dist/flatbuffers/duc/material-condition.js +8 -0
  341. package/dist/flatbuffers/duc/object-snap-mode.d.ts +22 -0
  342. package/dist/flatbuffers/duc/object-snap-mode.js +25 -0
  343. package/dist/flatbuffers/duc/paragraph-formatting.d.ts +33 -0
  344. package/dist/flatbuffers/duc/paragraph-formatting.js +106 -0
  345. package/dist/flatbuffers/duc/parametric-source-type.d.ts +4 -0
  346. package/dist/flatbuffers/duc/parametric-source-type.js +7 -0
  347. package/dist/flatbuffers/duc/parametric-source.d.ts +20 -0
  348. package/dist/flatbuffers/duc/parametric-source.js +57 -0
  349. package/dist/flatbuffers/duc/plot-layout.d.ts +14 -0
  350. package/dist/flatbuffers/duc/plot-layout.js +41 -0
  351. package/dist/flatbuffers/duc/point-binding-point.d.ts +15 -0
  352. package/dist/flatbuffers/duc/point-binding-point.js +48 -0
  353. package/dist/flatbuffers/duc/polar-grid-settings.d.ts +17 -0
  354. package/dist/flatbuffers/duc/polar-grid-settings.js +56 -0
  355. package/dist/flatbuffers/duc/polar-tracking-settings.d.ts +29 -0
  356. package/dist/flatbuffers/duc/polar-tracking-settings.js +90 -0
  357. package/dist/flatbuffers/duc/primary-units.d.ts +16 -0
  358. package/dist/flatbuffers/duc/primary-units.js +44 -0
  359. package/dist/flatbuffers/duc/pruning-level.d.ts +5 -0
  360. package/dist/flatbuffers/duc/pruning-level.js +8 -0
  361. package/dist/flatbuffers/duc/snap-marker-settings.d.ts +23 -0
  362. package/dist/flatbuffers/duc/snap-marker-settings.js +79 -0
  363. package/dist/flatbuffers/duc/snap-marker-shape.d.ts +6 -0
  364. package/dist/flatbuffers/duc/snap-marker-shape.js +9 -0
  365. package/dist/flatbuffers/duc/snap-marker-style-entry.d.ts +16 -0
  366. package/dist/flatbuffers/duc/snap-marker-style-entry.js +43 -0
  367. package/dist/flatbuffers/duc/snap-marker-style.d.ts +17 -0
  368. package/dist/flatbuffers/duc/snap-marker-style.js +49 -0
  369. package/dist/flatbuffers/duc/snap-mode.d.ts +4 -0
  370. package/dist/flatbuffers/duc/snap-mode.js +7 -0
  371. package/dist/flatbuffers/duc/snap-override-behavior.d.ts +5 -0
  372. package/dist/flatbuffers/duc/snap-override-behavior.js +8 -0
  373. package/dist/flatbuffers/duc/snap-override.d.ts +17 -0
  374. package/dist/flatbuffers/duc/snap-override.js +49 -0
  375. package/dist/flatbuffers/duc/snap-settings.d.ts +75 -0
  376. package/dist/flatbuffers/duc/snap-settings.js +245 -0
  377. package/dist/flatbuffers/duc/stack-format-properties.d.ts +18 -0
  378. package/dist/flatbuffers/duc/stack-format-properties.js +57 -0
  379. package/dist/flatbuffers/duc/stack-format.d.ts +21 -0
  380. package/dist/flatbuffers/duc/stack-format.js +64 -0
  381. package/dist/flatbuffers/duc/stacked-text-align.d.ts +5 -0
  382. package/dist/flatbuffers/duc/stacked-text-align.js +8 -0
  383. package/dist/flatbuffers/duc/standard-overrides.d.ts +63 -0
  384. package/dist/flatbuffers/duc/standard-overrides.js +162 -0
  385. package/dist/flatbuffers/duc/standard-styles.d.ts +77 -0
  386. package/dist/flatbuffers/duc/standard-styles.js +285 -0
  387. package/dist/flatbuffers/duc/standard-units.d.ts +16 -0
  388. package/dist/flatbuffers/duc/standard-units.js +44 -0
  389. package/dist/flatbuffers/duc/standard-validation.d.ts +16 -0
  390. package/dist/flatbuffers/duc/standard-validation.js +44 -0
  391. package/dist/flatbuffers/duc/standard-view-settings.d.ts +35 -0
  392. package/dist/flatbuffers/duc/standard-view-settings.js +124 -0
  393. package/dist/flatbuffers/duc/standard.d.ts +33 -0
  394. package/dist/flatbuffers/duc/standard.js +90 -0
  395. package/dist/flatbuffers/duc/string-value-entry.d.ts +17 -0
  396. package/dist/flatbuffers/duc/string-value-entry.js +49 -0
  397. package/dist/flatbuffers/duc/stroke-cap.d.ts +5 -0
  398. package/dist/flatbuffers/duc/stroke-cap.js +8 -0
  399. package/dist/flatbuffers/duc/stroke-join.d.ts +5 -0
  400. package/dist/flatbuffers/duc/stroke-join.js +8 -0
  401. package/dist/flatbuffers/duc/stroke-placement.d.ts +5 -0
  402. package/dist/flatbuffers/duc/stroke-placement.js +8 -0
  403. package/dist/flatbuffers/duc/stroke-preference.d.ts +6 -0
  404. package/dist/flatbuffers/duc/stroke-preference.js +9 -0
  405. package/dist/flatbuffers/duc/stroke-side-preference.d.ts +8 -0
  406. package/dist/flatbuffers/duc/stroke-side-preference.js +11 -0
  407. package/dist/flatbuffers/duc/stroke-sides.d.ts +24 -0
  408. package/dist/flatbuffers/duc/stroke-sides.js +67 -0
  409. package/dist/flatbuffers/duc/stroke-style.d.ts +37 -0
  410. package/dist/flatbuffers/duc/stroke-style.js +111 -0
  411. package/dist/flatbuffers/duc/stroke-width.d.ts +5 -0
  412. package/dist/flatbuffers/duc/stroke-width.js +8 -0
  413. package/dist/flatbuffers/duc/table-cell-alignment.d.ts +11 -0
  414. package/dist/flatbuffers/duc/table-cell-alignment.js +14 -0
  415. package/dist/flatbuffers/duc/table-flow-direction.d.ts +4 -0
  416. package/dist/flatbuffers/duc/table-flow-direction.js +7 -0
  417. package/dist/flatbuffers/duc/text-align.d.ts +5 -0
  418. package/dist/flatbuffers/duc/text-align.js +8 -0
  419. package/dist/flatbuffers/duc/text-column.d.ts +15 -0
  420. package/dist/flatbuffers/duc/text-column.js +48 -0
  421. package/dist/flatbuffers/duc/text-field-source-property.d.ts +13 -0
  422. package/dist/flatbuffers/duc/text-field-source-property.js +16 -0
  423. package/dist/flatbuffers/duc/text-field-source-type.d.ts +4 -0
  424. package/dist/flatbuffers/duc/text-field-source-type.js +7 -0
  425. package/dist/flatbuffers/duc/text-flow-direction.d.ts +6 -0
  426. package/dist/flatbuffers/duc/text-flow-direction.js +9 -0
  427. package/dist/flatbuffers/duc/tiling-properties.d.ts +21 -0
  428. package/dist/flatbuffers/duc/tiling-properties.js +75 -0
  429. package/dist/flatbuffers/duc/tolerance-clause.d.ts +27 -0
  430. package/dist/flatbuffers/duc/tolerance-clause.js +84 -0
  431. package/dist/flatbuffers/duc/tolerance-display.d.ts +7 -0
  432. package/dist/flatbuffers/duc/tolerance-display.js +10 -0
  433. package/dist/flatbuffers/duc/tolerance-type.d.ts +5 -0
  434. package/dist/flatbuffers/duc/tolerance-type.js +8 -0
  435. package/dist/flatbuffers/duc/tolerance-zone-type.d.ts +7 -0
  436. package/dist/flatbuffers/duc/tolerance-zone-type.js +10 -0
  437. package/dist/flatbuffers/duc/tracking-line-style.d.ts +26 -0
  438. package/dist/flatbuffers/duc/tracking-line-style.js +74 -0
  439. package/dist/flatbuffers/duc/unit-precision.d.ts +19 -0
  440. package/dist/flatbuffers/duc/unit-precision.js +64 -0
  441. package/dist/flatbuffers/duc/unit-system-base.d.ts +20 -0
  442. package/dist/flatbuffers/duc/unit-system-base.js +65 -0
  443. package/dist/flatbuffers/duc/unit-system.d.ts +4 -0
  444. package/dist/flatbuffers/duc/unit-system.js +7 -0
  445. package/dist/flatbuffers/duc/version-base.d.ts +27 -0
  446. package/dist/flatbuffers/duc/version-base.js +80 -0
  447. package/dist/flatbuffers/duc/version-graph-metadata.d.ts +15 -0
  448. package/dist/flatbuffers/duc/version-graph-metadata.js +48 -0
  449. package/dist/flatbuffers/duc/version-graph.d.ts +31 -0
  450. package/dist/flatbuffers/duc/version-graph.js +94 -0
  451. package/dist/flatbuffers/duc/vertical-align.d.ts +5 -0
  452. package/dist/flatbuffers/duc/vertical-align.js +8 -0
  453. package/dist/flatbuffers/duc/viewport-shade-plot.d.ts +6 -0
  454. package/dist/flatbuffers/duc/viewport-shade-plot.js +9 -0
  455. package/dist/flatbuffers/duc/youtube-states.d.ts +8 -0
  456. package/dist/flatbuffers/duc/youtube-states.js +11 -0
  457. package/dist/flatbuffers/duc.d.ts +227 -0
  458. package/dist/flatbuffers/duc.js +229 -0
  459. package/dist/index.d.ts +8 -0
  460. package/dist/index.js +8 -0
  461. package/dist/legacy/index.d.ts +1 -0
  462. package/dist/legacy/index.js +1 -0
  463. package/dist/legacy/v1/duc/app-state.d.ts +124 -0
  464. package/dist/legacy/v1/duc/app-state.js +388 -0
  465. package/dist/legacy/v1/duc/binary-file-data.d.ts +27 -0
  466. package/dist/legacy/v1/duc/binary-file-data.js +90 -0
  467. package/dist/legacy/v1/duc/binary-files-entry.d.ts +16 -0
  468. package/dist/legacy/v1/duc/binary-files-entry.js +43 -0
  469. package/dist/legacy/v1/duc/binary-files.d.ts +17 -0
  470. package/dist/legacy/v1/duc/binary-files.js +55 -0
  471. package/dist/legacy/v1/duc/binding-point.d.ts +15 -0
  472. package/dist/legacy/v1/duc/binding-point.js +48 -0
  473. package/dist/legacy/v1/duc/bound-element.d.ts +17 -0
  474. package/dist/legacy/v1/duc/bound-element.js +48 -0
  475. package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +22 -0
  476. package/dist/legacy/v1/duc/duc-block-attribute-details.js +57 -0
  477. package/dist/legacy/v1/duc/duc-block-attribute.d.ts +16 -0
  478. package/dist/legacy/v1/duc/duc-block-attribute.js +43 -0
  479. package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +17 -0
  480. package/dist/legacy/v1/duc/duc-block-instance-element-override.js +48 -0
  481. package/dist/legacy/v1/duc/duc-block.d.ts +34 -0
  482. package/dist/legacy/v1/duc/duc-block.js +110 -0
  483. package/dist/legacy/v1/duc/duc-element.d.ts +273 -0
  484. package/dist/legacy/v1/duc/duc-element.js +865 -0
  485. package/dist/legacy/v1/duc/duc-group.d.ts +40 -0
  486. package/dist/legacy/v1/duc/duc-group.js +114 -0
  487. package/dist/legacy/v1/duc/duc-line-reference.d.ts +15 -0
  488. package/dist/legacy/v1/duc/duc-line-reference.js +43 -0
  489. package/dist/legacy/v1/duc/duc-line.d.ts +15 -0
  490. package/dist/legacy/v1/duc/duc-line.js +43 -0
  491. package/dist/legacy/v1/duc/duc-path.d.ts +26 -0
  492. package/dist/legacy/v1/duc/duc-path.js +69 -0
  493. package/dist/legacy/v1/duc/duc-table-cell.d.ts +22 -0
  494. package/dist/legacy/v1/duc/duc-table-cell.js +57 -0
  495. package/dist/legacy/v1/duc/duc-table-column.d.ts +18 -0
  496. package/dist/legacy/v1/duc/duc-table-column.js +50 -0
  497. package/dist/legacy/v1/duc/duc-table-row.d.ts +18 -0
  498. package/dist/legacy/v1/duc/duc-table-row.js +50 -0
  499. package/dist/legacy/v1/duc/duc-table-style-props.d.ts +39 -0
  500. package/dist/legacy/v1/duc/duc-table-style-props.js +114 -0
  501. package/dist/legacy/v1/duc/duc-table-style.d.ts +14 -0
  502. package/dist/legacy/v1/duc/duc-table-style.js +41 -0
  503. package/dist/legacy/v1/duc/element-background.d.ts +14 -0
  504. package/dist/legacy/v1/duc/element-background.js +41 -0
  505. package/dist/legacy/v1/duc/element-content-base.d.ts +22 -0
  506. package/dist/legacy/v1/duc/element-content-base.js +64 -0
  507. package/dist/legacy/v1/duc/element-stroke.d.ts +23 -0
  508. package/dist/legacy/v1/duc/element-stroke.js +66 -0
  509. package/dist/legacy/v1/duc/exported-data-state.d.ts +51 -0
  510. package/dist/legacy/v1/duc/exported-data-state.js +155 -0
  511. package/dist/legacy/v1/duc/image-crop.d.ts +23 -0
  512. package/dist/legacy/v1/duc/image-crop.js +80 -0
  513. package/dist/legacy/v1/duc/linear-element-editor.d.ts +44 -0
  514. package/dist/legacy/v1/duc/linear-element-editor.js +119 -0
  515. package/dist/legacy/v1/duc/point-binding.d.ts +25 -0
  516. package/dist/legacy/v1/duc/point-binding.js +72 -0
  517. package/dist/legacy/v1/duc/point.d.ts +20 -0
  518. package/dist/legacy/v1/duc/point.js +63 -0
  519. package/dist/legacy/v1/duc/pointer-down-state.d.ts +32 -0
  520. package/dist/legacy/v1/duc/pointer-down-state.js +90 -0
  521. package/dist/legacy/v1/duc/renderer-state.d.ts +17 -0
  522. package/dist/legacy/v1/duc/renderer-state.js +54 -0
  523. package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +18 -0
  524. package/dist/legacy/v1/duc/segment-midpoint-state.js +57 -0
  525. package/dist/legacy/v1/duc/simple-point.d.ts +15 -0
  526. package/dist/legacy/v1/duc/simple-point.js +48 -0
  527. package/dist/legacy/v1/duc/stroke-sides.d.ts +23 -0
  528. package/dist/legacy/v1/duc/stroke-sides.js +66 -0
  529. package/dist/legacy/v1/duc/stroke-style.d.ts +31 -0
  530. package/dist/legacy/v1/duc/stroke-style.js +102 -0
  531. package/dist/legacy/v1/duc/tiling-properties.d.ts +21 -0
  532. package/dist/legacy/v1/duc/tiling-properties.js +75 -0
  533. package/dist/legacy/v1/duc.d.ts +35 -0
  534. package/dist/legacy/v1/duc.js +37 -0
  535. package/dist/legacy/v1/index.d.ts +1 -0
  536. package/dist/legacy/v1/index.js +1 -0
  537. package/dist/legacy/v1/parse/index.d.ts +67 -0
  538. package/dist/legacy/v1/parse/index.js +101 -0
  539. package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +3 -0
  540. package/dist/legacy/v1/parse/parseAppStateFromBinary.js +139 -0
  541. package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +4 -0
  542. package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +32 -0
  543. package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +3 -0
  544. package/dist/legacy/v1/parse/parseBlockFromBinary.js +70 -0
  545. package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +8 -0
  546. package/dist/legacy/v1/parse/parseElementFromBinary.js +387 -0
  547. package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +4 -0
  548. package/dist/legacy/v1/parse/parseGroupFromBinary.js +36 -0
  549. package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +4 -0
  550. package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +15 -0
  551. package/dist/legacy/v1/serialize/index.d.ts +5 -0
  552. package/dist/legacy/v1/serialize/index.js +81 -0
  553. package/dist/legacy/v1/serialize/serializationUtils.d.ts +17 -0
  554. package/dist/legacy/v1/serialize/serializationUtils.js +27 -0
  555. package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +4 -0
  556. package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +145 -0
  557. package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +4 -0
  558. package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +46 -0
  559. package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +3 -0
  560. package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +60 -0
  561. package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +8 -0
  562. package/dist/legacy/v1/serialize/serializeElementFromDuc.js +435 -0
  563. package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +3 -0
  564. package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +37 -0
  565. package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +4 -0
  566. package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +7 -0
  567. package/dist/legacy/v1/types/elements/index.d.ts +480 -0
  568. package/dist/legacy/v1/types/elements/index.js +1 -0
  569. package/dist/legacy/v1/types/elements/typeChecks.d.ts +40 -0
  570. package/dist/legacy/v1/types/elements/typeChecks.js +179 -0
  571. package/dist/legacy/v1/types/geometryTypes.d.ts +78 -0
  572. package/dist/legacy/v1/types/geometryTypes.js +1 -0
  573. package/dist/legacy/v1/types/index.d.ts +496 -0
  574. package/dist/legacy/v1/types/index.js +1 -0
  575. package/dist/legacy/v1/types/utility-types.d.ts +31 -0
  576. package/dist/legacy/v1/types/utility-types.js +1 -0
  577. package/dist/legacy/v1/utils/bounds.d.ts +76 -0
  578. package/dist/legacy/v1/utils/bounds.js +415 -0
  579. package/dist/legacy/v1/utils/constants.d.ts +370 -0
  580. package/dist/legacy/v1/utils/constants.js +571 -0
  581. package/dist/legacy/v1/utils/elements/index.d.ts +26 -0
  582. package/dist/legacy/v1/utils/elements/index.js +108 -0
  583. package/dist/legacy/v1/utils/elements/linearElement.d.ts +133 -0
  584. package/dist/legacy/v1/utils/elements/linearElement.js +544 -0
  585. package/dist/legacy/v1/utils/elements/textElement.d.ts +89 -0
  586. package/dist/legacy/v1/utils/elements/textElement.js +563 -0
  587. package/dist/legacy/v1/utils/index.d.ts +26 -0
  588. package/dist/legacy/v1/utils/index.js +40 -0
  589. package/dist/legacy/v1/utils/math/algebra/ga.d.ts +63 -0
  590. package/dist/legacy/v1/utils/math/algebra/ga.js +268 -0
  591. package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +9 -0
  592. package/dist/legacy/v1/utils/math/algebra/gadirections.js +18 -0
  593. package/dist/legacy/v1/utils/math/algebra/galines.d.ts +23 -0
  594. package/dist/legacy/v1/utils/math/algebra/galines.js +32 -0
  595. package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +8 -0
  596. package/dist/legacy/v1/utils/math/algebra/gapoints.js +30 -0
  597. package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +10 -0
  598. package/dist/legacy/v1/utils/math/algebra/gatransforms.js +23 -0
  599. package/dist/legacy/v1/utils/math/bbox.d.ts +10 -0
  600. package/dist/legacy/v1/utils/math/bbox.js +42 -0
  601. package/dist/legacy/v1/utils/math/geometry.d.ts +102 -0
  602. package/dist/legacy/v1/utils/math/geometry.js +790 -0
  603. package/dist/legacy/v1/utils/math/index.d.ts +309 -0
  604. package/dist/legacy/v1/utils/math/index.js +1140 -0
  605. package/dist/legacy/v1/utils/math/random.d.ts +4 -0
  606. package/dist/legacy/v1/utils/math/random.js +25 -0
  607. package/dist/legacy/v1/utils/measurements.d.ts +33 -0
  608. package/dist/legacy/v1/utils/measurements.js +65 -0
  609. package/dist/legacy/v1/utils/normalize.d.ts +14 -0
  610. package/dist/legacy/v1/utils/normalize.js +49 -0
  611. package/dist/legacy/v1/utils/restore.d.ts +197 -0
  612. package/dist/legacy/v1/utils/restore.js +1255 -0
  613. package/dist/legacy/v1/utils/scopes.d.ts +260 -0
  614. package/dist/legacy/v1/utils/scopes.js +661 -0
  615. package/dist/legacy/v1/utils/standards.d.ts +12 -0
  616. package/dist/legacy/v1/utils/standards.js +10 -0
  617. package/dist/legacy/v1/utils/state/index.d.ts +2 -0
  618. package/dist/legacy/v1/utils/state/index.js +68 -0
  619. package/dist/legacy/v1/utils/url.d.ts +8 -0
  620. package/dist/legacy/v1/utils/url.js +33 -0
  621. package/dist/parse.d.ts +54 -0
  622. package/dist/parse.js +1318 -0
  623. package/dist/restore/index.d.ts +3 -0
  624. package/dist/restore/index.js +3 -0
  625. package/dist/restore/restoreDataState.d.ts +191 -0
  626. package/dist/restore/restoreDataState.js +716 -0
  627. package/dist/restore/restoreElements.d.ts +34 -0
  628. package/dist/restore/restoreElements.js +1281 -0
  629. package/dist/restore/restoreStandards.d.ts +8 -0
  630. package/dist/restore/restoreStandards.js +224 -0
  631. package/dist/serialize.d.ts +3 -0
  632. package/dist/serialize.js +2465 -0
  633. package/dist/technical/index.d.ts +3 -0
  634. package/dist/technical/index.js +3 -0
  635. package/dist/technical/measurements.d.ts +31 -0
  636. package/dist/technical/measurements.js +64 -0
  637. package/dist/technical/scopes.d.ts +261 -0
  638. package/dist/technical/scopes.js +661 -0
  639. package/dist/technical/standards.d.ts +124 -0
  640. package/dist/technical/standards.js +10 -0
  641. package/dist/types/elements/index.d.ts +1356 -0
  642. package/dist/types/elements/index.js +1 -0
  643. package/dist/types/elements/typeChecks.d.ts +40 -0
  644. package/dist/types/elements/typeChecks.js +188 -0
  645. package/dist/types/geometryTypes.d.ts +90 -0
  646. package/dist/types/geometryTypes.js +1 -0
  647. package/dist/types/index.d.ts +591 -0
  648. package/dist/types/index.js +3 -0
  649. package/dist/types/utility-types.d.ts +31 -0
  650. package/dist/types/utility-types.js +1 -0
  651. package/dist/utils/bounds.d.ts +75 -0
  652. package/dist/utils/bounds.js +414 -0
  653. package/dist/utils/constants.d.ts +288 -0
  654. package/dist/utils/constants.js +529 -0
  655. package/dist/utils/elements/frameElement.d.ts +4 -0
  656. package/dist/utils/elements/frameElement.js +16 -0
  657. package/dist/utils/elements/freedrawElement.d.ts +2 -0
  658. package/dist/utils/elements/freedrawElement.js +46 -0
  659. package/dist/utils/elements/index.d.ts +51 -0
  660. package/dist/utils/elements/index.js +215 -0
  661. package/dist/utils/elements/linearElement.d.ts +53 -0
  662. package/dist/utils/elements/linearElement.js +539 -0
  663. package/dist/utils/elements/newElement.d.ts +72 -0
  664. package/dist/utils/elements/newElement.js +268 -0
  665. package/dist/utils/elements/textElement.d.ts +89 -0
  666. package/dist/utils/elements/textElement.js +565 -0
  667. package/dist/utils/elements/viewportElement.d.ts +6 -0
  668. package/dist/utils/elements/viewportElement.js +9 -0
  669. package/dist/utils/filebyte.d.ts +39 -0
  670. package/dist/utils/filebyte.js +117 -0
  671. package/dist/utils/functionCodec.d.ts +5 -0
  672. package/dist/utils/functionCodec.js +86 -0
  673. package/dist/utils/index.d.ts +32 -0
  674. package/dist/utils/index.js +53 -0
  675. package/dist/utils/math/algebra/ga.d.ts +63 -0
  676. package/dist/utils/math/algebra/ga.js +268 -0
  677. package/dist/utils/math/algebra/gadirections.d.ts +9 -0
  678. package/dist/utils/math/algebra/gadirections.js +18 -0
  679. package/dist/utils/math/algebra/galines.d.ts +23 -0
  680. package/dist/utils/math/algebra/galines.js +32 -0
  681. package/dist/utils/math/algebra/gapoints.d.ts +8 -0
  682. package/dist/utils/math/algebra/gapoints.js +30 -0
  683. package/dist/utils/math/algebra/gatransforms.d.ts +10 -0
  684. package/dist/utils/math/algebra/gatransforms.js +23 -0
  685. package/dist/utils/math/algebra/index.d.ts +5 -0
  686. package/dist/utils/math/algebra/index.js +5 -0
  687. package/dist/utils/math/bbox.d.ts +10 -0
  688. package/dist/utils/math/bbox.js +42 -0
  689. package/dist/utils/math/geometry.d.ts +102 -0
  690. package/dist/utils/math/geometry.js +790 -0
  691. package/dist/utils/math/index.d.ts +323 -0
  692. package/dist/utils/math/index.js +1188 -0
  693. package/dist/utils/math/random.d.ts +4 -0
  694. package/dist/utils/math/random.js +25 -0
  695. package/dist/utils/normalize.d.ts +14 -0
  696. package/dist/utils/normalize.js +49 -0
  697. package/dist/utils/shape.d.ts +15 -0
  698. package/dist/utils/shape.js +254 -0
  699. package/dist/utils/state/grid.d.ts +7 -0
  700. package/dist/utils/state/grid.js +25 -0
  701. package/dist/utils/state/index.d.ts +9 -0
  702. package/dist/utils/state/index.js +131 -0
  703. package/dist/utils/url.d.ts +8 -0
  704. package/dist/utils/url.js +33 -0
  705. package/dist/utils/version.d.ts +1 -0
  706. package/dist/utils/version.js +1 -0
  707. package/package.json +79 -0
@@ -0,0 +1,1188 @@
1
+ export * from "./geometry";
2
+ export * from "./bbox";
3
+ export * from "./algebra";
4
+ export * from "./random";
5
+ import { LINE_CONFIRM_THRESHOLD } from "ducjs/utils/constants";
6
+ import { pointFrom } from "ducjs/utils/math/geometry";
7
+ import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "ducjs/technical/scopes";
8
+ export const getRadianFromDegrees = (degrees) => {
9
+ return degrees * (Math.PI / 180);
10
+ };
11
+ export const getDegreesFromRadian = (radian) => {
12
+ return radian * (180 / Math.PI);
13
+ };
14
+ export const getPercentageValueFromPercentage = (value) => {
15
+ return value / 100;
16
+ };
17
+ export const getPercentageFromPercentage = (percentage) => {
18
+ return percentage * 100;
19
+ };
20
+ export const med = (A, B) => {
21
+ return [(A[0] + B[0]) / 2, (A[1] + B[1]) / 2];
22
+ };
23
+ /**
24
+ * Rotates a point (x, y) around another point (cx, cy) by a given angle.
25
+ * Returns the rotated point as a Point object.
26
+ */
27
+ // 𝑎′𝑥=(𝑎𝑥−𝑐𝑥)cos𝜃−(𝑎𝑦−𝑐𝑦)sin𝜃+𝑐𝑥
28
+ // 𝑎′𝑦=(𝑎𝑥−𝑐𝑥)sin𝜃+(𝑎𝑦−𝑐𝑦)cos𝜃+𝑐𝑦.
29
+ // https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
30
+ export const rotate = (
31
+ // Target point to rotate
32
+ x, y,
33
+ // Point to rotate against
34
+ cx, cy, angle) => ({
35
+ x: (x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
36
+ y: (x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy,
37
+ });
38
+ /**
39
+ * Rotates a Point around another Point by a given angle.
40
+ * Returns the rotated point as a Point object.
41
+ */
42
+ export const rotatePoint = (point, center, angle) => rotate(point.x, point.y, center.x, center.y, angle);
43
+ export const getSizeFromPoints = (points) => {
44
+ const xs = points.map((point) => point.x);
45
+ const ys = points.map((point) => point.y);
46
+ return {
47
+ width: Math.max(...xs) - Math.min(...xs),
48
+ height: Math.max(...ys) - Math.min(...ys),
49
+ };
50
+ };
51
+ /** @arg dimension, 0 for rescaling only x, 1 for y */
52
+ export const rescalePoints = (dimension, newSize, points, normalize, elementScope, currentScope) => {
53
+ const coordinates = points.map((point) => point[dimension].scoped);
54
+ const maxCoordinate = Math.max(...coordinates);
55
+ const minCoordinate = Math.min(...coordinates);
56
+ const size = maxCoordinate - minCoordinate;
57
+ const scale = size === 0 ? 1 : newSize / size;
58
+ const scaledPoints = points.map((point) => {
59
+ const newPoint = Object.assign({}, point);
60
+ newPoint[dimension] = getPrecisionValueFromScoped((point[dimension].scoped * scale), elementScope, currentScope);
61
+ return newPoint;
62
+ });
63
+ if (!normalize || points.length === 0) {
64
+ return scaledPoints;
65
+ }
66
+ // With normalization, we move the points so that the first point
67
+ // is at the same position as original.
68
+ const translation = (points[0][dimension].scoped -
69
+ scaledPoints[0][dimension].scoped);
70
+ const nextPoints = scaledPoints.map((scaledPoint) => {
71
+ const translatedPoint = Object.assign(Object.assign({}, scaledPoint), { [dimension]: getPrecisionValueFromScoped((scaledPoint[dimension].scoped + translation), elementScope, currentScope) });
72
+ return translatedPoint;
73
+ });
74
+ return nextPoints;
75
+ };
76
+ // Helper function to rescale DucLine handles
77
+ export const rescaleLines = (dimension, newSize, lines, points, normalize, elementScope, currentScope) => {
78
+ const coordinates = points.map((point) => point[dimension].scoped);
79
+ const maxCoordinate = Math.max(...coordinates);
80
+ const minCoordinate = Math.min(...coordinates);
81
+ const size = maxCoordinate - minCoordinate;
82
+ const scale = size === 0 ? 1 : newSize / size;
83
+ let translation = 0;
84
+ if (normalize && points.length > 0) {
85
+ const scaledFirstPointCoordinate = points[0][dimension].scoped * scale;
86
+ translation = (points[0][dimension].scoped -
87
+ scaledFirstPointCoordinate);
88
+ }
89
+ const scaledLines = lines.map((line) => {
90
+ const [start, end] = line;
91
+ const scaledStart = Object.assign(Object.assign({}, start), { handle: start.handle ? Object.assign(Object.assign({}, start.handle), { [dimension]: getPrecisionValueFromScoped((start.handle[dimension].scoped * scale + translation), elementScope, currentScope) }) : null });
92
+ const scaledEnd = Object.assign(Object.assign({}, end), { handle: end.handle ? Object.assign(Object.assign({}, end.handle), { [dimension]: getPrecisionValueFromScoped((end.handle[dimension].scoped * scale + translation), elementScope, currentScope) }) : null });
93
+ return [scaledStart, scaledEnd];
94
+ });
95
+ return scaledLines;
96
+ };
97
+ /**
98
+ * Calculates the distance from a point to a line segment
99
+ * @param point The point to check distance from
100
+ * @param start Start point of line segment
101
+ * @param end End point of line segment
102
+ * @returns Distance from point to line segment
103
+ */
104
+ export function distanceToLineSegment(point, start, end) {
105
+ const A = point.x - start.x;
106
+ const B = point.y - start.y;
107
+ const C = end.x - start.x;
108
+ const D = end.y - start.y;
109
+ const dot = A * C + B * D;
110
+ const lenSq = C * C + D * D;
111
+ let param = -1;
112
+ if (lenSq !== 0) {
113
+ param = dot / lenSq;
114
+ }
115
+ let xx, yy;
116
+ if (param < 0) {
117
+ xx = start.x;
118
+ yy = start.y;
119
+ }
120
+ else if (param > 1) {
121
+ xx = end.x;
122
+ yy = end.y;
123
+ }
124
+ else {
125
+ xx = start.x + param * C;
126
+ yy = start.y + param * D;
127
+ }
128
+ const dx = point.x - xx;
129
+ const dy = point.y - yy;
130
+ return Math.sqrt(dx * dx + dy * dy);
131
+ }
132
+ /**
133
+ * Calculates the distance from a point to a cubic Bezier curve segment
134
+ * @param point The point to check distance from
135
+ * @param start Start point of Bezier curve
136
+ * @param end End point of Bezier curve
137
+ * @param cp1 First control point
138
+ * @param cp2 Second control point
139
+ * @param numSamples Number of samples to use for approximation
140
+ * @returns Approximate distance from point to Bezier curve
141
+ */
142
+ export function distanceToCurveSegment(point, start, end, cp1, cp2, numSamples = 30) {
143
+ // Sample points along the curve
144
+ const samples = sampleBezierCurve(start, cp1, cp2, end, numSamples);
145
+ // Find the minimum distance to any line segment in the sampled curve
146
+ let minDistance = Infinity;
147
+ for (let i = 0; i < samples.length - 1; i++) {
148
+ const distance = distanceToLineSegment(point, samples[i], samples[i + 1]);
149
+ minDistance = Math.min(minDistance, distance);
150
+ }
151
+ return minDistance;
152
+ }
153
+ /**
154
+ * Samples points along a cubic Bezier curve using De Casteljau's algorithm
155
+ * More precise than the sampleBezierCurve in bounds.ts, but used only for distance calculations
156
+ */
157
+ export function sampleBezierCurve(start, cp1, cp2, end, numSamples) {
158
+ const result = [];
159
+ // Calculate curve complexity for adaptive sampling
160
+ const curvature = calculateCurveComplexity(start, cp1, cp2, end);
161
+ // Increase the maximum number of samples from 50 to 100 for high-curvature paths
162
+ const adaptiveNumSamples = Math.min(100, Math.max(numSamples, Math.ceil(numSamples * curvature)));
163
+ for (let i = 0; i <= adaptiveNumSamples; i++) {
164
+ const t = i / adaptiveNumSamples;
165
+ result.push(evaluateBezier(start, cp1, cp2, end, t));
166
+ }
167
+ return result;
168
+ }
169
+ /**
170
+ * Evaluates a point at parameter t on the cubic Bezier curve
171
+ */
172
+ export function evaluateBezier(p0, p1, p2, p3, t) {
173
+ const mt = 1 - t;
174
+ const mt2 = mt * mt;
175
+ const mt3 = mt2 * mt;
176
+ const t2 = t * t;
177
+ const t3 = t2 * t;
178
+ return {
179
+ x: mt3 * p0.x + 3 * mt2 * t * p1.x + 3 * mt * t2 * p2.x + t3 * p3.x,
180
+ y: mt3 * p0.y + 3 * mt2 * t * p1.y + 3 * mt * t2 * p2.y + t3 * p3.y
181
+ };
182
+ }
183
+ /**
184
+ * Calculates the approximate complexity of a Bezier curve to determine sampling rate
185
+ */
186
+ export function calculateCurveComplexity(start, cp1, cp2, end) {
187
+ // A simple heuristic for complexity: the sum of the distances
188
+ // from the control points to the line connecting the start and end points
189
+ const baseline = distanceToLineSegment(cp1, start, end) + distanceToLineSegment(cp2, start, end);
190
+ const chordLength = Math.hypot(end.x - start.x, end.y - start.y);
191
+ // Normalize by chord length to make it scale-invariant
192
+ return chordLength > 0 ? baseline / chordLength : 1;
193
+ }
194
+ /**
195
+ * Helper function to calculate the distance from a point to a line
196
+ */
197
+ export function distanceFromPointToLine(point, lineStart, lineEnd) {
198
+ const { x: x0, y: y0 } = point;
199
+ const { x: x1, y: y1 } = lineStart;
200
+ const { x: x2, y: y2 } = lineEnd;
201
+ const numerator = Math.abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1);
202
+ const denominator = Math.sqrt(Math.pow(y2 - y1, 2) + Math.pow(x2 - x1, 2));
203
+ return denominator === 0 ? 0 : numerator / denominator;
204
+ }
205
+ /**
206
+ * Adaptive sampling for bounds (from bounds.ts)
207
+ * This is different from the distance version above.
208
+ */
209
+ export function sampleBezierCurveForBounds(start, cp1, cp2, end, numSamples = 10 // Base number of samples
210
+ ) {
211
+ // Calculate curve complexity to determine adaptive sampling
212
+ const curvature = calculateCurvature(start, cp1, cp2, end);
213
+ // Adjust sampling based on curve complexity
214
+ // More complex curves get more samples for better accuracy
215
+ // Kept cap at 40 to avoid excessive segments during selection/collision checks
216
+ const adaptiveNumSamples = Math.max(numSamples, Math.min(40, Math.ceil(numSamples * curvature)));
217
+ const points = [];
218
+ for (let i = 0; i <= adaptiveNumSamples; i++) {
219
+ const t = i / adaptiveNumSamples;
220
+ points.push(getBezierPoint(start, cp1, cp2, end, t));
221
+ }
222
+ return points;
223
+ }
224
+ /**
225
+ * Calculate approximate curve complexity based on control point positions (from bounds.ts)
226
+ */
227
+ export function calculateCurvature(start, cp1, cp2, end) {
228
+ // Calculate distances from control points to the line segment
229
+ const lineLength = Math.hypot(end.x - start.x, end.y - start.y);
230
+ if (lineLength === 0)
231
+ return 1; // Prevent division by zero
232
+ // Project control points onto the line segment
233
+ const projectPoint = (p) => {
234
+ const dx = end.x - start.x;
235
+ const dy = end.y - start.y;
236
+ const t = ((p.x - start.x) * dx + (p.y - start.y) * dy) / (dx * dx + dy * dy);
237
+ return Math.max(0, Math.min(1, t));
238
+ };
239
+ const proj1 = projectPoint(cp1);
240
+ const proj2 = projectPoint(cp2);
241
+ // Calculate distance from control points to line
242
+ const distanceToLine = (p, t) => {
243
+ const projX = start.x + t * (end.x - start.x);
244
+ const projY = start.y + t * (end.y - start.y);
245
+ return Math.hypot(p.x - projX, p.y - projY);
246
+ };
247
+ const dist1 = distanceToLine(cp1, proj1);
248
+ const dist2 = distanceToLine(cp2, proj2);
249
+ // Normalize by line length to get relative curvature
250
+ const normalizedCurvature = Math.max(dist1, dist2) / lineLength;
251
+ // Return a scaling factor between 1 and 4 for sampling
252
+ return 1 + Math.min(3, normalizedCurvature * 10);
253
+ }
254
+ /**
255
+ * Get a point on a cubic bezier at t (from bounds.ts)
256
+ */
257
+ export function getBezierPoint(start, cp1, cp2, end, t) {
258
+ const mt = 1 - t;
259
+ return {
260
+ x: mt * mt * mt * start.x +
261
+ 3 * mt * mt * t * cp1.x +
262
+ 3 * mt * t * t * cp2.x +
263
+ t * t * t * end.x,
264
+ y: mt * mt * mt * start.y +
265
+ 3 * mt * mt * t * cp1.y +
266
+ 3 * mt * t * t * cp2.y +
267
+ t * t * t * end.y,
268
+ };
269
+ }
270
+ /**
271
+ * Quadratic bezier bounding box (from bounds.ts)
272
+ * Enhanced version that handles edge cases better
273
+ */
274
+ export function getQuadraticBezierBoundingBox(p0, p1, p2) {
275
+ const tValues = [];
276
+ // Find critical points where the derivative is zero
277
+ for (const coord of ['x', 'y']) {
278
+ // Derivative of quadratic Bézier: 2(1-t)(P1-P0) + 2t(P2-P1)
279
+ // Setting to zero: 2(P1-P0) - 2t(P1-P0) + 2t(P2-P1) = 0
280
+ // Simplifying: (P1-P0) + t(P2-2P1+P0) = 0
281
+ const a = p0[coord] - 2 * p1[coord] + p2[coord];
282
+ const b = 2 * (p1[coord] - p0[coord]);
283
+ if (Math.abs(a) < 1e-10)
284
+ continue; // No critical point if a ≈ 0
285
+ const t = -b / (2 * a);
286
+ if (t > 0 && t < 1)
287
+ tValues.push(t);
288
+ }
289
+ // Start with endpoints
290
+ const xValues = [p0.x, p2.x];
291
+ const yValues = [p0.y, p2.y];
292
+ // Add values at critical points
293
+ for (const t of tValues) {
294
+ const x = (1 - t) * (1 - t) * p0.x + 2 * (1 - t) * t * p1.x + t * t * p2.x;
295
+ const y = (1 - t) * (1 - t) * p0.y + 2 * (1 - t) * t * p1.y + t * t * p2.y;
296
+ xValues.push(x);
297
+ yValues.push(y);
298
+ }
299
+ // For extra safety, sample a few additional points
300
+ const samplePoints = [0.25, 0.5, 0.75];
301
+ for (const t of samplePoints) {
302
+ const x = (1 - t) * (1 - t) * p0.x + 2 * (1 - t) * t * p1.x + t * t * p2.x;
303
+ const y = (1 - t) * (1 - t) * p0.y + 2 * (1 - t) * t * p1.y + t * t * p2.y;
304
+ xValues.push(x);
305
+ yValues.push(y);
306
+ }
307
+ return {
308
+ minX: Math.min(...xValues),
309
+ minY: Math.min(...yValues),
310
+ maxX: Math.max(...xValues),
311
+ maxY: Math.max(...yValues),
312
+ };
313
+ }
314
+ /**
315
+ * Cubic bezier bounding box (from bounds.ts)
316
+ * Enhanced version that handles edge cases better
317
+ */
318
+ export function getCubicBezierBoundingBox(p0, p1, p2, p3) {
319
+ const tValues = [];
320
+ // Find critical points where the derivative is zero
321
+ for (const coord of ['x', 'y']) {
322
+ // Derivative of cubic Bézier: 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)
323
+ // Setting to zero and solving for t gives us: at² + bt + c = 0
324
+ const a = -3 * p0[coord] + 9 * p1[coord] - 9 * p2[coord] + 3 * p3[coord];
325
+ const b = 6 * p0[coord] - 12 * p1[coord] + 6 * p2[coord];
326
+ const c = 3 * p1[coord] - 3 * p0[coord];
327
+ if (Math.abs(a) < 1e-10) {
328
+ // Linear case: bt + c = 0
329
+ if (Math.abs(b) > 1e-10) {
330
+ const t = -c / b;
331
+ if (t > 0 && t < 1)
332
+ tValues.push(t);
333
+ }
334
+ continue;
335
+ }
336
+ const discriminant = b * b - 4 * a * c;
337
+ if (discriminant < 0)
338
+ continue;
339
+ const sqrtDiscriminant = Math.sqrt(discriminant);
340
+ const t1 = (-b + sqrtDiscriminant) / (2 * a);
341
+ const t2 = (-b - sqrtDiscriminant) / (2 * a);
342
+ if (t1 > 0 && t1 < 1)
343
+ tValues.push(t1);
344
+ if (t2 > 0 && t2 < 1)
345
+ tValues.push(t2);
346
+ }
347
+ // Start with endpoints
348
+ const xValues = [p0.x, p3.x];
349
+ const yValues = [p0.y, p3.y];
350
+ // Add values at critical points
351
+ for (const t of tValues) {
352
+ const point = getBezierPoint(p0, p1, p2, p3, t);
353
+ xValues.push(point.x);
354
+ yValues.push(point.y);
355
+ }
356
+ // For extra safety with complex curves, sample a few additional points
357
+ // This helps catch cases where the mathematical solution might miss extrema
358
+ const samplePoints = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
359
+ for (const t of samplePoints) {
360
+ const point = getBezierPoint(p0, p1, p2, p3, t);
361
+ xValues.push(point.x);
362
+ yValues.push(point.y);
363
+ }
364
+ return {
365
+ minX: Math.min(...xValues),
366
+ minY: Math.min(...yValues),
367
+ maxX: Math.max(...xValues),
368
+ maxY: Math.max(...yValues),
369
+ };
370
+ }
371
+ /**
372
+ * Cubic bezier curve bound (returns Bounds tuple, from bounds.ts)
373
+ */
374
+ export function getCubicBezierCurveBound(p0, p1, p2, p3) {
375
+ const solX = solveQuadratic(p0.x, p1.x, p2.x, p3.x);
376
+ const solY = solveQuadratic(p0.y, p1.y, p2.y, p3.y);
377
+ let minX = Math.min(p0.x, p3.x);
378
+ let maxX = Math.max(p0.x, p3.x);
379
+ if (solX) {
380
+ const xs = solX.filter((x) => x !== null);
381
+ minX = Math.min(minX, ...xs);
382
+ maxX = Math.max(maxX, ...xs);
383
+ }
384
+ let minY = Math.min(p0.y, p3.y);
385
+ let maxY = Math.max(p0.y, p3.y);
386
+ if (solY) {
387
+ const ys = solY.filter((y) => y !== null);
388
+ minY = Math.min(minY, ...ys);
389
+ maxY = Math.max(maxY, ...ys);
390
+ }
391
+ return [minX, minY, maxX, maxY];
392
+ }
393
+ // Helper for getCubicBezierCurveBound
394
+ function solveQuadratic(p0, p1, p2, p3) {
395
+ const i = p1 - p0;
396
+ const j = p2 - p1;
397
+ const k = p3 - p2;
398
+ const a = 3 * i - 6 * j + 3 * k;
399
+ const b = 6 * j - 6 * i;
400
+ const c = 3 * i;
401
+ const sqrtPart = b * b - 4 * a * c;
402
+ const hasSolution = sqrtPart >= 0;
403
+ if (!hasSolution) {
404
+ return false;
405
+ }
406
+ let s1 = null;
407
+ let s2 = null;
408
+ let t1 = Infinity;
409
+ let t2 = Infinity;
410
+ if (a === 0) {
411
+ t1 = t2 = -c / b;
412
+ }
413
+ else {
414
+ t1 = (-b + Math.sqrt(sqrtPart)) / (2 * a);
415
+ t2 = (-b - Math.sqrt(sqrtPart)) / (2 * a);
416
+ }
417
+ if (t1 >= 0 && t1 <= 1) {
418
+ s1 = getBezierValueForT(t1, p0, p1, p2, p3);
419
+ }
420
+ if (t2 >= 0 && t2 <= 1) {
421
+ s2 = getBezierValueForT(t2, p0, p1, p2, p3);
422
+ }
423
+ return [s1, s2];
424
+ }
425
+ // Helper for solveQuadratic
426
+ function getBezierValueForT(t, p0, p1, p2, p3) {
427
+ const oneMinusT = 1 - t;
428
+ return (Math.pow(oneMinusT, 3) * p0 +
429
+ 3 * Math.pow(oneMinusT, 2) * t * p1 +
430
+ 3 * oneMinusT * Math.pow(t, 2) * p2 +
431
+ Math.pow(t, 3) * p3);
432
+ }
433
+ export const isPointCurved = (element, pointIndex) => {
434
+ return element.lines.some(line => (line[0].index === pointIndex && line[0].handle) ||
435
+ (line[1].index === pointIndex && line[1].handle));
436
+ };
437
+ /**
438
+ * Gets the bezier handles for a point from the lines array
439
+ */
440
+ export const getPointHandles = (element, pointIndex) => {
441
+ const handles = {};
442
+ // Find lines that connect to this point
443
+ for (const line of element.lines) {
444
+ const [start, end] = line;
445
+ // Check if this point is the start of the line
446
+ if (start.index === pointIndex && start.handle) {
447
+ handles.handleOut = {
448
+ x: start.handle.x.scoped,
449
+ y: start.handle.y.scoped,
450
+ };
451
+ }
452
+ // Check if this point is the end of the line
453
+ if (end.index === pointIndex && end.handle) {
454
+ handles.handleIn = {
455
+ x: end.handle.x.scoped,
456
+ y: end.handle.y.scoped,
457
+ };
458
+ }
459
+ }
460
+ return handles;
461
+ };
462
+ /**
463
+ * Gets connected point indices from the lines array
464
+ */
465
+ export const getConnectedPoints = (element, pointIndex) => {
466
+ const connections = [];
467
+ for (const line of element.lines) {
468
+ const [start, end] = line;
469
+ if (start.index === pointIndex) {
470
+ connections.push(end.index);
471
+ }
472
+ else if (end.index === pointIndex) {
473
+ connections.push(start.index);
474
+ }
475
+ }
476
+ return connections;
477
+ };
478
+ /* Rotate a point by [angle] radians.
479
+ *
480
+ * @param point The point to rotate
481
+ * @param center The point to rotate around, the center point
482
+ * @param angle The radians to rotate the point by
483
+ * @returns The rotated point
484
+ */
485
+ export function pointRotateRads(point, center, angle) {
486
+ return pointFrom((point.x - center.x) * Math.cos(angle) - (point.y - center.y) * Math.sin(angle) + center.x, (point.x - center.x) * Math.sin(angle) + (point.y - center.y) * Math.cos(angle) + center.y);
487
+ }
488
+ export const distanceSq = (p1, p2) => {
489
+ const dx = p1.x - p2.x;
490
+ const dy = p1.y - p2.y;
491
+ return dx * dx + dy * dy;
492
+ };
493
+ export const distanceToLineSegmentSq = (p, a, b) => {
494
+ const l2 = distanceSq(a, b);
495
+ if (l2 === 0) {
496
+ return distanceSq(p, a);
497
+ }
498
+ let t = ((p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y)) / l2;
499
+ t = Math.max(0, Math.min(1, t));
500
+ const projection = {
501
+ x: a.x + t * (b.x - a.x),
502
+ y: a.y + t * (b.y - a.y),
503
+ };
504
+ return distanceSq(p, projection);
505
+ };
506
+ export const sampleQuadratic = (p0, p1, p2, samples, depth, maxDepth, toleranceSq) => {
507
+ if (depth >= maxDepth) {
508
+ samples.push(p2);
509
+ return;
510
+ }
511
+ const dSq = distanceToLineSegmentSq(p1, p0, p2);
512
+ if (dSq < toleranceSq) {
513
+ samples.push(p2);
514
+ return;
515
+ }
516
+ const p01 = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
517
+ const p12 = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
518
+ const mid = { x: (p01.x + p12.x) / 2, y: (p01.y + p12.y) / 2 };
519
+ sampleQuadratic(p0, p01, mid, samples, depth + 1, maxDepth, toleranceSq);
520
+ sampleQuadratic(mid, p12, p2, samples, depth + 1, maxDepth, toleranceSq);
521
+ };
522
+ export const sampleCubic = (p0, p1, p2, p3, samples, depth, maxDepth, toleranceSq) => {
523
+ if (depth >= maxDepth) {
524
+ samples.push(p3);
525
+ return;
526
+ }
527
+ const d1Sq = distanceToLineSegmentSq(p1, p0, p3);
528
+ const d2Sq = distanceToLineSegmentSq(p2, p0, p3);
529
+ if (d1Sq < toleranceSq && d2Sq < toleranceSq) {
530
+ samples.push(p3);
531
+ return;
532
+ }
533
+ const p01 = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
534
+ const p12 = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
535
+ const p23 = { x: (p2.x + p3.x) / 2, y: (p2.y + p3.y) / 2 };
536
+ const p012 = { x: (p01.x + p12.x) / 2, y: (p01.y + p12.y) / 2 };
537
+ const p123 = { x: (p12.x + p23.x) / 2, y: (p12.y + p23.y) / 2 };
538
+ const mid = { x: (p012.x + p123.x) / 2, y: (p012.y + p123.y) / 2 };
539
+ sampleCubic(p0, p01, p012, mid, samples, depth + 1, maxDepth, toleranceSq);
540
+ sampleCubic(mid, p123, p23, p3, samples, depth + 1, maxDepth, toleranceSq);
541
+ };
542
+ /**
543
+ * Adjusts x and y coordinates based on rotation and deltas.
544
+ * Returns the adjusted coordinates as a Point object.
545
+ */
546
+ export const adjustXYWithRotation = (sides, x, y, angle, deltaX1, deltaY1, deltaX2, deltaY2) => {
547
+ const cos = Math.cos(angle);
548
+ const sin = Math.sin(angle);
549
+ if (sides.e && sides.w) {
550
+ x += deltaX1 + deltaX2;
551
+ }
552
+ else if (sides.e) {
553
+ x += deltaX1 * (1 + cos);
554
+ y += deltaX1 * sin;
555
+ x += deltaX2 * (1 - cos);
556
+ y += deltaX2 * -sin;
557
+ }
558
+ else if (sides.w) {
559
+ x += deltaX1 * (1 - cos);
560
+ y += deltaX1 * -sin;
561
+ x += deltaX2 * (1 + cos);
562
+ y += deltaX2 * sin;
563
+ }
564
+ if (sides.n && sides.s) {
565
+ y += deltaY1 + deltaY2;
566
+ }
567
+ else if (sides.n) {
568
+ x += deltaY1 * sin;
569
+ y += deltaY1 * (1 - cos);
570
+ x += deltaY2 * -sin;
571
+ y += deltaY2 * (1 + cos);
572
+ }
573
+ else if (sides.s) {
574
+ x += deltaY1 * -sin;
575
+ y += deltaY1 * (1 + cos);
576
+ x += deltaY2 * sin;
577
+ y += deltaY2 * (1 - cos);
578
+ }
579
+ return { x, y };
580
+ };
581
+ /**
582
+ * Finds a point on a path.
583
+ * Returns an object with x, y, and the segment index if found, else null.
584
+ */
585
+ export const getPointOnAPath = (point, path) => {
586
+ const { x: px, y: py } = point;
587
+ const [start, ...other] = path;
588
+ let { x: lastX, y: lastY } = start;
589
+ let kLine = 0;
590
+ let idx = 0;
591
+ // If any item in the array is true, it means that a point is
592
+ // on some segment of a line-based path
593
+ const retVal = other.some(({ x: x2, y: y2 }, i) => {
594
+ // We always take a line when dealing with line segments
595
+ const x1 = lastX;
596
+ const y1 = lastY;
597
+ lastX = x2;
598
+ lastY = y2;
599
+ // If a point is not within the domain of the line segment
600
+ // it is not on the line segment
601
+ if (px < x1 || px > x2) {
602
+ return false;
603
+ }
604
+ // check if all points lie on the same line
605
+ // y1 = kx1 + b, y2 = kx2 + b
606
+ // y2 - y1 = k(x2 - x2) -> k = (y2 - y1) / (x2 - x1)
607
+ // Coefficient for the line (p0, p1)
608
+ const kL = (y2 - y1) / (x2 - x1);
609
+ // Coefficient for the line segment (p0, point)
610
+ const kP1 = (py - y1) / (px - x1);
611
+ // Coefficient for the line segment (point, p1)
612
+ const kP2 = (py - y2) / (px - x2);
613
+ // Because we are basing both lines from the same starting point
614
+ // the only option for collinearity is having same coefficients
615
+ // Using it for floating point comparisons
616
+ const epsilon = 0.3;
617
+ // If coefficient is more than an arbitrary epsilon,
618
+ // these lines are not collinear
619
+ if (Math.abs(kP1 - kL) > epsilon && Math.abs(kP2 - kL) > epsilon) {
620
+ return false;
621
+ }
622
+ // Store the coefficient because we are going to need it
623
+ kLine = kL;
624
+ idx = i;
625
+ return true;
626
+ });
627
+ // Return a coordinate that is always on the line segment
628
+ if (retVal === true) {
629
+ return { x: point.x, y: kLine * point.x, segment: idx };
630
+ }
631
+ return null;
632
+ };
633
+ /**
634
+ * Calculates the Euclidean distance between two points.
635
+ */
636
+ export const distance2d = (x1, y1, x2, y2) => {
637
+ const xd = x2 - x1;
638
+ const yd = y2 - y1;
639
+ return Math.hypot(xd, yd);
640
+ };
641
+ /**
642
+ * Calculates the squared Euclidean distance between two Points.
643
+ */
644
+ export const distanceSq2d = (p1, p2) => {
645
+ const xd = p2.x - p1.x;
646
+ const yd = p2.y - p1.y;
647
+ return xd * xd + yd * yd;
648
+ };
649
+ /**
650
+ * Calculates the center point between two Points.
651
+ */
652
+ export const centerPoint = (a, b) => ({
653
+ x: (a.x + b.x) / 2,
654
+ y: (a.y + b.y) / 2,
655
+ });
656
+ /**
657
+ * Checks if the first and last point are close enough to be considered a loop.
658
+ */
659
+ export const isPathALoop = (points,
660
+ /** Supply if you want the loop detection to account for current zoom */
661
+ zoomValue = 1, elementScope, currentScope) => {
662
+ if (points.length >= 3) {
663
+ const [first, last] = [points[0], points[points.length - 1]];
664
+ const lineConfirmThreshold = getPrecisionValueFromRaw(LINE_CONFIRM_THRESHOLD, elementScope, currentScope);
665
+ const distance = distance2d(first.x.scoped, first.y.scoped, last.x.scoped, last.y.scoped);
666
+ // Adjusting LINE_CONFIRM_THRESHOLD to current zoom so that when zoomed in
667
+ // really close we make the threshold smaller, and vice versa.
668
+ return distance <= lineConfirmThreshold.scoped / zoomValue;
669
+ }
670
+ return false;
671
+ };
672
+ /**
673
+ * Determines if a Point is inside a Polygon defined by an array of Points.
674
+ */
675
+ export const isPointInPolygon = (points, x, y) => {
676
+ const vertices = points.length;
677
+ // There must be at least 3 vertices in polygon
678
+ if (vertices < 3) {
679
+ return false;
680
+ }
681
+ const extreme = { x: Number.MAX_SAFE_INTEGER, y };
682
+ const p = { x, y };
683
+ let count = 0;
684
+ for (let i = 0; i < vertices; i++) {
685
+ const current = points[i];
686
+ const next = points[(i + 1) % vertices];
687
+ if (doSegmentsIntersect(current, next, p, extreme)) {
688
+ if (orderedColinearOrientation(current, p, next) === 0) {
689
+ return isPointWithinBounds(current, p, next);
690
+ }
691
+ count++;
692
+ }
693
+ }
694
+ // True if count is odd
695
+ return count % 2 === 1;
696
+ };
697
+ /**
698
+ * Returns whether `q` lies inside the segment/rectangle defined by `p` and `r`.
699
+ * This is an approximation to "does `q` lie on a segment `pr`" check.
700
+ */
701
+ export const isPointWithinBounds = (p, q, r) => {
702
+ return (q.x <= Math.max(p.x, r.x) &&
703
+ q.x >= Math.min(p.x, r.x) &&
704
+ q.y <= Math.max(p.y, r.y) &&
705
+ q.y >= Math.min(p.y, r.y));
706
+ };
707
+ /**
708
+ * For the ordered points p, q, r, returns
709
+ * 0 if p, q, r are colinear
710
+ * 1 if Clockwise
711
+ * 2 if counterclockwise
712
+ */
713
+ const orderedColinearOrientation = (p, q, r) => {
714
+ const val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
715
+ if (val === 0) {
716
+ return 0;
717
+ }
718
+ return val > 0 ? 1 : 2;
719
+ };
720
+ /**
721
+ * Checks if two segments p1q1 and p2q2 intersect.
722
+ */
723
+ const doSegmentsIntersect = (p1, q1, p2, q2) => {
724
+ const o1 = orderedColinearOrientation(p1, q1, p2);
725
+ const o2 = orderedColinearOrientation(p1, q1, q2);
726
+ const o3 = orderedColinearOrientation(p2, q2, p1);
727
+ const o4 = orderedColinearOrientation(p2, q2, q1);
728
+ if (o1 !== o2 && o3 !== o4) {
729
+ return true;
730
+ }
731
+ // p1, q1 and p2 are colinear and p2 lies on segment p1q1
732
+ if (o1 === 0 && isPointWithinBounds(p1, p2, q1)) {
733
+ return true;
734
+ }
735
+ // p1, q1 and p2 are colinear and q2 lies on segment p1q1
736
+ if (o2 === 0 && isPointWithinBounds(p1, q2, q1)) {
737
+ return true;
738
+ }
739
+ // p2, q2 and p1 are colinear and p1 lies on segment p2q2
740
+ if (o3 === 0 && isPointWithinBounds(p2, p1, q2)) {
741
+ return true;
742
+ }
743
+ // p2, q2 and q1 are colinear and q1 lies on segment p2q2
744
+ if (o4 === 0 && isPointWithinBounds(p2, q1, q2)) {
745
+ return true;
746
+ }
747
+ return false;
748
+ };
749
+ /**
750
+ * Rounds a point to the nearest grid point based on gridSize.
751
+ */
752
+ export const getGridPoint = (x, y, gridSize) => {
753
+ if (gridSize) {
754
+ return {
755
+ x: Math.round(x / gridSize) * gridSize,
756
+ y: Math.round(y / gridSize) * gridSize,
757
+ };
758
+ }
759
+ return { x, y };
760
+ };
761
+ /**
762
+ * Calculates a point on a Bezier curve at parameter t.
763
+ * Returns the point as a Point object.
764
+ */
765
+ export const getBezierXY = (p0, p1, p2, p3, t) => {
766
+ const equation = (t, coord) => Math.pow(1 - t, 3) * p3[coord] +
767
+ 3 * t * Math.pow(1 - t, 2) * p2[coord] +
768
+ 3 * Math.pow(t, 2) * (1 - t) * p1[coord] +
769
+ p0[coord] * Math.pow(t, 3);
770
+ const tx = equation(t, "x");
771
+ const ty = equation(t, "y");
772
+ return { x: tx, y: ty };
773
+ };
774
+ /**
775
+ * Checks if two Points are equal based on their x and y coordinates.
776
+ */
777
+ export const arePointsEqual = (p1, p2, threshold = 0) => {
778
+ if (!p1 || !p2)
779
+ return false;
780
+ if (threshold === 0) {
781
+ return p1.x === p2.x && p1.y === p2.y;
782
+ }
783
+ return Math.abs(p1.x - p2.x) <= threshold && Math.abs(p1.y - p2.y) <= threshold;
784
+ };
785
+ /**
786
+ * Checks if an angle is a right angle (with floating point tolerance).
787
+ */
788
+ export const isRightAngle = (angle) => {
789
+ // If our angles were mathematically accurate, we could just check
790
+ //
791
+ // angle % (Math.PI / 2) === 0
792
+ //
793
+ // But since we're in floating point land, we need to round.
794
+ //
795
+ // Below, after dividing by Math.PI, a multiple of 0.5 indicates a right
796
+ // angle, which we can check with modulo after rounding.
797
+ return Math.round((angle / Math.PI) * 10000) % 5000 === 0;
798
+ };
799
+ /**
800
+ * Converts radians to degrees.
801
+ */
802
+ export const radianToDegree = (r) => {
803
+ return (r * 180) / Math.PI;
804
+ };
805
+ /**
806
+ * Converts degrees to radians.
807
+ */
808
+ export const degreeToRadian = (d) => {
809
+ return (d / 180) * Math.PI;
810
+ };
811
+ /**
812
+ * Given two ranges, returns if the two ranges overlap with each other.
813
+ * e.g. [1, 3] overlaps with [2, 4] while [1, 3] does not overlap with [4, 5]
814
+ */
815
+ export const rangesOverlap = ([a0, a1], [b0, b1]) => {
816
+ if (a0 <= b0) {
817
+ return a1 >= b0;
818
+ }
819
+ if (a0 >= b0) {
820
+ return b1 >= a0;
821
+ }
822
+ return false;
823
+ };
824
+ /**
825
+ * Given two ranges, returns the intersection of the two ranges if any.
826
+ * e.g. the intersection of [1, 3] and [2, 4] is [2, 3]
827
+ */
828
+ export const rangeIntersection = (rangeA, rangeB) => {
829
+ const rangeStart = Math.max(rangeA[0], rangeB[0]);
830
+ const rangeEnd = Math.min(rangeA[1], rangeB[1]);
831
+ if (rangeStart <= rangeEnd) {
832
+ return [rangeStart, rangeEnd];
833
+ }
834
+ return null;
835
+ };
836
+ /**
837
+ * Checks if a value is within a range [min, max].
838
+ */
839
+ export const isValueInRange = (value, min, max) => {
840
+ return value >= min && value <= max;
841
+ };
842
+ /**
843
+ * Translates a Point by a given Vector.
844
+ */
845
+ export const translatePoint = (p, v) => ({
846
+ x: p.x + v.x,
847
+ y: p.y + v.y,
848
+ });
849
+ /**
850
+ * Scales a Vector by a scalar.
851
+ */
852
+ export const scaleVector = (v, scalar) => ({
853
+ x: v.x * scalar,
854
+ y: v.y * scalar,
855
+ });
856
+ /**
857
+ * Converts a Point to a Vector relative to an origin.
858
+ */
859
+ export const pointToVector = (p, origin = { x: 0, y: 0 }) => ({
860
+ x: p.x - origin.x,
861
+ y: p.y - origin.y,
862
+ });
863
+ export const vectorToPoint = (v, origin = { x: 0, y: 0 }) => ({
864
+ x: v.x + origin.x,
865
+ y: v.y + origin.y,
866
+ });
867
+ export const headingToPoint = (heading) => ({
868
+ x: heading.x,
869
+ y: heading.y
870
+ });
871
+ /**
872
+ * Scales a Point from a midpoint by a multiplier.
873
+ */
874
+ export const scalePointFromOrigin = (p, mid, multiplier) => translatePoint(mid, scaleVector(pointToVector(p, mid), multiplier));
875
+ /**
876
+ * Calculates the sign of the triangle formed by three Points.
877
+ */
878
+ const triangleSign = (p1, p2, p3) => {
879
+ return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
880
+ };
881
+ /**
882
+ * Determines if a Point is inside a Triangle defined by three Points.
883
+ */
884
+ export const PointInTriangle = (pt, v1, v2, v3) => {
885
+ const d1 = triangleSign(pt, v1, v2);
886
+ const d2 = triangleSign(pt, v2, v3);
887
+ const d3 = triangleSign(pt, v3, v1);
888
+ const has_neg = d1 < 0 || d2 < 0 || d3 < 0;
889
+ const has_pos = d1 > 0 || d2 > 0 || d3 > 0;
890
+ return !(has_neg && has_pos);
891
+ };
892
+ /**
893
+ * Calculates the squared magnitude of a Vector.
894
+ */
895
+ export const magnitudeSq = (vector) => vector.x * vector.x + vector.y * vector.y;
896
+ /**
897
+ * Calculates the magnitude of a Vector.
898
+ */
899
+ export const magnitude = (vector) => Math.sqrt(magnitudeSq(vector));
900
+ /**
901
+ * Normalizes a Vector to unit length.
902
+ */
903
+ export const normalize = (vector) => {
904
+ const m = magnitude(vector);
905
+ return { x: vector.x / m, y: vector.y / m };
906
+ };
907
+ /**
908
+ * Adds two Vectors.
909
+ */
910
+ export const addVectors = (vec1, vec2) => ({ x: vec1.x + vec2.x, y: vec1.y + vec2.y });
911
+ /**
912
+ * Subtracts vec2 from vec1.
913
+ */
914
+ export const subtractVectors = (vec1, vec2) => ({ x: vec1.x - vec2.x, y: vec1.y - vec2.y });
915
+ /**
916
+ * Checks if a Point is inside given Bounds.
917
+ */
918
+ export const pointInsideBounds = (p, bounds) => p.x > bounds[0] && p.x < bounds[2] && p.y > bounds[1] && p.y < bounds[3];
919
+ /**
920
+ * Get the axis-aligned bounding box for a given element.
921
+ */
922
+ export const aabbForElement = (element, offset) => {
923
+ const bbox = {
924
+ minX: element.x.scoped,
925
+ minY: element.y.scoped,
926
+ maxX: element.x.scoped + element.width.scoped,
927
+ maxY: element.y.scoped + element.height.scoped,
928
+ midX: element.x.scoped + element.width.scoped / 2,
929
+ midY: element.y.scoped + element.height.scoped / 2,
930
+ };
931
+ const center = { x: bbox.midX, y: bbox.midY };
932
+ const topLeft = rotatePoint({ x: bbox.minX, y: bbox.minY }, center, element.angle);
933
+ const topRight = rotatePoint({ x: bbox.maxX, y: bbox.minY }, center, element.angle);
934
+ const bottomRight = rotatePoint({ x: bbox.maxX, y: bbox.maxY }, center, element.angle);
935
+ const bottomLeft = rotatePoint({ x: bbox.minX, y: bbox.maxY }, center, element.angle);
936
+ const bounds = [
937
+ Math.min(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x),
938
+ Math.min(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y),
939
+ Math.max(topLeft.x, topRight.x, bottomRight.x, bottomLeft.x),
940
+ Math.max(topLeft.y, topRight.y, bottomRight.y, bottomLeft.y),
941
+ ];
942
+ if (offset) {
943
+ const [topOffset, rightOffset, downOffset, leftOffset] = offset;
944
+ return [
945
+ bounds[0] - leftOffset,
946
+ bounds[1] - topOffset,
947
+ bounds[2] + rightOffset,
948
+ bounds[3] + downOffset,
949
+ ];
950
+ }
951
+ return bounds;
952
+ };
953
+ /**
954
+ * Returns the polar coordinates for the given cartesian point represented by
955
+ * (x, y) for the center point 0,0 where the first number returned is the radius,
956
+ * the second is the angle in radians.
957
+ */
958
+ export const carthesian2Polar = ({ x, y }) => [
959
+ Math.hypot(x, y),
960
+ Math.atan2(y, x),
961
+ ];
962
+ /**
963
+ * Determines if a carthesian point lies on a symmetric arc, i.e. an arc which
964
+ * is part of a circle contour centered on 0, 0.
965
+ */
966
+ export const isPointOnSymmetricArc = ({ radius: arcRadius, startAngle, endAngle }, point) => {
967
+ const [radius, angle] = carthesian2Polar(point);
968
+ return startAngle < endAngle
969
+ ? Math.abs(radius - arcRadius) < 0.0000001 &&
970
+ startAngle <= angle &&
971
+ endAngle >= angle
972
+ : startAngle <= angle || endAngle >= angle;
973
+ };
974
+ /**
975
+ * Gets the center point for given Bounds.
976
+ */
977
+ export const getCenterForBounds = (bounds) => ({
978
+ x: bounds[0] + (bounds[2] - bounds[0]) / 2,
979
+ y: bounds[1] + (bounds[3] - bounds[1]) / 2,
980
+ });
981
+ /**
982
+ * Gets the center point for a DucElement.
983
+ */
984
+ export const getCenterForElement = (element) => ({
985
+ x: element.x.scoped + element.width.scoped / 2,
986
+ y: element.y.scoped + element.height.scoped / 2,
987
+ });
988
+ /**
989
+ * Determines if two axis-aligned bounding boxes overlap.
990
+ */
991
+ export const aabbsOverlapping = (a, b) => pointInsideBounds({ x: a[0], y: a[1] }, b) ||
992
+ pointInsideBounds({ x: a[2], y: a[1] }, b) ||
993
+ pointInsideBounds({ x: a[2], y: a[3] }, b) ||
994
+ pointInsideBounds({ x: a[0], y: a[3] }, b) ||
995
+ pointInsideBounds({ x: b[0], y: b[1] }, a) ||
996
+ pointInsideBounds({ x: b[2], y: b[1] }, a) ||
997
+ pointInsideBounds({ x: b[2], y: b[3] }, a) ||
998
+ pointInsideBounds({ x: b[0], y: b[3] }, a);
999
+ /**
1000
+ * Clamps a value between min and max.
1001
+ */
1002
+ export const clamp = (value, min, max) => {
1003
+ return Math.min(Math.max(value, min), max);
1004
+ };
1005
+ /**
1006
+ * Rounds a value to a specified precision.
1007
+ */
1008
+ export const round = (value, precision) => {
1009
+ const multiplier = Math.pow(10, precision);
1010
+ return Math.round((value + Number.EPSILON) * multiplier) / multiplier;
1011
+ };
1012
+ export const fastRound = (num) => {
1013
+ return (num + 0.5) << 0;
1014
+ };
1015
+ export const polygonIncludesPointNonZero = (point, polygon) => {
1016
+ const [x, y] = point;
1017
+ let windingNumber = 0;
1018
+ for (let i = 0; i < polygon.length; i++) {
1019
+ const j = (i + 1) % polygon.length;
1020
+ const [xi, yi] = polygon[i];
1021
+ const [xj, yj] = polygon[j];
1022
+ if (yi <= y) {
1023
+ if (yj > y) {
1024
+ if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) > 0) {
1025
+ windingNumber++;
1026
+ }
1027
+ }
1028
+ }
1029
+ else if (yj <= y) {
1030
+ if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) < 0) {
1031
+ windingNumber--;
1032
+ }
1033
+ }
1034
+ }
1035
+ return windingNumber !== 0;
1036
+ };
1037
+ export const reverseExponent = (num) => {
1038
+ if (num === 0)
1039
+ return 0; // Handle zero case
1040
+ // Find the order of magnitude
1041
+ const magnitude = Math.abs(num);
1042
+ const log10 = Math.log10(magnitude);
1043
+ const exponent = Math.floor(log10);
1044
+ // Calculate opposite exponent
1045
+ return num * Math.pow(10, -2 * exponent);
1046
+ };
1047
+ /**
1048
+ * Retrieves control points for a Bezier curve.
1049
+ */
1050
+ export const getControlPointsForBezierCurve = (element, endPoint) => {
1051
+ const endPointIndex = element.points.findIndex((p) => arePointsEqual(getScopedBezierPointFromDucPoint(p), endPoint));
1052
+ if (endPointIndex < 1) {
1053
+ return null;
1054
+ }
1055
+ const startPointIndex = endPointIndex - 1;
1056
+ const line = element.lines.find((l) => (l[0].index === startPointIndex && l[1].index === endPointIndex) ||
1057
+ (l[0].index === endPointIndex && l[1].index === startPointIndex));
1058
+ if (!line || (!line[0].handle && !line[1].handle)) {
1059
+ return null;
1060
+ }
1061
+ const startRef = line[0].index === startPointIndex ? line[0] : line[1];
1062
+ const endRef = line[1].index === startPointIndex ? line[1] : line[0];
1063
+ const p0 = getScopedBezierPointFromDucPoint(element.points[startRef.index]);
1064
+ const p3 = getScopedBezierPointFromDucPoint(element.points[endRef.index]);
1065
+ if (startRef.handle && endRef.handle) {
1066
+ const p1 = getScopedBezierPointFromDucPoint(startRef.handle);
1067
+ const p2 = getScopedBezierPointFromDucPoint(endRef.handle);
1068
+ return [p0, p1, p2, p3];
1069
+ }
1070
+ // Quadratic bezier, we need to convert to cubic
1071
+ const p1 = getScopedBezierPointFromDucPoint(startRef.handle || endRef.handle);
1072
+ return [
1073
+ p0,
1074
+ { x: p0.x + 2 / 3 * (p1.x - p0.x), y: p0.y + 2 / 3 * (p1.y - p0.y) },
1075
+ { x: p3.x + 2 / 3 * (p1.x - p3.x), y: p3.y + 2 / 3 * (p1.y - p3.y) },
1076
+ p3
1077
+ ];
1078
+ };
1079
+ /**
1080
+ * Gets points along a Bezier curve for better accuracy.
1081
+ */
1082
+ export const getPointsInBezierCurve = (element, endPoint) => {
1083
+ const controlPoints = getControlPointsForBezierCurve(element, endPoint);
1084
+ if (!controlPoints) {
1085
+ return [];
1086
+ }
1087
+ const pointsOnCurve = [];
1088
+ let t = 1;
1089
+ // Take 20 points on curve for better accuracy
1090
+ while (t > 0) {
1091
+ const point = getBezierXY(controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3], t);
1092
+ pointsOnCurve.push({ x: point.x, y: point.y });
1093
+ t -= 0.05;
1094
+ }
1095
+ if (pointsOnCurve.length) {
1096
+ if (arePointsEqual(pointsOnCurve.at(-1), endPoint)) {
1097
+ pointsOnCurve.push({ x: endPoint.x, y: endPoint.y });
1098
+ }
1099
+ }
1100
+ return pointsOnCurve;
1101
+ };
1102
+ /**
1103
+ * Calculates the arc lengths of a Bezier curve.
1104
+ */
1105
+ export const getBezierCurveArcLengths = (element, endPoint) => {
1106
+ const arcLengths = [];
1107
+ arcLengths[0] = 0;
1108
+ const points = getPointsInBezierCurve(element, endPoint);
1109
+ let index = 0;
1110
+ let distance = 0;
1111
+ while (index < points.length - 1) {
1112
+ const segmentDistance = distance2d(points[index].x, points[index].y, points[index + 1].x, points[index + 1].y);
1113
+ distance += segmentDistance;
1114
+ arcLengths.push(distance);
1115
+ index++;
1116
+ }
1117
+ return arcLengths;
1118
+ };
1119
+ /**
1120
+ * Calculates the total length of a Bezier curve.
1121
+ */
1122
+ export const getBezierCurveLength = (element, endPoint) => {
1123
+ const arcLengths = getBezierCurveArcLengths(element, endPoint);
1124
+ return arcLengths.at(-1);
1125
+ };
1126
+ /**
1127
+ * Maps an interval to the corresponding t parameter on the Bezier curve based on length.
1128
+ */
1129
+ export const mapIntervalToBezierT = (element, endPoint, interval) => {
1130
+ const arcLengths = getBezierCurveArcLengths(element, endPoint);
1131
+ if (arcLengths.length === 0) {
1132
+ return interval;
1133
+ }
1134
+ const pointsCount = arcLengths.length - 1;
1135
+ const curveLength = arcLengths.at(-1);
1136
+ const targetLength = interval * curveLength;
1137
+ let low = 0;
1138
+ let high = pointsCount;
1139
+ let index = 0;
1140
+ // Doing a binary search to find the largest length that is less than the target length
1141
+ while (low < high) {
1142
+ index = Math.floor(low + (high - low) / 2);
1143
+ if (arcLengths[index] < targetLength) {
1144
+ low = index + 1;
1145
+ }
1146
+ else {
1147
+ high = index;
1148
+ }
1149
+ }
1150
+ if (arcLengths[index] > targetLength) {
1151
+ index--;
1152
+ }
1153
+ if (index < 0) {
1154
+ index = 0;
1155
+ }
1156
+ if (arcLengths[index] === targetLength) {
1157
+ return index / pointsCount;
1158
+ }
1159
+ if (arcLengths[index + 1] - arcLengths[index] === 0)
1160
+ return 1 - index / pointsCount;
1161
+ return (1 -
1162
+ (index +
1163
+ (targetLength - arcLengths[index]) /
1164
+ (arcLengths[index + 1] - arcLengths[index])) /
1165
+ pointsCount);
1166
+ };
1167
+ // Helper function to sample a point on a cubic Bézier curve
1168
+ export const sampleCubicBezier = (p0, p1, p2, p3, t) => {
1169
+ const u = 1 - t;
1170
+ const tt = t * t;
1171
+ const uu = u * u;
1172
+ const uuu = uu * u;
1173
+ const ttt = tt * t;
1174
+ return {
1175
+ x: uuu * p0.x + 3 * uu * t * p1.x + 3 * u * tt * p2.x + ttt * p3.x,
1176
+ y: uuu * p0.y + 3 * uu * t * p1.y + 3 * u * tt * p2.y + ttt * p3.y,
1177
+ };
1178
+ };
1179
+ // Helper function to sample a point on a quadratic Bézier curve
1180
+ export const sampleQuadraticBezier = (p0, p1, p2, t) => {
1181
+ const u = 1 - t;
1182
+ const uu = u * u;
1183
+ const tt = t * t;
1184
+ return {
1185
+ x: uu * p0.x + 2 * u * t * p1.x + tt * p2.x,
1186
+ y: uu * p0.y + 2 * u * t * p1.y + tt * p2.y,
1187
+ };
1188
+ };