@visactor/vrender 0.9.1 → 0.9.2-fill-stroke.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/allocator/constants.d.ts +9 -0
- package/cjs/allocator/constants.js +10 -0
- package/cjs/allocator/constants.js.map +1 -0
- package/cjs/animate/custom-animate.d.ts +2 -2
- package/cjs/animate/custom-animate.js +13 -12
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/default-ticker.d.ts +2 -0
- package/cjs/animate/default-ticker.js +14 -0
- package/cjs/animate/default-ticker.js.map +1 -0
- package/cjs/animate/morphing.js +4 -5
- package/cjs/animate/morphing.js.map +1 -1
- package/cjs/animate/timeline.js +1 -2
- package/cjs/application.d.ts +11 -0
- package/cjs/application.js +9 -0
- package/cjs/application.js.map +1 -0
- package/cjs/canvas/contributions/browser/context.d.ts +2 -4
- package/cjs/canvas/contributions/browser/context.js +4 -4
- package/cjs/canvas/contributions/browser/context.js.map +1 -1
- package/cjs/canvas/contributions/taro/context.js +4 -4
- package/cjs/canvas/contributions/taro/context.js.map +1 -1
- package/cjs/common/bezier-utils.d.ts +5 -0
- package/cjs/common/bezier-utils.js +35 -0
- package/cjs/common/bezier-utils.js.map +1 -0
- package/cjs/common/canvas-utils.d.ts +1 -1
- package/cjs/common/canvas-utils.js +11 -7
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/custom-path2d.d.ts +47 -0
- package/cjs/common/custom-path2d.js +333 -0
- package/cjs/common/custom-path2d.js.map +1 -0
- package/cjs/common/segment/basis.d.ts +25 -0
- package/cjs/common/segment/basis.js +68 -0
- package/cjs/common/segment/basis.js.map +1 -0
- package/cjs/common/segment/common.d.ts +3 -0
- package/cjs/common/segment/common.js +12 -0
- package/cjs/common/segment/common.js.map +1 -0
- package/cjs/common/segment/curve/arc.d.ts +14 -0
- package/cjs/common/segment/curve/arc.js +29 -0
- package/cjs/common/segment/curve/arc.js.map +1 -0
- package/cjs/common/segment/curve/base.d.ts +13 -0
- package/cjs/common/segment/curve/base.js +15 -0
- package/cjs/common/segment/curve/base.js.map +1 -0
- package/cjs/common/segment/curve/cubic-bezier.d.ts +17 -0
- package/cjs/common/segment/curve/cubic-bezier.js +42 -0
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -0
- package/cjs/common/segment/curve/curve-context.d.ts +19 -0
- package/cjs/common/segment/curve/curve-context.js +48 -0
- package/cjs/common/segment/curve/curve-context.js.map +1 -0
- package/cjs/common/segment/curve/ellipse.d.ts +18 -0
- package/cjs/common/segment/curve/ellipse.js +30 -0
- package/cjs/common/segment/curve/ellipse.js.map +1 -0
- package/cjs/common/segment/curve/line.d.ts +16 -0
- package/cjs/common/segment/curve/line.js +41 -0
- package/cjs/common/segment/curve/line.js.map +1 -0
- package/cjs/common/segment/curve/move.d.ts +13 -0
- package/cjs/common/segment/curve/move.js +28 -0
- package/cjs/common/segment/curve/move.js.map +1 -0
- package/cjs/common/segment/curve/path.d.ts +11 -0
- package/cjs/common/segment/curve/path.js +31 -0
- package/cjs/common/segment/curve/path.js.map +1 -0
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +14 -0
- package/cjs/common/segment/curve/quadratic-bezier.js +29 -0
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -0
- package/cjs/common/segment/index.d.ts +10 -0
- package/cjs/common/segment/index.js +56 -0
- package/cjs/common/segment/index.js.map +1 -0
- package/cjs/common/segment/linear-closed.d.ts +24 -0
- package/cjs/common/segment/linear-closed.js +60 -0
- package/cjs/common/segment/linear-closed.js.map +1 -0
- package/cjs/common/segment/linear.d.ts +24 -0
- package/cjs/common/segment/linear.js +59 -0
- package/cjs/common/segment/linear.js.map +1 -0
- package/cjs/common/segment/monotone.d.ts +33 -0
- package/cjs/common/segment/monotone.js +128 -0
- package/cjs/common/segment/monotone.js.map +1 -0
- package/cjs/common/segment/step.d.ts +25 -0
- package/cjs/common/segment/step.js +65 -0
- package/cjs/common/segment/step.js.map +1 -0
- package/cjs/common/shape/rect.d.ts +1 -1
- package/cjs/common/utils.d.ts +2 -1
- package/cjs/common/utils.js +15 -6
- package/cjs/common/utils.js.map +1 -1
- package/cjs/container.d.ts +2 -0
- package/cjs/container.js +10 -0
- package/cjs/container.js.map +1 -0
- package/cjs/core/constants.d.ts +3 -0
- package/cjs/core/constants.js +8 -0
- package/cjs/core/constants.js.map +1 -0
- package/cjs/core/global-module.d.ts +5 -0
- package/cjs/core/global-module.js +19 -0
- package/cjs/core/global-module.js.map +1 -0
- package/cjs/core/global.d.ts +2 -2
- package/cjs/core/global.js +1 -2
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/interface.d.ts +30 -0
- package/cjs/core/interface.js +6 -0
- package/cjs/core/interface.js.map +1 -0
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.d.ts +1 -1
- package/cjs/core/stage.js +3 -3
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +1 -1
- package/cjs/event/constant.js +1 -1
- package/cjs/event/event-manager.js +1 -1
- package/cjs/event/event-system.js +1 -1
- package/cjs/event/event-target.js +2 -1
- package/cjs/event/index.js +1 -1
- package/cjs/event/interface.js +1 -1
- package/cjs/event/type.js +1 -1
- package/cjs/event/util.js +1 -1
- package/cjs/graphic/config.js +2 -4
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/constants.d.ts +18 -0
- package/cjs/graphic/constants.js +21 -0
- package/cjs/graphic/constants.js.map +1 -0
- package/cjs/graphic/graphic-service/graphic-service.js +24 -29
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.js +1 -1
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/richtext/utils.js +6 -8
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/interface/context.d.ts +3 -3
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/curve.d.ts +42 -0
- package/cjs/interface/curve.js +6 -0
- package/cjs/interface/curve.js.map +1 -0
- package/cjs/interface/graphic/area.d.ts +1 -1
- package/cjs/interface/graphic/area.js.map +1 -1
- package/cjs/interface/graphic/creator.js.map +1 -1
- package/cjs/interface/graphic/line.d.ts +1 -1
- package/cjs/interface/graphic/line.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +2 -4
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic-service.d.ts +58 -0
- package/cjs/interface/graphic-service.js +6 -0
- package/cjs/interface/graphic-service.js.map +1 -0
- package/cjs/interface/graphic.d.ts +4 -4
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/stage.d.ts +2 -2
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/picker/contributions/canvas-picker/rect-picker.js +1 -1
- package/cjs/picker/contributions/canvas-picker/rect-picker.js.map +1 -1
- package/cjs/picker/contributions/math-picker/rect-picker.js +1 -1
- package/cjs/picker/contributions/math-picker/rect-picker.js.map +1 -1
- package/cjs/render/contributions/render/arc-render.d.ts +1 -1
- package/cjs/render/contributions/render/arc-render.js +3 -3
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/arc3d-render.js +6 -6
- package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +4 -4
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/circle-render.js +1 -1
- package/cjs/render/contributions/render/circle-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/area-contribution-render.js +6 -2
- package/cjs/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +1 -1
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/incremental-area-render.js +1 -1
- package/cjs/render/contributions/render/incremental-area-render.js.map +1 -1
- package/cjs/render/contributions/render/incremental-line-render.js +1 -1
- package/cjs/render/contributions/render/incremental-line-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +4 -4
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js +1 -1
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/pyramid3d-render.js +3 -3
- package/cjs/render/contributions/render/pyramid3d-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.js +1 -1
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/rect3d-render.js +3 -3
- package/cjs/render/contributions/render/rect3d-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +1 -1
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +5 -5
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +3 -3
- package/cjs/render/contributions/render/utils.js +3 -3
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/cjs/resource-loader/loader.d.ts +1 -1
- package/cjs/tapable/interface.d.ts +1 -0
- package/cjs/tapable/interface.js +3 -0
- package/cjs/tapable/interface.js.map +1 -0
- package/dist/vrender.js.js +1 -1
- package/dist/vrender.js.min.js +1 -1
- package/es/allocator/constants.d.ts +9 -0
- package/es/allocator/constants.js +17 -0
- package/es/allocator/constants.js.map +1 -0
- package/es/animate/custom-animate.d.ts +2 -2
- package/es/animate/custom-animate.js +13 -12
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/default-ticker.d.ts +2 -0
- package/es/animate/default-ticker.js +12 -0
- package/es/animate/default-ticker.js.map +1 -0
- package/es/animate/morphing.js +4 -5
- package/es/animate/morphing.js.map +1 -1
- package/es/animate/timeline.js +1 -2
- package/es/application.d.ts +11 -0
- package/es/application.js +3 -0
- package/es/application.js.map +1 -0
- package/es/canvas/contributions/browser/context.d.ts +2 -4
- package/es/canvas/contributions/browser/context.js +5 -6
- package/es/canvas/contributions/browser/context.js.map +1 -1
- package/es/canvas/contributions/taro/context.js +5 -6
- package/es/canvas/contributions/taro/context.js.map +1 -1
- package/es/common/bezier-utils.d.ts +5 -0
- package/es/common/bezier-utils.js +26 -0
- package/es/common/bezier-utils.js.map +1 -0
- package/es/common/canvas-utils.d.ts +1 -1
- package/es/common/canvas-utils.js +6 -3
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/custom-path2d.d.ts +47 -0
- package/es/common/custom-path2d.js +338 -0
- package/es/common/custom-path2d.js.map +1 -0
- package/es/common/segment/basis.d.ts +25 -0
- package/es/common/segment/basis.js +65 -0
- package/es/common/segment/basis.js.map +1 -0
- package/es/common/segment/common.d.ts +3 -0
- package/es/common/segment/common.js +6 -0
- package/es/common/segment/common.js.map +1 -0
- package/es/common/segment/curve/arc.d.ts +14 -0
- package/es/common/segment/curve/arc.js +22 -0
- package/es/common/segment/curve/arc.js.map +1 -0
- package/es/common/segment/curve/base.d.ts +13 -0
- package/es/common/segment/curve/base.js +7 -0
- package/es/common/segment/curve/base.js.map +1 -0
- package/es/common/segment/curve/cubic-bezier.d.ts +17 -0
- package/es/common/segment/curve/cubic-bezier.js +37 -0
- package/es/common/segment/curve/cubic-bezier.js.map +1 -0
- package/es/common/segment/curve/curve-context.d.ts +19 -0
- package/es/common/segment/curve/curve-context.js +44 -0
- package/es/common/segment/curve/curve-context.js.map +1 -0
- package/es/common/segment/curve/ellipse.d.ts +18 -0
- package/es/common/segment/curve/ellipse.js +24 -0
- package/es/common/segment/curve/ellipse.js.map +1 -0
- package/es/common/segment/curve/line.d.ts +16 -0
- package/es/common/segment/curve/line.js +34 -0
- package/es/common/segment/curve/line.js.map +1 -0
- package/es/common/segment/curve/move.d.ts +13 -0
- package/es/common/segment/curve/move.js +22 -0
- package/es/common/segment/curve/move.js.map +1 -0
- package/es/common/segment/curve/path.d.ts +11 -0
- package/es/common/segment/curve/path.js +23 -0
- package/es/common/segment/curve/path.js.map +1 -0
- package/es/common/segment/curve/quadratic-bezier.d.ts +14 -0
- package/es/common/segment/curve/quadratic-bezier.js +23 -0
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -0
- package/es/common/segment/index.d.ts +10 -0
- package/es/common/segment/index.js +49 -0
- package/es/common/segment/index.js.map +1 -0
- package/es/common/segment/linear-closed.d.ts +24 -0
- package/es/common/segment/linear-closed.js +56 -0
- package/es/common/segment/linear-closed.js.map +1 -0
- package/es/common/segment/linear.d.ts +24 -0
- package/es/common/segment/linear.js +56 -0
- package/es/common/segment/linear.js.map +1 -0
- package/es/common/segment/monotone.d.ts +33 -0
- package/es/common/segment/monotone.js +122 -0
- package/es/common/segment/monotone.js.map +1 -0
- package/es/common/segment/step.d.ts +25 -0
- package/es/common/segment/step.js +62 -0
- package/es/common/segment/step.js.map +1 -0
- package/es/common/shape/rect.d.ts +1 -1
- package/es/common/utils.d.ts +2 -1
- package/es/common/utils.js +14 -5
- package/es/common/utils.js.map +1 -1
- package/es/container.d.ts +2 -0
- package/es/container.js +4 -0
- package/es/container.js.map +1 -0
- package/es/core/constants.d.ts +3 -0
- package/es/core/constants.js +6 -0
- package/es/core/constants.js.map +1 -0
- package/es/core/global-module.d.ts +5 -0
- package/es/core/global-module.js +19 -0
- package/es/core/global-module.js.map +1 -0
- package/es/core/global.d.ts +2 -2
- package/es/core/global.js +1 -2
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/interface.d.ts +30 -0
- package/es/core/interface.js +2 -0
- package/es/core/interface.js.map +1 -0
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.d.ts +1 -1
- package/es/core/stage.js +3 -3
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +1 -1
- package/es/event/constant.js +1 -1
- package/es/event/event-manager.js +1 -1
- package/es/event/event-system.js +1 -1
- package/es/event/event-target.js +2 -1
- package/es/event/index.js +1 -1
- package/es/event/interface.js +1 -1
- package/es/event/type.js +1 -1
- package/es/event/util.js +1 -1
- package/es/graphic/config.js +2 -4
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/constants.d.ts +18 -0
- package/es/graphic/constants.js +38 -0
- package/es/graphic/constants.js.map +1 -0
- package/es/graphic/graphic-service/graphic-service.js +25 -29
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.js +1 -1
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/richtext/utils.js +6 -8
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/interface/context.d.ts +3 -3
- package/es/interface/context.js.map +1 -1
- package/es/interface/curve.d.ts +42 -0
- package/es/interface/curve.js +2 -0
- package/es/interface/curve.js.map +1 -0
- package/es/interface/graphic/area.d.ts +1 -1
- package/es/interface/graphic/area.js.map +1 -1
- package/es/interface/graphic/creator.js.map +1 -1
- package/es/interface/graphic/line.d.ts +1 -1
- package/es/interface/graphic/line.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +2 -4
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic-service.d.ts +58 -0
- package/es/interface/graphic-service.js +2 -0
- package/es/interface/graphic-service.js.map +1 -0
- package/es/interface/graphic.d.ts +4 -4
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/stage.d.ts +2 -2
- package/es/interface/stage.js.map +1 -1
- package/es/picker/contributions/canvas-picker/rect-picker.js +1 -1
- package/es/picker/contributions/canvas-picker/rect-picker.js.map +1 -1
- package/es/picker/contributions/math-picker/rect-picker.js +1 -1
- package/es/picker/contributions/math-picker/rect-picker.js.map +1 -1
- package/es/render/contributions/render/arc-render.d.ts +1 -1
- package/es/render/contributions/render/arc-render.js +3 -3
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/arc3d-render.js +6 -6
- package/es/render/contributions/render/arc3d-render.js.map +1 -1
- package/es/render/contributions/render/area-render.js +4 -4
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/circle-render.js +1 -1
- package/es/render/contributions/render/circle-render.js.map +1 -1
- package/es/render/contributions/render/contributions/area-contribution-render.js +3 -1
- package/es/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
- package/es/render/contributions/render/group-render.js +1 -1
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/incremental-area-render.js +1 -1
- package/es/render/contributions/render/incremental-area-render.js.map +1 -1
- package/es/render/contributions/render/incremental-line-render.js +1 -1
- package/es/render/contributions/render/incremental-line-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +4 -4
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js +1 -1
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js +1 -1
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/pyramid3d-render.js +3 -3
- package/es/render/contributions/render/pyramid3d-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.js +1 -1
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/rect3d-render.js +3 -3
- package/es/render/contributions/render/rect3d-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +1 -1
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/text-render.js +5 -5
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +3 -3
- package/es/render/contributions/render/utils.js +4 -3
- package/es/render/contributions/render/utils.js.map +1 -1
- package/es/resource-loader/loader.d.ts +1 -1
- package/es/tapable/interface.d.ts +1 -0
- package/es/tapable/interface.js +3 -0
- package/es/tapable/interface.js.map +1 -0
- package/es/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/curve/move.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,SAAU,SAAQ,KAAK;IAIlC,YAAY,EAAU,EAAE,EAAU;QAChC,KAAK,EAAE,CAAC;QAJV,SAAI,GAAW,aAAa,CAAC,SAAS,CAAC;QAKrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD,UAAU,CAAC,CAAS;QAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IACD,UAAU,CAAC,CAAS;QAClB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACS,UAAU;QAClB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACS,cAAc,CAAC,SAAqB;QAC5C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;CACF","file":"move.js","sourcesContent":["import type { IPoint, IPointLike } from '@visactor/vutils';\nimport type { IMoveCurve, IDirection } from '../../../interface';\nimport { Curve } from './base';\nimport { CurveTypeEnum } from '../../enums';\n\nexport class MoveCurve extends Curve implements IMoveCurve {\n type: number = CurveTypeEnum.MoveCurve;\n declare p0: IPoint;\n declare p1: IPoint;\n constructor(p0: IPoint, p1: IPoint) {\n super();\n this.p0 = p0;\n this.p1 = p1;\n }\n getAngleAt(t: number): number {\n throw new Error('ArcCurve暂不支持getAngleAt');\n }\n getPointAt(t: number): IPointLike {\n throw new Error('MoveCurve暂不支持getPointAt');\n }\n protected calcLength(): number {\n throw new Error('MoveCurve暂不支持updateLength');\n }\n protected calcProjLength(direction: IDirection): number {\n throw new Error('QuadraticBezierCurve暂不支持updateLength');\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAABBBounds, IPoint, IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { ICurvePath, ICurve } from '../../../interface';
|
|
3
|
+
export declare class CurvePath implements ICurvePath<IPoint> {
|
|
4
|
+
curves: ICurve<IPoint>[];
|
|
5
|
+
bounds: IAABBBounds;
|
|
6
|
+
constructor();
|
|
7
|
+
getCurveLengths(): number[];
|
|
8
|
+
getPointAt(t: number): IPointLike;
|
|
9
|
+
getLength(): number;
|
|
10
|
+
getBounds(): import("@visactor/vutils").IBounds;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AABBBounds } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
export class CurvePath {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.curves = [], this.bounds = new AABBBounds;
|
|
6
|
+
}
|
|
7
|
+
getCurveLengths() {
|
|
8
|
+
return this.curves.map((curve => curve.getLength()));
|
|
9
|
+
}
|
|
10
|
+
getPointAt(t) {
|
|
11
|
+
return {
|
|
12
|
+
x: 0,
|
|
13
|
+
y: 0
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getLength() {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
getBounds() {
|
|
20
|
+
return this.bounds;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/curve/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,OAAO,SAAS;IAGpB;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;IACjC,CAAC;IACD,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,UAAU,CAAC,CAAS;QAClB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACxB,CAAC;IACD,SAAS;QACP,OAAO,CAAC,CAAC;IACX,CAAC;IACD,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","file":"path.js","sourcesContent":["import type { IAABBBounds, IPoint, IPointLike } from '@visactor/vutils';\nimport { AABBBounds } from '@visactor/vutils';\nimport type { ICurvePath, ICurve } from '../../../interface';\n\nexport class CurvePath implements ICurvePath<IPoint> {\n curves: ICurve<IPoint>[];\n bounds: IAABBBounds;\n constructor() {\n this.curves = [];\n this.bounds = new AABBBounds();\n }\n getCurveLengths(): number[] {\n return this.curves.map(curve => curve.getLength());\n }\n getPointAt(t: number): IPointLike {\n return { x: 0, y: 0 };\n }\n getLength(): number {\n return 0;\n }\n getBounds() {\n return this.bounds;\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IDirection, IQuadraticBezierCurve } from '../../../interface';
|
|
2
|
+
import { Curve } from './base';
|
|
3
|
+
import type { IPoint, IPointLike } from '@visactor/vutils';
|
|
4
|
+
export declare class QuadraticBezierCurve extends Curve implements IQuadraticBezierCurve {
|
|
5
|
+
type: number;
|
|
6
|
+
readonly p0: IPoint;
|
|
7
|
+
readonly p1: IPoint;
|
|
8
|
+
readonly p2: IPoint;
|
|
9
|
+
constructor(p0: IPoint, p1: IPoint, p2: IPoint);
|
|
10
|
+
getPointAt(t: number): IPointLike;
|
|
11
|
+
protected calcLength(): number;
|
|
12
|
+
protected calcProjLength(direction: IDirection): number;
|
|
13
|
+
getAngleAt(t: number): number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CurveTypeEnum } from "src/common/enums";
|
|
2
|
+
|
|
3
|
+
import { Curve } from "./base";
|
|
4
|
+
|
|
5
|
+
export class QuadraticBezierCurve extends Curve {
|
|
6
|
+
constructor(p0, p1, p2) {
|
|
7
|
+
super(), this.type = CurveTypeEnum.QuadraticBezierCurve, this.p0 = p0, this.p1 = p1,
|
|
8
|
+
this.p2 = p2;
|
|
9
|
+
}
|
|
10
|
+
getPointAt(t) {
|
|
11
|
+
throw new Error("QuadraticBezierCurve暂不支持getPointAt");
|
|
12
|
+
}
|
|
13
|
+
calcLength() {
|
|
14
|
+
throw new Error("QuadraticBezierCurve暂不支持updateLength");
|
|
15
|
+
}
|
|
16
|
+
calcProjLength(direction) {
|
|
17
|
+
throw new Error("QuadraticBezierCurve暂不支持updateLength");
|
|
18
|
+
}
|
|
19
|
+
getAngleAt(t) {
|
|
20
|
+
throw new Error("ArcCurve暂不支持getAngleAt");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=quadratic-bezier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/curve/quadratic-bezier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG/B,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAK7C,YAAY,EAAU,EAAE,EAAU,EAAE,EAAU;QAC5C,KAAK,EAAE,CAAC;QALV,SAAI,GAAW,aAAa,CAAC,oBAAoB,CAAC;QAMhD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD,UAAU,CAAC,CAAS;QAClB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACS,UAAU;QAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACS,cAAc,CAAC,SAAqB;QAC5C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,UAAU,CAAC,CAAS;QAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;CACF","file":"quadratic-bezier.js","sourcesContent":["import { CurveTypeEnum } from 'src/common/enums';\nimport type { IDirection, IQuadraticBezierCurve } from '../../../interface';\nimport { Curve } from './base';\nimport type { IPoint, IPointLike } from '@visactor/vutils';\n\nexport class QuadraticBezierCurve extends Curve implements IQuadraticBezierCurve {\n type: number = CurveTypeEnum.QuadraticBezierCurve;\n declare readonly p0: IPoint;\n declare readonly p1: IPoint;\n declare readonly p2: IPoint;\n constructor(p0: IPoint, p1: IPoint, p2: IPoint) {\n super();\n this.p0 = p0;\n this.p1 = p1;\n this.p2 = p2;\n }\n getPointAt(t: number): IPointLike {\n throw new Error('QuadraticBezierCurve暂不支持getPointAt');\n }\n protected calcLength(): number {\n throw new Error('QuadraticBezierCurve暂不支持updateLength');\n }\n protected calcProjLength(direction: IDirection): number {\n throw new Error('QuadraticBezierCurve暂不支持updateLength');\n }\n getAngleAt(t: number): number {\n throw new Error('ArcCurve暂不支持getAngleAt');\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import { ICurveType, ISegPath2D } from '../../interface';
|
|
3
|
+
export * from './linear';
|
|
4
|
+
export * from './linear-closed';
|
|
5
|
+
export * from './basis';
|
|
6
|
+
export * from './monotone';
|
|
7
|
+
export * from './step';
|
|
8
|
+
export declare function calcLineCache(points: IPointLike[], curveType: ICurveType, params?: {
|
|
9
|
+
startPoint: IPointLike;
|
|
10
|
+
}): ISegPath2D | null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { genLinearSegments } from "./linear";
|
|
2
|
+
|
|
3
|
+
import { genBasisSegments } from "./basis";
|
|
4
|
+
|
|
5
|
+
import { genMonotoneXSegments, genMonotoneYSegments } from "./monotone";
|
|
6
|
+
|
|
7
|
+
import { genStepSegments } from "./step";
|
|
8
|
+
|
|
9
|
+
import { genLinearClosedSegments } from "./linear-closed";
|
|
10
|
+
|
|
11
|
+
export * from "./linear";
|
|
12
|
+
|
|
13
|
+
export * from "./linear-closed";
|
|
14
|
+
|
|
15
|
+
export * from "./basis";
|
|
16
|
+
|
|
17
|
+
export * from "./monotone";
|
|
18
|
+
|
|
19
|
+
export * from "./step";
|
|
20
|
+
|
|
21
|
+
export function calcLineCache(points, curveType, params) {
|
|
22
|
+
switch (curveType) {
|
|
23
|
+
case "linear":
|
|
24
|
+
default:
|
|
25
|
+
return genLinearSegments(points, params);
|
|
26
|
+
|
|
27
|
+
case "basis":
|
|
28
|
+
return genBasisSegments(points, params);
|
|
29
|
+
|
|
30
|
+
case "monotoneX":
|
|
31
|
+
return genMonotoneXSegments(points, params);
|
|
32
|
+
|
|
33
|
+
case "monotoneY":
|
|
34
|
+
return genMonotoneYSegments(points, params);
|
|
35
|
+
|
|
36
|
+
case "step":
|
|
37
|
+
return genStepSegments(points, .5, params);
|
|
38
|
+
|
|
39
|
+
case "stepBefore":
|
|
40
|
+
return genStepSegments(points, 0, params);
|
|
41
|
+
|
|
42
|
+
case "stepAfter":
|
|
43
|
+
return genStepSegments(points, 1, params);
|
|
44
|
+
|
|
45
|
+
case "linearClosed":
|
|
46
|
+
return genLinearClosedSegments(points, params);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AAEvB,MAAM,UAAU,aAAa,CAC3B,MAAoB,EACpB,SAAqB,EACrB,MAAmC;IAEnC,QAAQ,SAAS,EAAE;QACjB,KAAK,QAAQ;YACX,OAAO,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3C,KAAK,OAAO;YACV,OAAO,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,KAAK,WAAW;YACd,OAAO,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9C,KAAK,WAAW;YACd,OAAO,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9C,KAAK,MAAM;YACT,OAAO,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC9C,KAAK,YAAY;YACf,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC5C,KAAK,WAAW;YACd,OAAO,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAC5C,KAAK,cAAc;YACjB,OAAO,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjD;YACE,OAAO,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C;AACH,CAAC","file":"index.js","sourcesContent":["import { IPointLike } from '@visactor/vutils';\nimport { ICurveType, ISegPath2D } from '../../interface';\nimport { genLinearSegments } from './linear';\nimport { genBasisSegments } from './basis';\nimport { genMonotoneXSegments, genMonotoneYSegments } from './monotone';\nimport { genStepSegments } from './step';\nimport { genLinearClosedSegments } from './linear-closed';\n\nexport * from './linear';\nexport * from './linear-closed';\nexport * from './basis';\nexport * from './monotone';\nexport * from './step';\n\nexport function calcLineCache(\n points: IPointLike[],\n curveType: ICurveType,\n params?: { startPoint: IPointLike }\n): ISegPath2D | null {\n switch (curveType) {\n case 'linear':\n return genLinearSegments(points, params);\n case 'basis':\n return genBasisSegments(points, params);\n case 'monotoneX':\n return genMonotoneXSegments(points, params);\n case 'monotoneY':\n return genMonotoneYSegments(points, params);\n case 'step':\n return genStepSegments(points, 0.5, params);\n case 'stepBefore':\n return genStepSegments(points, 0, params);\n case 'stepAfter':\n return genStepSegments(points, 1, params);\n case 'linearClosed':\n return genLinearClosedSegments(points, params);\n default:\n return genLinearSegments(points, params);\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';
|
|
3
|
+
export declare class LinearClosed implements ILinearSegment {
|
|
4
|
+
context: ISegPath2D;
|
|
5
|
+
private _lastDefined?;
|
|
6
|
+
protected startPoint?: IPointLike;
|
|
7
|
+
constructor(context: ISegPath2D, startPoint?: IPointLike);
|
|
8
|
+
_x: number;
|
|
9
|
+
_y: number;
|
|
10
|
+
_x0: number;
|
|
11
|
+
_x1: number;
|
|
12
|
+
_y0: number;
|
|
13
|
+
_y1: number;
|
|
14
|
+
_line: number;
|
|
15
|
+
_point: number;
|
|
16
|
+
areaStart(): void;
|
|
17
|
+
areaEnd(): void;
|
|
18
|
+
lineStart(): void;
|
|
19
|
+
lineEnd(): void;
|
|
20
|
+
point(p: IPointLike): void;
|
|
21
|
+
tryUpdateLength(): number;
|
|
22
|
+
}
|
|
23
|
+
export declare function genLinearClosedSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
|
|
24
|
+
export declare function genLinearClosedTypeSegments(path: ILinearSegment, points: IPointLike[]): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { abs } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { SegContext } from "../seg-context";
|
|
4
|
+
|
|
5
|
+
import { genCurveSegments } from "./common";
|
|
6
|
+
|
|
7
|
+
import { Direction } from "../enums";
|
|
8
|
+
|
|
9
|
+
export class LinearClosed {
|
|
10
|
+
constructor(context, startPoint) {
|
|
11
|
+
this.context = context, startPoint && (this.startPoint = startPoint);
|
|
12
|
+
}
|
|
13
|
+
areaStart() {
|
|
14
|
+
this._line = 0;
|
|
15
|
+
}
|
|
16
|
+
areaEnd() {
|
|
17
|
+
this._line = NaN;
|
|
18
|
+
}
|
|
19
|
+
lineStart() {
|
|
20
|
+
this._point = 0, this.startPoint && this.point(this.startPoint);
|
|
21
|
+
}
|
|
22
|
+
lineEnd() {
|
|
23
|
+
this.context.closePath();
|
|
24
|
+
}
|
|
25
|
+
point(p) {
|
|
26
|
+
const x = p.x, y = p.y;
|
|
27
|
+
switch (this._point) {
|
|
28
|
+
case 0:
|
|
29
|
+
this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined) : this.context.moveTo(x, y);
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
case 1:
|
|
33
|
+
this._point = 2;
|
|
34
|
+
|
|
35
|
+
default:
|
|
36
|
+
this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined);
|
|
37
|
+
}
|
|
38
|
+
this._lastDefined = p.defined;
|
|
39
|
+
}
|
|
40
|
+
tryUpdateLength() {
|
|
41
|
+
return this.context.tryUpdateLength();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function genLinearClosedSegments(points, params = {}) {
|
|
46
|
+
const {direction: direction, startPoint: startPoint} = params;
|
|
47
|
+
if (points.length < 2 - Number(!!startPoint)) return null;
|
|
48
|
+
const segContext = new SegContext("linear", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
|
|
49
|
+
return genLinearClosedTypeSegments(new LinearClosed(segContext, startPoint), points),
|
|
50
|
+
segContext;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function genLinearClosedTypeSegments(path, points) {
|
|
54
|
+
return genCurveSegments(path, points, 1);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=linear-closed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/linear-closed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsBrC,MAAM,OAAO,YAAY;IAMvB,YAAY,OAAmB,EAAE,UAAuB;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;IAC/C,CAAC;IAUD,SAAS;QACP,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IACD,SAAS;QACP,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IACD,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,CAAa;QACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,QAAQ,IAAI,CAAC,MAAM,EAAE;YACnB,KAAK,CAAC;gBACJ,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;gBAChB,IAAI,CAAC,KAAK;oBACR,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,KAAK,K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AC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAoB,EAAE,MAAoB;IACpF,OAAO,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","file":"linear-closed.js","sourcesContent":["import { abs, IPointLike } from '@visactor/vutils';\nimport { SegContext } from '../seg-context';\nimport { genCurveSegments } from './common';\nimport { Direction } from '../enums';\nimport type { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class LinearClosed implements ILinearSegment {\n declare context: ISegPath2D;\n private _lastDefined?: boolean;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n startPoint && (this.startPoint = startPoint);\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n this.context.closePath();\n }\n point(p: IPointLike): void {\n const x = p.x;\n const y = p.y;\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false)\n : this.context.moveTo(x, y);\n break;\n case 1:\n this._point = 2; // falls through\n default:\n this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false);\n break;\n }\n\n this._lastDefined = p.defined;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport function genLinearClosedSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = new SegContext(\n 'linear',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const linear = new LinearClosed(segContext, startPoint);\n\n genLinearClosedTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearClosedTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';
|
|
3
|
+
export declare class Linear implements ILinearSegment {
|
|
4
|
+
context: ISegPath2D;
|
|
5
|
+
private _lastDefined?;
|
|
6
|
+
protected startPoint?: IPointLike;
|
|
7
|
+
constructor(context: ISegPath2D, startPoint?: IPointLike);
|
|
8
|
+
_x: number;
|
|
9
|
+
_y: number;
|
|
10
|
+
_x0: number;
|
|
11
|
+
_x1: number;
|
|
12
|
+
_y0: number;
|
|
13
|
+
_y1: number;
|
|
14
|
+
_line: number;
|
|
15
|
+
_point: number;
|
|
16
|
+
areaStart(): void;
|
|
17
|
+
areaEnd(): void;
|
|
18
|
+
lineStart(): void;
|
|
19
|
+
lineEnd(): void;
|
|
20
|
+
point(p: IPointLike): void;
|
|
21
|
+
tryUpdateLength(): number;
|
|
22
|
+
}
|
|
23
|
+
export declare function genLinearSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
|
|
24
|
+
export declare function genLinearTypeSegments(path: ILinearSegment, points: IPointLike[]): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { abs } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { SegContext } from "../seg-context";
|
|
4
|
+
|
|
5
|
+
import { genCurveSegments } from "./common";
|
|
6
|
+
|
|
7
|
+
import { Direction } from "../enums";
|
|
8
|
+
|
|
9
|
+
export class Linear {
|
|
10
|
+
constructor(context, startPoint) {
|
|
11
|
+
this.context = context, startPoint && (this.startPoint = startPoint);
|
|
12
|
+
}
|
|
13
|
+
areaStart() {
|
|
14
|
+
this._line = 0;
|
|
15
|
+
}
|
|
16
|
+
areaEnd() {
|
|
17
|
+
this._line = NaN;
|
|
18
|
+
}
|
|
19
|
+
lineStart() {
|
|
20
|
+
this._point = 0, this.startPoint && this.point(this.startPoint);
|
|
21
|
+
}
|
|
22
|
+
lineEnd() {
|
|
23
|
+
(this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(),
|
|
24
|
+
this._line = 1 - this._line;
|
|
25
|
+
}
|
|
26
|
+
point(p) {
|
|
27
|
+
const x = p.x, y = p.y;
|
|
28
|
+
switch (this._point) {
|
|
29
|
+
case 0:
|
|
30
|
+
this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined) : this.context.moveTo(x, y);
|
|
31
|
+
break;
|
|
32
|
+
|
|
33
|
+
case 1:
|
|
34
|
+
this._point = 2;
|
|
35
|
+
|
|
36
|
+
default:
|
|
37
|
+
this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined);
|
|
38
|
+
}
|
|
39
|
+
this._lastDefined = p.defined;
|
|
40
|
+
}
|
|
41
|
+
tryUpdateLength() {
|
|
42
|
+
return this.context.tryUpdateLength();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function genLinearSegments(points, params = {}) {
|
|
47
|
+
const {direction: direction, startPoint: startPoint} = params;
|
|
48
|
+
if (points.length < 2 - Number(!!startPoint)) return null;
|
|
49
|
+
const segContext = new SegContext("linear", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
|
|
50
|
+
return genLinearTypeSegments(new Linear(segContext, startPoint), points), segContext;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function genLinearTypeSegments(path, points) {
|
|
54
|
+
return genCurveSegments(path, points, 1);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=linear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/linear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsBrC,MAAM,OAAO,MAAM;IAMjB,YAAY,OAAmB,EAAE,UAAuB;QACtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;IAC/C,CAAC;IAUD,SAAS;QACP,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAC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AO,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAoB,EAAE,SAA4B,EAAE;IACpF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC;KACb;IAED,MAAM,UAAU,GAAG,IAAI,UAAU,CAC/B,QAAQ,EACR,SAAS,aAAT,SAAS,cAAT,SAAS,GACP,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC,CAAC,SAAS,CAAC,GAAG;QACf,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CACxB,CAAC;IACF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAElD,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEtC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAoB,EAAE,MAAoB;IAC9E,OAAO,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","file":"linear.js","sourcesContent":["import { abs, IPointLike } from '@visactor/vutils';\nimport { SegContext } from '../seg-context';\nimport { genCurveSegments } from './common';\nimport { Direction } from '../enums';\nimport { IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构,定义绘制线段的方法\n// https://github.com/d3/d3-shape/blob/main/src/curve/linear.js\nexport class Linear implements ILinearSegment {\n declare context: ISegPath2D;\n private _lastDefined?: boolean;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n startPoint && (this.startPoint = startPoint);\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n const x = p.x;\n const y = p.y;\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false)\n : this.context.moveTo(x, y);\n break;\n case 1:\n this._point = 2; // falls through\n default:\n this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false);\n break;\n }\n\n this._lastDefined = p.defined;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport function genLinearSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n\n const segContext = new SegContext(\n 'linear',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const linear = new Linear(segContext, startPoint);\n\n genLinearTypeSegments(linear, points);\n\n return segContext;\n}\n\nexport function genLinearTypeSegments(path: ILinearSegment, points: IPointLike[]): void {\n return genCurveSegments(path, points, 1);\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';
|
|
3
|
+
export declare class MonotoneX implements ICurvedSegment {
|
|
4
|
+
protected _lastDefined?: boolean;
|
|
5
|
+
context: ISegPath2D;
|
|
6
|
+
_t0: number;
|
|
7
|
+
protected startPoint?: IPointLike;
|
|
8
|
+
constructor(context: ISegPath2D, startPoint?: IPointLike);
|
|
9
|
+
_x: number;
|
|
10
|
+
_y: number;
|
|
11
|
+
_x0: number;
|
|
12
|
+
_x1: number;
|
|
13
|
+
_y0: number;
|
|
14
|
+
_y1: number;
|
|
15
|
+
_line: number;
|
|
16
|
+
_point: number;
|
|
17
|
+
areaStart(): void;
|
|
18
|
+
areaEnd(): void;
|
|
19
|
+
lineStart(): void;
|
|
20
|
+
lineEnd(): void;
|
|
21
|
+
point(p: IPointLike): void;
|
|
22
|
+
tryUpdateLength(): number;
|
|
23
|
+
}
|
|
24
|
+
export declare class MonotoneY extends MonotoneX {
|
|
25
|
+
context: ISegPath2D;
|
|
26
|
+
protected startPoint?: IPointLike;
|
|
27
|
+
constructor(context: ISegPath2D, startPoint?: IPointLike);
|
|
28
|
+
point(p: IPointLike): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void;
|
|
31
|
+
export declare function genMonotoneXSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
|
|
32
|
+
export declare function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void;
|
|
33
|
+
export declare function genMonotoneYSegments(points: IPointLike[], params?: IGenSegmentParams): ISegPath2D | null;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { abs } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { genLinearSegments } from "./linear";
|
|
4
|
+
|
|
5
|
+
import { genCurveSegments } from "./common";
|
|
6
|
+
|
|
7
|
+
import { ReflectSegContext, SegContext } from "../seg-context";
|
|
8
|
+
|
|
9
|
+
import { Direction } from "../enums";
|
|
10
|
+
|
|
11
|
+
function sign(x) {
|
|
12
|
+
return x < 0 ? -1 : 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function slope3(curveClass, x2, y2) {
|
|
16
|
+
const h0 = curveClass._x1 - curveClass._x0, h1 = x2 - curveClass._x1, s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0)), s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0)), p = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
17
|
+
return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), .5 * Math.abs(p)) || 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function slope2(curveClass, t) {
|
|
21
|
+
const h = curveClass._x1 - curveClass._x0;
|
|
22
|
+
return h ? (3 * (curveClass._y1 - curveClass._y0) / h - t) / 2 : t;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function point(curveClass, t0, t1, defined) {
|
|
26
|
+
const x0 = curveClass._x0, y0 = curveClass._y0, x1 = curveClass._x1, y1 = curveClass._y1, dx = (x1 - x0) / 3;
|
|
27
|
+
curveClass.context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1, defined);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class MonotoneX {
|
|
31
|
+
constructor(context, startPoint) {
|
|
32
|
+
this.context = context, this.startPoint = startPoint;
|
|
33
|
+
}
|
|
34
|
+
areaStart() {
|
|
35
|
+
this._line = 0;
|
|
36
|
+
}
|
|
37
|
+
areaEnd() {
|
|
38
|
+
this._line = NaN;
|
|
39
|
+
}
|
|
40
|
+
lineStart() {
|
|
41
|
+
this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0, this.startPoint && this.point(this.startPoint);
|
|
42
|
+
}
|
|
43
|
+
lineEnd() {
|
|
44
|
+
switch (this._point) {
|
|
45
|
+
case 2:
|
|
46
|
+
this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined);
|
|
47
|
+
break;
|
|
48
|
+
|
|
49
|
+
case 3:
|
|
50
|
+
point(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined);
|
|
51
|
+
}
|
|
52
|
+
(this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(),
|
|
53
|
+
this._line = 1 - this._line;
|
|
54
|
+
}
|
|
55
|
+
point(p) {
|
|
56
|
+
let t1 = NaN;
|
|
57
|
+
const x = p.x, y = p.y;
|
|
58
|
+
if (x !== this._x1 || y !== this._y1) {
|
|
59
|
+
switch (this._point) {
|
|
60
|
+
case 0:
|
|
61
|
+
this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined) : this.context.moveTo(x, y);
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case 1:
|
|
65
|
+
this._point = 2;
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case 2:
|
|
69
|
+
this._point = 3, point(this, slope2(this, t1 = slope3(this, x, y)), t1, !1 !== this._lastDefined && !1 !== p.defined);
|
|
70
|
+
break;
|
|
71
|
+
|
|
72
|
+
default:
|
|
73
|
+
point(this, this._t0, t1 = slope3(this, x, y), !1 !== this._lastDefined && !1 !== p.defined);
|
|
74
|
+
}
|
|
75
|
+
this._x0 = this._x1, this._x1 = x, this._y0 = this._y1, this._y1 = y, this._t0 = t1,
|
|
76
|
+
this._lastDefined = !1 !== p.defined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
tryUpdateLength() {
|
|
80
|
+
return this.context.tryUpdateLength();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class MonotoneY extends MonotoneX {
|
|
85
|
+
constructor(context, startPoint) {
|
|
86
|
+
super(context, startPoint);
|
|
87
|
+
}
|
|
88
|
+
point(p) {
|
|
89
|
+
return super.point({
|
|
90
|
+
y: p.x,
|
|
91
|
+
x: p.y,
|
|
92
|
+
defined: p.defined
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function genMonotpneXTypeSegments(path, points) {
|
|
98
|
+
return genCurveSegments(path, points, 2);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function genMonotoneXSegments(points, params = {}) {
|
|
102
|
+
const {direction: direction, startPoint: startPoint} = params;
|
|
103
|
+
if (points.length < 2 - Number(!!startPoint)) return null;
|
|
104
|
+
if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
|
|
105
|
+
const segContext = new SegContext("monotoneX", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
|
|
106
|
+
return genMonotpneXTypeSegments(new MonotoneX(segContext, startPoint), points),
|
|
107
|
+
segContext;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function genMonotpneYTypeSegments(path, points) {
|
|
111
|
+
return genCurveSegments(path, points, 2);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function genMonotoneYSegments(points, params = {}) {
|
|
115
|
+
const {direction: direction, startPoint: startPoint} = params;
|
|
116
|
+
if (points.length < 2 - Number(!!startPoint)) return null;
|
|
117
|
+
if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
|
|
118
|
+
const segContext = new ReflectSegContext("monotoneY", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
|
|
119
|
+
return genMonotpneYTypeSegments(new MonotoneY(segContext, startPoint), points),
|
|
120
|
+
segContext;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=monotone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/common/segment/monotone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAsBrC,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAMD,SAAS,MAAM,CAAC,UAAiC,EAAE,EAAU,EAAE,EAAU;IACvE,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,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C,OAAO,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C;IACD,MAAM,UAAU,GAAG,IAAI,iBAAiB,CACtC,WAAW,EACX,SAAS,aAAT,SAAS,cAAT,SAAS,GACP,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC,CAAC,SAAS,CAAC,GAAG;QACf,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CACxB,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAExD,wBAAwB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5C,OAAO,UAAU,CAAC;AACpB,CAAC","file":"monotone.js","sourcesContent":["import { IPointLike, abs } from '@visactor/vutils';\nimport { genLinearSegments } from './linear';\nimport { genCurveSegments } from './common';\nimport { ReflectSegContext, SegContext } from '../seg-context';\nimport { Direction } from '../enums';\nimport { ICurvedSegment, IGenSegmentParams, ISegPath2D } from '../../interface/curve';\n\n/**\n * 部分源码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\n// 基于d3-shape重构\n// https://github.com/d3/d3-shape/blob/main/src/curve/monotone.js\nfunction sign(x: number): number {\n return x < 0 ? -1 : 1;\n}\n\n// Calculate the slopes of the tangents (Hermite-type interpolation) based on\n// the following paper: Steffen, M. 1990. A Simple Method for Monotonic\n// Interpolation in One Dimension. Astronomy and Astrophysics, Vol. 239, NO.\n// NOV(II), P. 443, 1990.\nfunction slope3(curveClass: MonotoneX | MonotoneY, x2: number, y2: number) {\n const h0 = curveClass._x1 - curveClass._x0;\n const h1 = x2 - curveClass._x1;\n const s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0));\n const s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0));\n const p = (s0 * h1 + s1 * h0) / (h0 + h1);\n return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n}\n\n// Calculate a one-sided slope.\nfunction slope2(curveClass: MonotoneX | MonotoneY, t: number) {\n const h = curveClass._x1 - curveClass._x0;\n return h ? ((3 * (curveClass._y1 - curveClass._y0)) / h - t) / 2 : t;\n}\n\n// According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations\n// \"you can express cubic Hermite interpolation in terms of cubic Bézier curves\n// with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1\".\nfunction point(curveClass: MonotoneX | MonotoneY, t0: number, t1: number, defined: boolean) {\n const x0 = curveClass._x0;\n const y0 = curveClass._y0;\n const x1 = curveClass._x1;\n const y1 = curveClass._y1;\n const dx = (x1 - x0) / 3;\n curveClass.context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1, defined);\n}\n\nexport class MonotoneX implements ICurvedSegment {\n protected _lastDefined?: boolean;\n declare context: ISegPath2D;\n declare _t0: number;\n\n protected startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n this.context = context;\n this.startPoint = startPoint;\n }\n _x: number;\n _y: number;\n _x0: number;\n _x1: number;\n _y0: number;\n _y1: number;\n _line: number;\n _point: number;\n\n areaStart() {\n this._line = 0;\n }\n areaEnd() {\n this._line = NaN;\n }\n lineStart() {\n this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;\n this._point = 0;\n this.startPoint && this.point(this.startPoint);\n }\n lineEnd() {\n switch (this._point) {\n case 2:\n this.context.lineTo(this._x1, this._y1, this._lastDefined !== false);\n break;\n case 3:\n point(this, this._t0, slope2(this, this._t0), this._lastDefined !== false);\n break;\n }\n if (this._line || (this._line !== 0 && this._point === 1)) {\n this.context.closePath();\n }\n this._line = 1 - this._line;\n }\n point(p: IPointLike): void {\n let t1 = NaN;\n\n const x = p.x;\n const y = p.y;\n if (x === this._x1 && y === this._y1) {\n return;\n } // Ignore coincident points.\n switch (this._point) {\n case 0:\n this._point = 1;\n this._line\n ? this.context.lineTo(x, y, this._lastDefined !== false && p.defined !== false)\n : this.context.moveTo(x, y);\n break;\n case 1:\n this._point = 2;\n break;\n case 2:\n this._point = 3;\n point(this, slope2(this, (t1 = slope3(this, x, y))), t1, this._lastDefined !== false && p.defined !== false);\n break;\n default:\n point(this, this._t0, (t1 = slope3(this, x, y)), this._lastDefined !== false && p.defined !== false);\n break;\n }\n\n (this._x0 = this._x1), (this._x1 = x);\n (this._y0 = this._y1), (this._y1 = y);\n this._t0 = t1;\n this._lastDefined = p.defined !== false;\n }\n\n tryUpdateLength(): number {\n return this.context.tryUpdateLength();\n }\n}\n\nexport class MonotoneY extends MonotoneX {\n declare context: ISegPath2D;\n\n protected declare startPoint?: IPointLike;\n\n constructor(context: ISegPath2D, startPoint?: IPointLike) {\n super(context, startPoint);\n }\n\n point(p: IPointLike): void {\n return super.point({ y: p.x, x: p.y, defined: p.defined } as any);\n }\n}\n\nexport function genMonotpneXTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneXSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new SegContext(\n 'monotoneX',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneX = new MonotoneX(segContext, startPoint);\n\n genMonotpneXTypeSegments(monotoneX, points);\n\n return segContext;\n}\n\nexport function genMonotpneYTypeSegments(path: MonotoneX, points: IPointLike[]): void {\n return genCurveSegments(path, points, 2);\n}\n\nexport function genMonotoneYSegments(points: IPointLike[], params: IGenSegmentParams = {}): ISegPath2D | null {\n const { direction, startPoint } = params;\n if (points.length < 2 - Number(!!startPoint)) {\n return null;\n }\n if (points.length < 3 - Number(!!startPoint)) {\n return genLinearSegments(points, params);\n }\n const segContext = new ReflectSegContext(\n 'monotoneY',\n direction ??\n (abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y)\n ? Direction.ROW\n : Direction.COLUMN)\n );\n const monotoneY = new MonotoneY(segContext, startPoint);\n\n genMonotpneYTypeSegments(monotoneY, points);\n\n return segContext;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { ICurvedSegment, IGenSegmentParams, ILinearSegment, ISegPath2D } from '../../interface/curve';
|
|
3
|
+
export declare class Step implements ICurvedSegment {
|
|
4
|
+
context: ISegPath2D;
|
|
5
|
+
_t: number;
|
|
6
|
+
private _lastDefined?;
|
|
7
|
+
protected startPoint?: IPointLike;
|
|
8
|
+
constructor(context: ISegPath2D, t?: number, startPoint?: IPointLike);
|
|
9
|
+
_x: number;
|
|
10
|
+
_y: number;
|
|
11
|
+
_x0: number;
|
|
12
|
+
_x1: number;
|
|
13
|
+
_y0: number;
|
|
14
|
+
_y1: number;
|
|
15
|
+
_line: number;
|
|
16
|
+
_point: number;
|
|
17
|
+
areaStart(): void;
|
|
18
|
+
areaEnd(): void;
|
|
19
|
+
lineStart(): void;
|
|
20
|
+
lineEnd(): void;
|
|
21
|
+
point(p: IPointLike): void;
|
|
22
|
+
tryUpdateLength(): number;
|
|
23
|
+
}
|
|
24
|
+
export declare function genStepSegments(points: IPointLike[], t: number, params?: IGenSegmentParams): ISegPath2D | null;
|
|
25
|
+
export declare function genStepTypeSegments(path: ILinearSegment, points: IPointLike[]): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { abs } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { SegContext } from "../seg-context";
|
|
4
|
+
|
|
5
|
+
import { genCurveSegments } from "./common";
|
|
6
|
+
|
|
7
|
+
import { Direction } from "../enums";
|
|
8
|
+
|
|
9
|
+
export class Step {
|
|
10
|
+
constructor(context, t = .5, startPoint) {
|
|
11
|
+
this.context = context, this._t = t, this.startPoint = startPoint;
|
|
12
|
+
}
|
|
13
|
+
areaStart() {
|
|
14
|
+
this._line = 0;
|
|
15
|
+
}
|
|
16
|
+
areaEnd() {
|
|
17
|
+
this._line = NaN;
|
|
18
|
+
}
|
|
19
|
+
lineStart() {
|
|
20
|
+
this._x = this._y = NaN, this._point = 0, this.startPoint && this.point(this.startPoint);
|
|
21
|
+
}
|
|
22
|
+
lineEnd() {
|
|
23
|
+
0 < this._t && this._t < 1 && 2 === this._point && this.context.lineTo(this._x, this._y, !1 !== this._lastDefined),
|
|
24
|
+
(this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(),
|
|
25
|
+
this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
|
|
26
|
+
}
|
|
27
|
+
point(p) {
|
|
28
|
+
const x = p.x, y = p.y;
|
|
29
|
+
switch (this._point) {
|
|
30
|
+
case 0:
|
|
31
|
+
this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined) : this.context.moveTo(x, y);
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case 1:
|
|
35
|
+
this._point = 2;
|
|
36
|
+
|
|
37
|
+
default:
|
|
38
|
+
if (this._t <= 0) this.context.lineTo(this._x, y, !1 !== this._lastDefined && !1 !== p.defined),
|
|
39
|
+
this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined); else {
|
|
40
|
+
const x1 = this._x * (1 - this._t) + x * this._t;
|
|
41
|
+
this.context.lineTo(x1, this._y, !1 !== this._lastDefined && !1 !== p.defined),
|
|
42
|
+
this.context.lineTo(x1, y, !1 !== this._lastDefined && !1 !== p.defined);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this._lastDefined = p.defined, this._x = x, this._y = y;
|
|
46
|
+
}
|
|
47
|
+
tryUpdateLength() {
|
|
48
|
+
return this.context.tryUpdateLength();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function genStepSegments(points, t, params = {}) {
|
|
53
|
+
const {direction: direction, startPoint: startPoint} = params;
|
|
54
|
+
if (points.length < 2 - Number(!!startPoint)) return null;
|
|
55
|
+
const segContext = new SegContext("step", null != direction ? direction : abs(points[points.length - 1].x - points[0].x) > abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
|
|
56
|
+
return genStepTypeSegments(new Step(segContext, t, startPoint), points), segContext;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function genStepTypeSegments(path, points) {
|
|
60
|
+
return genCurveSegments(path, points, 1);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=step.js.map
|