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.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/flatbuffers/duc/alternate-units.d.ts +21 -0
- package/dist/flatbuffers/duc/alternate-units.js +66 -0
- package/dist/flatbuffers/duc/angular-unit-system.d.ts +17 -0
- package/dist/flatbuffers/duc/angular-unit-system.js +50 -0
- package/dist/flatbuffers/duc/angular-units-format.d.ts +7 -0
- package/dist/flatbuffers/duc/angular-units-format.js +10 -0
- package/dist/flatbuffers/duc/axis.d.ts +5 -0
- package/dist/flatbuffers/duc/axis.js +8 -0
- package/dist/flatbuffers/duc/bezier-mirroring.d.ts +5 -0
- package/dist/flatbuffers/duc/bezier-mirroring.js +8 -0
- package/dist/flatbuffers/duc/blending.d.ts +9 -0
- package/dist/flatbuffers/duc/blending.js +12 -0
- package/dist/flatbuffers/duc/block-attachment.d.ts +4 -0
- package/dist/flatbuffers/duc/block-attachment.js +7 -0
- package/dist/flatbuffers/duc/boolean-operation.d.ts +6 -0
- package/dist/flatbuffers/duc/boolean-operation.js +9 -0
- package/dist/flatbuffers/duc/bound-element.d.ts +17 -0
- package/dist/flatbuffers/duc/bound-element.js +48 -0
- package/dist/flatbuffers/duc/checkpoint.d.ts +22 -0
- package/dist/flatbuffers/duc/checkpoint.js +75 -0
- package/dist/flatbuffers/duc/column-layout.d.ts +22 -0
- package/dist/flatbuffers/duc/column-layout.js +72 -0
- package/dist/flatbuffers/duc/column-type.d.ts +5 -0
- package/dist/flatbuffers/duc/column-type.js +8 -0
- package/dist/flatbuffers/duc/custom-hatch-pattern.d.ts +23 -0
- package/dist/flatbuffers/duc/custom-hatch-pattern.js +71 -0
- package/dist/flatbuffers/duc/datum-bracket-style.d.ts +5 -0
- package/dist/flatbuffers/duc/datum-bracket-style.js +8 -0
- package/dist/flatbuffers/duc/datum-reference.d.ts +17 -0
- package/dist/flatbuffers/duc/datum-reference.js +49 -0
- package/dist/flatbuffers/duc/datum-target-type.d.ts +6 -0
- package/dist/flatbuffers/duc/datum-target-type.js +9 -0
- package/dist/flatbuffers/duc/decimal-separator.d.ts +4 -0
- package/dist/flatbuffers/duc/decimal-separator.js +7 -0
- package/dist/flatbuffers/duc/delta.d.ts +20 -0
- package/dist/flatbuffers/duc/delta.js +64 -0
- package/dist/flatbuffers/duc/dictionary-entry.d.ts +17 -0
- package/dist/flatbuffers/duc/dictionary-entry.js +49 -0
- package/dist/flatbuffers/duc/dimension-baseline-data.d.ts +14 -0
- package/dist/flatbuffers/duc/dimension-baseline-data.js +40 -0
- package/dist/flatbuffers/duc/dimension-bindings.d.ts +17 -0
- package/dist/flatbuffers/duc/dimension-bindings.js +50 -0
- package/dist/flatbuffers/duc/dimension-continue-data.d.ts +14 -0
- package/dist/flatbuffers/duc/dimension-continue-data.js +40 -0
- package/dist/flatbuffers/duc/dimension-definition-points.d.ts +21 -0
- package/dist/flatbuffers/duc/dimension-definition-points.js +64 -0
- package/dist/flatbuffers/duc/dimension-ext-line-style.d.ts +18 -0
- package/dist/flatbuffers/duc/dimension-ext-line-style.js +57 -0
- package/dist/flatbuffers/duc/dimension-fit-rule.d.ts +6 -0
- package/dist/flatbuffers/duc/dimension-fit-rule.js +9 -0
- package/dist/flatbuffers/duc/dimension-fit-style.d.ts +19 -0
- package/dist/flatbuffers/duc/dimension-fit-style.js +58 -0
- package/dist/flatbuffers/duc/dimension-line-style.d.ts +16 -0
- package/dist/flatbuffers/duc/dimension-line-style.js +49 -0
- package/dist/flatbuffers/duc/dimension-symbol-style.d.ts +22 -0
- package/dist/flatbuffers/duc/dimension-symbol-style.js +72 -0
- package/dist/flatbuffers/duc/dimension-text-placement.d.ts +5 -0
- package/dist/flatbuffers/duc/dimension-text-placement.js +8 -0
- package/dist/flatbuffers/duc/dimension-tolerance-style.d.ts +24 -0
- package/dist/flatbuffers/duc/dimension-tolerance-style.js +71 -0
- package/dist/flatbuffers/duc/dimension-type.d.ts +15 -0
- package/dist/flatbuffers/duc/dimension-type.js +18 -0
- package/dist/flatbuffers/duc/dimension-units-format.d.ts +7 -0
- package/dist/flatbuffers/duc/dimension-units-format.js +10 -0
- package/dist/flatbuffers/duc/dimension-validation-rules.d.ts +25 -0
- package/dist/flatbuffers/duc/dimension-validation-rules.js +74 -0
- package/dist/flatbuffers/duc/duc-arrow-element.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-arrow-element.js +49 -0
- package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.js +44 -0
- package/dist/flatbuffers/duc/duc-block-attribute-definition.d.ts +22 -0
- package/dist/flatbuffers/duc/duc-block-attribute-definition.js +64 -0
- package/dist/flatbuffers/duc/duc-block-duplication-array.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-block-duplication-array.js +64 -0
- package/dist/flatbuffers/duc/duc-block-instance-element.d.ts +30 -0
- package/dist/flatbuffers/duc/duc-block-instance-element.js +94 -0
- package/dist/flatbuffers/duc/duc-block.d.ts +34 -0
- package/dist/flatbuffers/duc/duc-block.js +111 -0
- package/dist/flatbuffers/duc/duc-common-style.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-common-style.js +44 -0
- package/dist/flatbuffers/duc/duc-dimension-element.d.ts +45 -0
- package/dist/flatbuffers/duc/duc-dimension-element.js +120 -0
- package/dist/flatbuffers/duc/duc-dimension-style.d.ts +28 -0
- package/dist/flatbuffers/duc/duc-dimension-style.js +76 -0
- package/dist/flatbuffers/duc/duc-doc-element.d.ts +33 -0
- package/dist/flatbuffers/duc/duc-doc-element.js +95 -0
- package/dist/flatbuffers/duc/duc-doc-style.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-doc-style.js +52 -0
- package/dist/flatbuffers/duc/duc-element-base.d.ts +88 -0
- package/dist/flatbuffers/duc/duc-element-base.js +269 -0
- package/dist/flatbuffers/duc/duc-element-styles-base.d.ts +30 -0
- package/dist/flatbuffers/duc/duc-element-styles-base.js +103 -0
- package/dist/flatbuffers/duc/duc-ellipse-element.d.ts +22 -0
- package/dist/flatbuffers/duc/duc-ellipse-element.js +73 -0
- package/dist/flatbuffers/duc/duc-embeddable-element.d.ts +14 -0
- package/dist/flatbuffers/duc/duc-embeddable-element.js +41 -0
- package/dist/flatbuffers/duc/duc-external-file-data.d.ts +27 -0
- package/dist/flatbuffers/duc/duc-external-file-data.js +92 -0
- package/dist/flatbuffers/duc/duc-external-file-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-external-file-entry.js +44 -0
- package/dist/flatbuffers/duc/duc-feature-control-frame-element.d.ts +31 -0
- package/dist/flatbuffers/duc/duc-feature-control-frame-element.js +89 -0
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +25 -0
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +68 -0
- package/dist/flatbuffers/duc/duc-frame-element.d.ts +14 -0
- package/dist/flatbuffers/duc/duc-frame-element.js +41 -0
- package/dist/flatbuffers/duc/duc-free-draw-element.d.ts +52 -0
- package/dist/flatbuffers/duc/duc-free-draw-element.js +154 -0
- package/dist/flatbuffers/duc/duc-free-draw-ends.d.ts +18 -0
- package/dist/flatbuffers/duc/duc-free-draw-ends.js +56 -0
- package/dist/flatbuffers/duc/duc-global-state.d.ts +37 -0
- package/dist/flatbuffers/duc/duc-global-state.js +121 -0
- package/dist/flatbuffers/duc/duc-group.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-group.js +44 -0
- package/dist/flatbuffers/duc/duc-hatch-style.d.ts +28 -0
- package/dist/flatbuffers/duc/duc-hatch-style.js +79 -0
- package/dist/flatbuffers/duc/duc-head.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-head.js +57 -0
- package/dist/flatbuffers/duc/duc-image-element.d.ts +35 -0
- package/dist/flatbuffers/duc/duc-image-element.js +91 -0
- package/dist/flatbuffers/duc/duc-image-filter.d.ts +15 -0
- package/dist/flatbuffers/duc/duc-image-filter.js +48 -0
- package/dist/flatbuffers/duc/duc-layer-overrides.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-layer-overrides.js +44 -0
- package/dist/flatbuffers/duc/duc-layer.d.ts +21 -0
- package/dist/flatbuffers/duc/duc-layer.js +59 -0
- package/dist/flatbuffers/duc/duc-leader-element.d.ts +22 -0
- package/dist/flatbuffers/duc/duc-leader-element.js +60 -0
- package/dist/flatbuffers/duc/duc-leader-style.d.ts +30 -0
- package/dist/flatbuffers/duc/duc-leader-style.js +87 -0
- package/dist/flatbuffers/duc/duc-line-reference.d.ts +15 -0
- package/dist/flatbuffers/duc/duc-line-reference.js +43 -0
- package/dist/flatbuffers/duc/duc-line.d.ts +15 -0
- package/dist/flatbuffers/duc/duc-line.js +43 -0
- package/dist/flatbuffers/duc/duc-linear-element-base.d.ts +38 -0
- package/dist/flatbuffers/duc/duc-linear-element-base.js +124 -0
- package/dist/flatbuffers/duc/duc-linear-element.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-linear-element.js +49 -0
- package/dist/flatbuffers/duc/duc-local-state.d.ts +68 -0
- package/dist/flatbuffers/duc/duc-local-state.js +206 -0
- package/dist/flatbuffers/duc/duc-mermaid-element.d.ts +23 -0
- package/dist/flatbuffers/duc/duc-mermaid-element.js +65 -0
- package/dist/flatbuffers/duc/duc-parametric-element.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-parametric-element.js +44 -0
- package/dist/flatbuffers/duc/duc-path.d.ts +26 -0
- package/dist/flatbuffers/duc/duc-path.js +69 -0
- package/dist/flatbuffers/duc/duc-pdf-element.d.ts +17 -0
- package/dist/flatbuffers/duc/duc-pdf-element.js +49 -0
- package/dist/flatbuffers/duc/duc-plot-element.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-plot-element.js +52 -0
- package/dist/flatbuffers/duc/duc-plot-style.d.ts +14 -0
- package/dist/flatbuffers/duc/duc-plot-style.js +41 -0
- package/dist/flatbuffers/duc/duc-point-binding.d.ts +26 -0
- package/dist/flatbuffers/duc/duc-point-binding.js +73 -0
- package/dist/flatbuffers/duc/duc-point.d.ts +18 -0
- package/dist/flatbuffers/duc/duc-point.js +57 -0
- package/dist/flatbuffers/duc/duc-polygon-element.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-polygon-element.js +49 -0
- package/dist/flatbuffers/duc/duc-rectangle-element.d.ts +14 -0
- package/dist/flatbuffers/duc/duc-rectangle-element.js +41 -0
- package/dist/flatbuffers/duc/duc-region.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-region.js +51 -0
- package/dist/flatbuffers/duc/duc-stack-base.d.ts +27 -0
- package/dist/flatbuffers/duc/duc-stack-base.js +78 -0
- package/dist/flatbuffers/duc/duc-stack-element-base.d.ts +23 -0
- package/dist/flatbuffers/duc/duc-stack-element-base.js +65 -0
- package/dist/flatbuffers/duc/duc-stack-like-styles.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-stack-like-styles.js +48 -0
- package/dist/flatbuffers/duc/duc-table-auto-size.d.ts +15 -0
- package/dist/flatbuffers/duc/duc-table-auto-size.js +48 -0
- package/dist/flatbuffers/duc/duc-table-cell-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-table-cell-entry.js +44 -0
- package/dist/flatbuffers/duc/duc-table-cell-span.d.ts +15 -0
- package/dist/flatbuffers/duc/duc-table-cell-span.js +48 -0
- package/dist/flatbuffers/duc/duc-table-cell-style.d.ts +22 -0
- package/dist/flatbuffers/duc/duc-table-cell-style.js +59 -0
- package/dist/flatbuffers/duc/duc-table-cell.d.ts +27 -0
- package/dist/flatbuffers/duc/duc-table-cell.js +72 -0
- package/dist/flatbuffers/duc/duc-table-column-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-table-column-entry.js +44 -0
- package/dist/flatbuffers/duc/duc-table-column.d.ts +18 -0
- package/dist/flatbuffers/duc/duc-table-column.js +51 -0
- package/dist/flatbuffers/duc/duc-table-element.d.ts +51 -0
- package/dist/flatbuffers/duc/duc-table-element.js +167 -0
- package/dist/flatbuffers/duc/duc-table-row-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-table-row-entry.js +44 -0
- package/dist/flatbuffers/duc/duc-table-row.d.ts +18 -0
- package/dist/flatbuffers/duc/duc-table-row.js +51 -0
- package/dist/flatbuffers/duc/duc-table-style.d.ts +23 -0
- package/dist/flatbuffers/duc/duc-table-style.js +65 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.d.ts +14 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.js +40 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-element-source.d.ts +17 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-element-source.js +49 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-part.d.ts +22 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-part.js +58 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-source-data.d.ts +9 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-source-data.js +26 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-source.d.ts +19 -0
- package/dist/flatbuffers/duc/duc-text-dynamic-source.js +58 -0
- package/dist/flatbuffers/duc/duc-text-element.d.ts +33 -0
- package/dist/flatbuffers/duc/duc-text-element.js +94 -0
- package/dist/flatbuffers/duc/duc-text-style.d.ts +44 -0
- package/dist/flatbuffers/duc/duc-text-style.js +128 -0
- package/dist/flatbuffers/duc/duc-ucs.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-ucs.js +49 -0
- package/dist/flatbuffers/duc/duc-view.d.ts +24 -0
- package/dist/flatbuffers/duc/duc-view.js +71 -0
- package/dist/flatbuffers/duc/duc-viewport-element.d.ts +36 -0
- package/dist/flatbuffers/duc/duc-viewport-element.js +102 -0
- package/dist/flatbuffers/duc/duc-viewport-style.d.ts +16 -0
- package/dist/flatbuffers/duc/duc-viewport-style.js +49 -0
- package/dist/flatbuffers/duc/duc-xray-element.d.ts +23 -0
- package/dist/flatbuffers/duc/duc-xray-element.js +66 -0
- package/dist/flatbuffers/duc/duc-xray-style.d.ts +17 -0
- package/dist/flatbuffers/duc/duc-xray-style.js +49 -0
- package/dist/flatbuffers/duc/dynamic-snap-settings.d.ts +17 -0
- package/dist/flatbuffers/duc/dynamic-snap-settings.js +56 -0
- package/dist/flatbuffers/duc/element-background.d.ts +14 -0
- package/dist/flatbuffers/duc/element-background.js +41 -0
- package/dist/flatbuffers/duc/element-content-base.d.ts +29 -0
- package/dist/flatbuffers/duc/element-content-base.js +80 -0
- package/dist/flatbuffers/duc/element-content-preference.d.ts +8 -0
- package/dist/flatbuffers/duc/element-content-preference.js +11 -0
- package/dist/flatbuffers/duc/element-stroke.d.ts +24 -0
- package/dist/flatbuffers/duc/element-stroke.js +66 -0
- package/dist/flatbuffers/duc/element-wrapper.d.ts +16 -0
- package/dist/flatbuffers/duc/element-wrapper.js +49 -0
- package/dist/flatbuffers/duc/element.d.ts +49 -0
- package/dist/flatbuffers/duc/element.js +106 -0
- package/dist/flatbuffers/duc/exported-data-state.d.ts +87 -0
- package/dist/flatbuffers/duc/exported-data-state.js +290 -0
- package/dist/flatbuffers/duc/fcfbetween-modifier.d.ts +17 -0
- package/dist/flatbuffers/duc/fcfbetween-modifier.js +48 -0
- package/dist/flatbuffers/duc/fcfdatum-definition.d.ts +16 -0
- package/dist/flatbuffers/duc/fcfdatum-definition.js +43 -0
- package/dist/flatbuffers/duc/fcfdatum-style.d.ts +14 -0
- package/dist/flatbuffers/duc/fcfdatum-style.js +41 -0
- package/dist/flatbuffers/duc/fcfframe-modifiers.d.ts +22 -0
- package/dist/flatbuffers/duc/fcfframe-modifiers.js +65 -0
- package/dist/flatbuffers/duc/fcflayout-style.d.ts +17 -0
- package/dist/flatbuffers/duc/fcflayout-style.js +56 -0
- package/dist/flatbuffers/duc/fcfprojected-zone-modifier.d.ts +13 -0
- package/dist/flatbuffers/duc/fcfprojected-zone-modifier.js +40 -0
- package/dist/flatbuffers/duc/fcfsegment-row.d.ts +17 -0
- package/dist/flatbuffers/duc/fcfsegment-row.js +55 -0
- package/dist/flatbuffers/duc/fcfsymbol-style.d.ts +13 -0
- package/dist/flatbuffers/duc/fcfsymbol-style.js +40 -0
- package/dist/flatbuffers/duc/feature-control-frame-segment.d.ts +22 -0
- package/dist/flatbuffers/duc/feature-control-frame-segment.js +65 -0
- package/dist/flatbuffers/duc/feature-modifier.d.ts +18 -0
- package/dist/flatbuffers/duc/feature-modifier.js +21 -0
- package/dist/flatbuffers/duc/gdt-symbol.d.ts +22 -0
- package/dist/flatbuffers/duc/gdt-symbol.js +25 -0
- package/dist/flatbuffers/duc/geometric-point.d.ts +10 -0
- package/dist/flatbuffers/duc/geometric-point.js +27 -0
- package/dist/flatbuffers/duc/grid-display-type.d.ts +6 -0
- package/dist/flatbuffers/duc/grid-display-type.js +9 -0
- package/dist/flatbuffers/duc/grid-settings.d.ts +54 -0
- package/dist/flatbuffers/duc/grid-settings.js +165 -0
- package/dist/flatbuffers/duc/grid-style.d.ts +26 -0
- package/dist/flatbuffers/duc/grid-style.js +74 -0
- package/dist/flatbuffers/duc/grid-type.d.ts +7 -0
- package/dist/flatbuffers/duc/grid-type.js +10 -0
- package/dist/flatbuffers/duc/handle-type.d.ts +4 -0
- package/dist/flatbuffers/duc/handle-type.js +7 -0
- package/dist/flatbuffers/duc/hatch-pattern-line.d.ts +35 -0
- package/dist/flatbuffers/duc/hatch-pattern-line.js +93 -0
- package/dist/flatbuffers/duc/hatch-style.d.ts +5 -0
- package/dist/flatbuffers/duc/hatch-style.js +8 -0
- package/dist/flatbuffers/duc/identified-common-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-common-style.js +44 -0
- package/dist/flatbuffers/duc/identified-dimension-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-dimension-style.js +44 -0
- package/dist/flatbuffers/duc/identified-doc-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-doc-style.js +44 -0
- package/dist/flatbuffers/duc/identified-fcfstyle.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-fcfstyle.js +44 -0
- package/dist/flatbuffers/duc/identified-grid-settings.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-grid-settings.js +44 -0
- package/dist/flatbuffers/duc/identified-hatch-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-hatch-style.js +44 -0
- package/dist/flatbuffers/duc/identified-leader-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-leader-style.js +44 -0
- package/dist/flatbuffers/duc/identified-snap-settings.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-snap-settings.js +44 -0
- package/dist/flatbuffers/duc/identified-stack-like-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-stack-like-style.js +44 -0
- package/dist/flatbuffers/duc/identified-table-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-table-style.js +44 -0
- package/dist/flatbuffers/duc/identified-text-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-text-style.js +44 -0
- package/dist/flatbuffers/duc/identified-ucs.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-ucs.js +44 -0
- package/dist/flatbuffers/duc/identified-view.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-view.js +44 -0
- package/dist/flatbuffers/duc/identified-viewport-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-viewport-style.js +44 -0
- package/dist/flatbuffers/duc/identified-xray-style.d.ts +16 -0
- package/dist/flatbuffers/duc/identified-xray-style.js +44 -0
- package/dist/flatbuffers/duc/identifier.d.ts +20 -0
- package/dist/flatbuffers/duc/identifier.js +57 -0
- package/dist/flatbuffers/duc/image-crop.d.ts +23 -0
- package/dist/flatbuffers/duc/image-crop.js +80 -0
- package/dist/flatbuffers/duc/image-status.d.ts +5 -0
- package/dist/flatbuffers/duc/image-status.js +8 -0
- package/dist/flatbuffers/duc/isometric-grid-settings.d.ts +15 -0
- package/dist/flatbuffers/duc/isometric-grid-settings.js +48 -0
- package/dist/flatbuffers/duc/jsonpatch-operation.d.ts +23 -0
- package/dist/flatbuffers/duc/jsonpatch-operation.js +64 -0
- package/dist/flatbuffers/duc/layer-snap-filters.d.ts +23 -0
- package/dist/flatbuffers/duc/layer-snap-filters.js +76 -0
- package/dist/flatbuffers/duc/layer-validation-rules.d.ts +17 -0
- package/dist/flatbuffers/duc/layer-validation-rules.js +54 -0
- package/dist/flatbuffers/duc/leader-block-content.d.ts +25 -0
- package/dist/flatbuffers/duc/leader-block-content.js +85 -0
- package/dist/flatbuffers/duc/leader-content-data.d.ts +9 -0
- package/dist/flatbuffers/duc/leader-content-data.js +26 -0
- package/dist/flatbuffers/duc/leader-content-type.d.ts +4 -0
- package/dist/flatbuffers/duc/leader-content-type.js +7 -0
- package/dist/flatbuffers/duc/leader-content.d.ts +19 -0
- package/dist/flatbuffers/duc/leader-content.js +58 -0
- package/dist/flatbuffers/duc/leader-text-block-content.d.ts +14 -0
- package/dist/flatbuffers/duc/leader-text-block-content.js +40 -0
- package/dist/flatbuffers/duc/line-head.d.ts +17 -0
- package/dist/flatbuffers/duc/line-head.js +20 -0
- package/dist/flatbuffers/duc/line-spacing-type.d.ts +5 -0
- package/dist/flatbuffers/duc/line-spacing-type.js +8 -0
- package/dist/flatbuffers/duc/line-spacing.d.ts +16 -0
- package/dist/flatbuffers/duc/line-spacing.js +49 -0
- package/dist/flatbuffers/duc/linear-unit-system.d.ts +24 -0
- package/dist/flatbuffers/duc/linear-unit-system.js +75 -0
- package/dist/flatbuffers/duc/margins.d.ts +19 -0
- package/dist/flatbuffers/duc/margins.js +64 -0
- package/dist/flatbuffers/duc/mark-ellipse-center.d.ts +4 -0
- package/dist/flatbuffers/duc/mark-ellipse-center.js +7 -0
- package/dist/flatbuffers/duc/material-condition.d.ts +5 -0
- package/dist/flatbuffers/duc/material-condition.js +8 -0
- package/dist/flatbuffers/duc/object-snap-mode.d.ts +22 -0
- package/dist/flatbuffers/duc/object-snap-mode.js +25 -0
- package/dist/flatbuffers/duc/paragraph-formatting.d.ts +33 -0
- package/dist/flatbuffers/duc/paragraph-formatting.js +106 -0
- package/dist/flatbuffers/duc/parametric-source-type.d.ts +4 -0
- package/dist/flatbuffers/duc/parametric-source-type.js +7 -0
- package/dist/flatbuffers/duc/parametric-source.d.ts +20 -0
- package/dist/flatbuffers/duc/parametric-source.js +57 -0
- package/dist/flatbuffers/duc/plot-layout.d.ts +14 -0
- package/dist/flatbuffers/duc/plot-layout.js +41 -0
- package/dist/flatbuffers/duc/point-binding-point.d.ts +15 -0
- package/dist/flatbuffers/duc/point-binding-point.js +48 -0
- package/dist/flatbuffers/duc/polar-grid-settings.d.ts +17 -0
- package/dist/flatbuffers/duc/polar-grid-settings.js +56 -0
- package/dist/flatbuffers/duc/polar-tracking-settings.d.ts +29 -0
- package/dist/flatbuffers/duc/polar-tracking-settings.js +90 -0
- package/dist/flatbuffers/duc/primary-units.d.ts +16 -0
- package/dist/flatbuffers/duc/primary-units.js +44 -0
- package/dist/flatbuffers/duc/pruning-level.d.ts +5 -0
- package/dist/flatbuffers/duc/pruning-level.js +8 -0
- package/dist/flatbuffers/duc/snap-marker-settings.d.ts +23 -0
- package/dist/flatbuffers/duc/snap-marker-settings.js +79 -0
- package/dist/flatbuffers/duc/snap-marker-shape.d.ts +6 -0
- package/dist/flatbuffers/duc/snap-marker-shape.js +9 -0
- package/dist/flatbuffers/duc/snap-marker-style-entry.d.ts +16 -0
- package/dist/flatbuffers/duc/snap-marker-style-entry.js +43 -0
- package/dist/flatbuffers/duc/snap-marker-style.d.ts +17 -0
- package/dist/flatbuffers/duc/snap-marker-style.js +49 -0
- package/dist/flatbuffers/duc/snap-mode.d.ts +4 -0
- package/dist/flatbuffers/duc/snap-mode.js +7 -0
- package/dist/flatbuffers/duc/snap-override-behavior.d.ts +5 -0
- package/dist/flatbuffers/duc/snap-override-behavior.js +8 -0
- package/dist/flatbuffers/duc/snap-override.d.ts +17 -0
- package/dist/flatbuffers/duc/snap-override.js +49 -0
- package/dist/flatbuffers/duc/snap-settings.d.ts +75 -0
- package/dist/flatbuffers/duc/snap-settings.js +245 -0
- package/dist/flatbuffers/duc/stack-format-properties.d.ts +18 -0
- package/dist/flatbuffers/duc/stack-format-properties.js +57 -0
- package/dist/flatbuffers/duc/stack-format.d.ts +21 -0
- package/dist/flatbuffers/duc/stack-format.js +64 -0
- package/dist/flatbuffers/duc/stacked-text-align.d.ts +5 -0
- package/dist/flatbuffers/duc/stacked-text-align.js +8 -0
- package/dist/flatbuffers/duc/standard-overrides.d.ts +63 -0
- package/dist/flatbuffers/duc/standard-overrides.js +162 -0
- package/dist/flatbuffers/duc/standard-styles.d.ts +77 -0
- package/dist/flatbuffers/duc/standard-styles.js +285 -0
- package/dist/flatbuffers/duc/standard-units.d.ts +16 -0
- package/dist/flatbuffers/duc/standard-units.js +44 -0
- package/dist/flatbuffers/duc/standard-validation.d.ts +16 -0
- package/dist/flatbuffers/duc/standard-validation.js +44 -0
- package/dist/flatbuffers/duc/standard-view-settings.d.ts +35 -0
- package/dist/flatbuffers/duc/standard-view-settings.js +124 -0
- package/dist/flatbuffers/duc/standard.d.ts +33 -0
- package/dist/flatbuffers/duc/standard.js +90 -0
- package/dist/flatbuffers/duc/string-value-entry.d.ts +17 -0
- package/dist/flatbuffers/duc/string-value-entry.js +49 -0
- package/dist/flatbuffers/duc/stroke-cap.d.ts +5 -0
- package/dist/flatbuffers/duc/stroke-cap.js +8 -0
- package/dist/flatbuffers/duc/stroke-join.d.ts +5 -0
- package/dist/flatbuffers/duc/stroke-join.js +8 -0
- package/dist/flatbuffers/duc/stroke-placement.d.ts +5 -0
- package/dist/flatbuffers/duc/stroke-placement.js +8 -0
- package/dist/flatbuffers/duc/stroke-preference.d.ts +6 -0
- package/dist/flatbuffers/duc/stroke-preference.js +9 -0
- package/dist/flatbuffers/duc/stroke-side-preference.d.ts +8 -0
- package/dist/flatbuffers/duc/stroke-side-preference.js +11 -0
- package/dist/flatbuffers/duc/stroke-sides.d.ts +24 -0
- package/dist/flatbuffers/duc/stroke-sides.js +67 -0
- package/dist/flatbuffers/duc/stroke-style.d.ts +37 -0
- package/dist/flatbuffers/duc/stroke-style.js +111 -0
- package/dist/flatbuffers/duc/stroke-width.d.ts +5 -0
- package/dist/flatbuffers/duc/stroke-width.js +8 -0
- package/dist/flatbuffers/duc/table-cell-alignment.d.ts +11 -0
- package/dist/flatbuffers/duc/table-cell-alignment.js +14 -0
- package/dist/flatbuffers/duc/table-flow-direction.d.ts +4 -0
- package/dist/flatbuffers/duc/table-flow-direction.js +7 -0
- package/dist/flatbuffers/duc/text-align.d.ts +5 -0
- package/dist/flatbuffers/duc/text-align.js +8 -0
- package/dist/flatbuffers/duc/text-column.d.ts +15 -0
- package/dist/flatbuffers/duc/text-column.js +48 -0
- package/dist/flatbuffers/duc/text-field-source-property.d.ts +13 -0
- package/dist/flatbuffers/duc/text-field-source-property.js +16 -0
- package/dist/flatbuffers/duc/text-field-source-type.d.ts +4 -0
- package/dist/flatbuffers/duc/text-field-source-type.js +7 -0
- package/dist/flatbuffers/duc/text-flow-direction.d.ts +6 -0
- package/dist/flatbuffers/duc/text-flow-direction.js +9 -0
- package/dist/flatbuffers/duc/tiling-properties.d.ts +21 -0
- package/dist/flatbuffers/duc/tiling-properties.js +75 -0
- package/dist/flatbuffers/duc/tolerance-clause.d.ts +27 -0
- package/dist/flatbuffers/duc/tolerance-clause.js +84 -0
- package/dist/flatbuffers/duc/tolerance-display.d.ts +7 -0
- package/dist/flatbuffers/duc/tolerance-display.js +10 -0
- package/dist/flatbuffers/duc/tolerance-type.d.ts +5 -0
- package/dist/flatbuffers/duc/tolerance-type.js +8 -0
- package/dist/flatbuffers/duc/tolerance-zone-type.d.ts +7 -0
- package/dist/flatbuffers/duc/tolerance-zone-type.js +10 -0
- package/dist/flatbuffers/duc/tracking-line-style.d.ts +26 -0
- package/dist/flatbuffers/duc/tracking-line-style.js +74 -0
- package/dist/flatbuffers/duc/unit-precision.d.ts +19 -0
- package/dist/flatbuffers/duc/unit-precision.js +64 -0
- package/dist/flatbuffers/duc/unit-system-base.d.ts +20 -0
- package/dist/flatbuffers/duc/unit-system-base.js +65 -0
- package/dist/flatbuffers/duc/unit-system.d.ts +4 -0
- package/dist/flatbuffers/duc/unit-system.js +7 -0
- package/dist/flatbuffers/duc/version-base.d.ts +27 -0
- package/dist/flatbuffers/duc/version-base.js +80 -0
- package/dist/flatbuffers/duc/version-graph-metadata.d.ts +15 -0
- package/dist/flatbuffers/duc/version-graph-metadata.js +48 -0
- package/dist/flatbuffers/duc/version-graph.d.ts +31 -0
- package/dist/flatbuffers/duc/version-graph.js +94 -0
- package/dist/flatbuffers/duc/vertical-align.d.ts +5 -0
- package/dist/flatbuffers/duc/vertical-align.js +8 -0
- package/dist/flatbuffers/duc/viewport-shade-plot.d.ts +6 -0
- package/dist/flatbuffers/duc/viewport-shade-plot.js +9 -0
- package/dist/flatbuffers/duc/youtube-states.d.ts +8 -0
- package/dist/flatbuffers/duc/youtube-states.js +11 -0
- package/dist/flatbuffers/duc.d.ts +227 -0
- package/dist/flatbuffers/duc.js +229 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/legacy/index.d.ts +1 -0
- package/dist/legacy/index.js +1 -0
- package/dist/legacy/v1/duc/app-state.d.ts +124 -0
- package/dist/legacy/v1/duc/app-state.js +388 -0
- package/dist/legacy/v1/duc/binary-file-data.d.ts +27 -0
- package/dist/legacy/v1/duc/binary-file-data.js +90 -0
- package/dist/legacy/v1/duc/binary-files-entry.d.ts +16 -0
- package/dist/legacy/v1/duc/binary-files-entry.js +43 -0
- package/dist/legacy/v1/duc/binary-files.d.ts +17 -0
- package/dist/legacy/v1/duc/binary-files.js +55 -0
- package/dist/legacy/v1/duc/binding-point.d.ts +15 -0
- package/dist/legacy/v1/duc/binding-point.js +48 -0
- package/dist/legacy/v1/duc/bound-element.d.ts +17 -0
- package/dist/legacy/v1/duc/bound-element.js +48 -0
- package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +22 -0
- package/dist/legacy/v1/duc/duc-block-attribute-details.js +57 -0
- package/dist/legacy/v1/duc/duc-block-attribute.d.ts +16 -0
- package/dist/legacy/v1/duc/duc-block-attribute.js +43 -0
- package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +17 -0
- package/dist/legacy/v1/duc/duc-block-instance-element-override.js +48 -0
- package/dist/legacy/v1/duc/duc-block.d.ts +34 -0
- package/dist/legacy/v1/duc/duc-block.js +110 -0
- package/dist/legacy/v1/duc/duc-element.d.ts +273 -0
- package/dist/legacy/v1/duc/duc-element.js +865 -0
- package/dist/legacy/v1/duc/duc-group.d.ts +40 -0
- package/dist/legacy/v1/duc/duc-group.js +114 -0
- package/dist/legacy/v1/duc/duc-line-reference.d.ts +15 -0
- package/dist/legacy/v1/duc/duc-line-reference.js +43 -0
- package/dist/legacy/v1/duc/duc-line.d.ts +15 -0
- package/dist/legacy/v1/duc/duc-line.js +43 -0
- package/dist/legacy/v1/duc/duc-path.d.ts +26 -0
- package/dist/legacy/v1/duc/duc-path.js +69 -0
- package/dist/legacy/v1/duc/duc-table-cell.d.ts +22 -0
- package/dist/legacy/v1/duc/duc-table-cell.js +57 -0
- package/dist/legacy/v1/duc/duc-table-column.d.ts +18 -0
- package/dist/legacy/v1/duc/duc-table-column.js +50 -0
- package/dist/legacy/v1/duc/duc-table-row.d.ts +18 -0
- package/dist/legacy/v1/duc/duc-table-row.js +50 -0
- package/dist/legacy/v1/duc/duc-table-style-props.d.ts +39 -0
- package/dist/legacy/v1/duc/duc-table-style-props.js +114 -0
- package/dist/legacy/v1/duc/duc-table-style.d.ts +14 -0
- package/dist/legacy/v1/duc/duc-table-style.js +41 -0
- package/dist/legacy/v1/duc/element-background.d.ts +14 -0
- package/dist/legacy/v1/duc/element-background.js +41 -0
- package/dist/legacy/v1/duc/element-content-base.d.ts +22 -0
- package/dist/legacy/v1/duc/element-content-base.js +64 -0
- package/dist/legacy/v1/duc/element-stroke.d.ts +23 -0
- package/dist/legacy/v1/duc/element-stroke.js +66 -0
- package/dist/legacy/v1/duc/exported-data-state.d.ts +51 -0
- package/dist/legacy/v1/duc/exported-data-state.js +155 -0
- package/dist/legacy/v1/duc/image-crop.d.ts +23 -0
- package/dist/legacy/v1/duc/image-crop.js +80 -0
- package/dist/legacy/v1/duc/linear-element-editor.d.ts +44 -0
- package/dist/legacy/v1/duc/linear-element-editor.js +119 -0
- package/dist/legacy/v1/duc/point-binding.d.ts +25 -0
- package/dist/legacy/v1/duc/point-binding.js +72 -0
- package/dist/legacy/v1/duc/point.d.ts +20 -0
- package/dist/legacy/v1/duc/point.js +63 -0
- package/dist/legacy/v1/duc/pointer-down-state.d.ts +32 -0
- package/dist/legacy/v1/duc/pointer-down-state.js +90 -0
- package/dist/legacy/v1/duc/renderer-state.d.ts +17 -0
- package/dist/legacy/v1/duc/renderer-state.js +54 -0
- package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +18 -0
- package/dist/legacy/v1/duc/segment-midpoint-state.js +57 -0
- package/dist/legacy/v1/duc/simple-point.d.ts +15 -0
- package/dist/legacy/v1/duc/simple-point.js +48 -0
- package/dist/legacy/v1/duc/stroke-sides.d.ts +23 -0
- package/dist/legacy/v1/duc/stroke-sides.js +66 -0
- package/dist/legacy/v1/duc/stroke-style.d.ts +31 -0
- package/dist/legacy/v1/duc/stroke-style.js +102 -0
- package/dist/legacy/v1/duc/tiling-properties.d.ts +21 -0
- package/dist/legacy/v1/duc/tiling-properties.js +75 -0
- package/dist/legacy/v1/duc.d.ts +35 -0
- package/dist/legacy/v1/duc.js +37 -0
- package/dist/legacy/v1/index.d.ts +1 -0
- package/dist/legacy/v1/index.js +1 -0
- package/dist/legacy/v1/parse/index.d.ts +67 -0
- package/dist/legacy/v1/parse/index.js +101 -0
- package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +3 -0
- package/dist/legacy/v1/parse/parseAppStateFromBinary.js +139 -0
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +4 -0
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +32 -0
- package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +3 -0
- package/dist/legacy/v1/parse/parseBlockFromBinary.js +70 -0
- package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +8 -0
- package/dist/legacy/v1/parse/parseElementFromBinary.js +387 -0
- package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +4 -0
- package/dist/legacy/v1/parse/parseGroupFromBinary.js +36 -0
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +4 -0
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +15 -0
- package/dist/legacy/v1/serialize/index.d.ts +5 -0
- package/dist/legacy/v1/serialize/index.js +81 -0
- package/dist/legacy/v1/serialize/serializationUtils.d.ts +17 -0
- package/dist/legacy/v1/serialize/serializationUtils.js +27 -0
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +4 -0
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +145 -0
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +4 -0
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +46 -0
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +3 -0
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +60 -0
- package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +8 -0
- package/dist/legacy/v1/serialize/serializeElementFromDuc.js +435 -0
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +3 -0
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +37 -0
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +4 -0
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +7 -0
- package/dist/legacy/v1/types/elements/index.d.ts +480 -0
- package/dist/legacy/v1/types/elements/index.js +1 -0
- package/dist/legacy/v1/types/elements/typeChecks.d.ts +40 -0
- package/dist/legacy/v1/types/elements/typeChecks.js +179 -0
- package/dist/legacy/v1/types/geometryTypes.d.ts +78 -0
- package/dist/legacy/v1/types/geometryTypes.js +1 -0
- package/dist/legacy/v1/types/index.d.ts +496 -0
- package/dist/legacy/v1/types/index.js +1 -0
- package/dist/legacy/v1/types/utility-types.d.ts +31 -0
- package/dist/legacy/v1/types/utility-types.js +1 -0
- package/dist/legacy/v1/utils/bounds.d.ts +76 -0
- package/dist/legacy/v1/utils/bounds.js +415 -0
- package/dist/legacy/v1/utils/constants.d.ts +370 -0
- package/dist/legacy/v1/utils/constants.js +571 -0
- package/dist/legacy/v1/utils/elements/index.d.ts +26 -0
- package/dist/legacy/v1/utils/elements/index.js +108 -0
- package/dist/legacy/v1/utils/elements/linearElement.d.ts +133 -0
- package/dist/legacy/v1/utils/elements/linearElement.js +544 -0
- package/dist/legacy/v1/utils/elements/textElement.d.ts +89 -0
- package/dist/legacy/v1/utils/elements/textElement.js +563 -0
- package/dist/legacy/v1/utils/index.d.ts +26 -0
- package/dist/legacy/v1/utils/index.js +40 -0
- package/dist/legacy/v1/utils/math/algebra/ga.d.ts +63 -0
- package/dist/legacy/v1/utils/math/algebra/ga.js +268 -0
- package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +9 -0
- package/dist/legacy/v1/utils/math/algebra/gadirections.js +18 -0
- package/dist/legacy/v1/utils/math/algebra/galines.d.ts +23 -0
- package/dist/legacy/v1/utils/math/algebra/galines.js +32 -0
- package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +8 -0
- package/dist/legacy/v1/utils/math/algebra/gapoints.js +30 -0
- package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +10 -0
- package/dist/legacy/v1/utils/math/algebra/gatransforms.js +23 -0
- package/dist/legacy/v1/utils/math/bbox.d.ts +10 -0
- package/dist/legacy/v1/utils/math/bbox.js +42 -0
- package/dist/legacy/v1/utils/math/geometry.d.ts +102 -0
- package/dist/legacy/v1/utils/math/geometry.js +790 -0
- package/dist/legacy/v1/utils/math/index.d.ts +309 -0
- package/dist/legacy/v1/utils/math/index.js +1140 -0
- package/dist/legacy/v1/utils/math/random.d.ts +4 -0
- package/dist/legacy/v1/utils/math/random.js +25 -0
- package/dist/legacy/v1/utils/measurements.d.ts +33 -0
- package/dist/legacy/v1/utils/measurements.js +65 -0
- package/dist/legacy/v1/utils/normalize.d.ts +14 -0
- package/dist/legacy/v1/utils/normalize.js +49 -0
- package/dist/legacy/v1/utils/restore.d.ts +197 -0
- package/dist/legacy/v1/utils/restore.js +1255 -0
- package/dist/legacy/v1/utils/scopes.d.ts +260 -0
- package/dist/legacy/v1/utils/scopes.js +661 -0
- package/dist/legacy/v1/utils/standards.d.ts +12 -0
- package/dist/legacy/v1/utils/standards.js +10 -0
- package/dist/legacy/v1/utils/state/index.d.ts +2 -0
- package/dist/legacy/v1/utils/state/index.js +68 -0
- package/dist/legacy/v1/utils/url.d.ts +8 -0
- package/dist/legacy/v1/utils/url.js +33 -0
- package/dist/parse.d.ts +54 -0
- package/dist/parse.js +1318 -0
- package/dist/restore/index.d.ts +3 -0
- package/dist/restore/index.js +3 -0
- package/dist/restore/restoreDataState.d.ts +191 -0
- package/dist/restore/restoreDataState.js +716 -0
- package/dist/restore/restoreElements.d.ts +34 -0
- package/dist/restore/restoreElements.js +1281 -0
- package/dist/restore/restoreStandards.d.ts +8 -0
- package/dist/restore/restoreStandards.js +224 -0
- package/dist/serialize.d.ts +3 -0
- package/dist/serialize.js +2465 -0
- package/dist/technical/index.d.ts +3 -0
- package/dist/technical/index.js +3 -0
- package/dist/technical/measurements.d.ts +31 -0
- package/dist/technical/measurements.js +64 -0
- package/dist/technical/scopes.d.ts +261 -0
- package/dist/technical/scopes.js +661 -0
- package/dist/technical/standards.d.ts +124 -0
- package/dist/technical/standards.js +10 -0
- package/dist/types/elements/index.d.ts +1356 -0
- package/dist/types/elements/index.js +1 -0
- package/dist/types/elements/typeChecks.d.ts +40 -0
- package/dist/types/elements/typeChecks.js +188 -0
- package/dist/types/geometryTypes.d.ts +90 -0
- package/dist/types/geometryTypes.js +1 -0
- package/dist/types/index.d.ts +591 -0
- package/dist/types/index.js +3 -0
- package/dist/types/utility-types.d.ts +31 -0
- package/dist/types/utility-types.js +1 -0
- package/dist/utils/bounds.d.ts +75 -0
- package/dist/utils/bounds.js +414 -0
- package/dist/utils/constants.d.ts +288 -0
- package/dist/utils/constants.js +529 -0
- package/dist/utils/elements/frameElement.d.ts +4 -0
- package/dist/utils/elements/frameElement.js +16 -0
- package/dist/utils/elements/freedrawElement.d.ts +2 -0
- package/dist/utils/elements/freedrawElement.js +46 -0
- package/dist/utils/elements/index.d.ts +51 -0
- package/dist/utils/elements/index.js +215 -0
- package/dist/utils/elements/linearElement.d.ts +53 -0
- package/dist/utils/elements/linearElement.js +539 -0
- package/dist/utils/elements/newElement.d.ts +72 -0
- package/dist/utils/elements/newElement.js +268 -0
- package/dist/utils/elements/textElement.d.ts +89 -0
- package/dist/utils/elements/textElement.js +565 -0
- package/dist/utils/elements/viewportElement.d.ts +6 -0
- package/dist/utils/elements/viewportElement.js +9 -0
- package/dist/utils/filebyte.d.ts +39 -0
- package/dist/utils/filebyte.js +117 -0
- package/dist/utils/functionCodec.d.ts +5 -0
- package/dist/utils/functionCodec.js +86 -0
- package/dist/utils/index.d.ts +32 -0
- package/dist/utils/index.js +53 -0
- package/dist/utils/math/algebra/ga.d.ts +63 -0
- package/dist/utils/math/algebra/ga.js +268 -0
- package/dist/utils/math/algebra/gadirections.d.ts +9 -0
- package/dist/utils/math/algebra/gadirections.js +18 -0
- package/dist/utils/math/algebra/galines.d.ts +23 -0
- package/dist/utils/math/algebra/galines.js +32 -0
- package/dist/utils/math/algebra/gapoints.d.ts +8 -0
- package/dist/utils/math/algebra/gapoints.js +30 -0
- package/dist/utils/math/algebra/gatransforms.d.ts +10 -0
- package/dist/utils/math/algebra/gatransforms.js +23 -0
- package/dist/utils/math/algebra/index.d.ts +5 -0
- package/dist/utils/math/algebra/index.js +5 -0
- package/dist/utils/math/bbox.d.ts +10 -0
- package/dist/utils/math/bbox.js +42 -0
- package/dist/utils/math/geometry.d.ts +102 -0
- package/dist/utils/math/geometry.js +790 -0
- package/dist/utils/math/index.d.ts +323 -0
- package/dist/utils/math/index.js +1188 -0
- package/dist/utils/math/random.d.ts +4 -0
- package/dist/utils/math/random.js +25 -0
- package/dist/utils/normalize.d.ts +14 -0
- package/dist/utils/normalize.js +49 -0
- package/dist/utils/shape.d.ts +15 -0
- package/dist/utils/shape.js +254 -0
- package/dist/utils/state/grid.d.ts +7 -0
- package/dist/utils/state/grid.js +25 -0
- package/dist/utils/state/index.d.ts +9 -0
- package/dist/utils/state/index.js +131 -0
- package/dist/utils/url.d.ts +8 -0
- package/dist/utils/url.js +33 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +1 -0
- 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
|
+
};
|