@visactor/vrender-core 0.21.0-vstory.2 → 0.21.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/cjs/animate/Ticker/default-ticker.d.ts +2 -3
- package/cjs/animate/Ticker/default-ticker.js +5 -8
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/animate.js +1 -1
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/custom-animate.d.ts +2 -0
- package/cjs/animate/custom-animate.js +11 -2
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/animate/easing.d.ts +0 -3
- package/cjs/animate/easing.js +1 -9
- package/cjs/animate/easing.js.map +1 -1
- package/cjs/color-string/store.js +2 -1
- package/cjs/common/3d-interceptor.js +1 -2
- package/cjs/common/bezier-utils.d.ts +0 -3
- package/cjs/common/bezier-utils.js +2 -17
- package/cjs/common/bezier-utils.js.map +1 -1
- package/cjs/common/color-utils.js +2 -2
- package/cjs/common/color-utils.js.map +1 -1
- package/cjs/common/custom-path2d.d.ts +0 -4
- package/cjs/common/custom-path2d.js +11 -43
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/render-area.js +1 -0
- package/cjs/common/render-command-list.js +1 -2
- package/cjs/common/segment/curve/arc.d.ts +1 -4
- package/cjs/common/segment/curve/arc.js +1 -10
- package/cjs/common/segment/curve/arc.js.map +1 -1
- package/cjs/common/segment/curve/base.d.ts +1 -4
- package/cjs/common/segment/curve/base.js.map +1 -1
- package/cjs/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/cjs/common/segment/curve/cubic-bezier.js +3 -24
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
- package/cjs/common/segment/curve/curve-context.js +4 -5
- package/cjs/common/segment/curve/curve-context.js.map +1 -1
- package/cjs/common/segment/curve/ellipse.d.ts +1 -4
- package/cjs/common/segment/curve/ellipse.js +0 -9
- package/cjs/common/segment/curve/ellipse.js.map +1 -1
- package/cjs/common/segment/curve/line.d.ts +1 -4
- package/cjs/common/segment/curve/line.js +0 -18
- package/cjs/common/segment/curve/line.js.map +1 -1
- package/cjs/common/segment/curve/move.d.ts +1 -4
- package/cjs/common/segment/curve/move.js +0 -9
- package/cjs/common/segment/curve/move.js.map +1 -1
- package/cjs/common/segment/curve/path.d.ts +1 -2
- package/cjs/common/segment/curve/path.js +2 -5
- package/cjs/common/segment/curve/path.js.map +1 -1
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/cjs/common/segment/curve/quadratic-bezier.js +5 -23
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/utils.d.ts +1 -0
- package/cjs/common/utils.js +9 -2
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +56 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +119 -18
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/contributions/textMeasure/layout.d.ts +8 -3
- package/cjs/core/contributions/textMeasure/layout.js +55 -44
- package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
- package/cjs/core/stage.d.ts +5 -0
- package/cjs/core/stage.js +20 -7
- package/cjs/core/stage.js.map +1 -1
- package/cjs/event/event-manager.d.ts +1 -0
- package/cjs/event/event-manager.js +1 -1
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/event/event-system.js +2 -1
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/graphic/builtin-symbol/rect.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/rect.js +0 -28
- package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/utils.js +0 -5
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.d.ts +1 -1
- package/cjs/graphic/config.js +8 -9
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.js +1 -2
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/richtext/line.js +9 -2
- package/cjs/graphic/richtext/line.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +4 -3
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.d.ts +2 -1
- package/cjs/graphic/richtext/utils.js +5 -3
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext/wrapper.d.ts +0 -1
- package/cjs/graphic/richtext/wrapper.js +1 -1
- package/cjs/graphic/richtext/wrapper.js.map +1 -1
- package/cjs/graphic/richtext.js +1 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/text.d.ts +11 -11
- package/cjs/graphic/text.js +102 -168
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/wrap-text.js +16 -4
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +2 -5
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/context.d.ts +1 -0
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/graphic/path.d.ts +0 -1
- package/cjs/interface/graphic/path.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +0 -2
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +11 -3
- package/cjs/interface/graphic/text.js +6 -1
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +3 -6
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/path.d.ts +0 -5
- package/cjs/interface/path.js.map +1 -1
- package/cjs/interface/picker.d.ts +0 -13
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/interface/stage.d.ts +2 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/text.d.ts +9 -1
- package/cjs/interface/text.js.map +1 -1
- package/cjs/picker/constants.d.ts +0 -2
- package/cjs/picker/constants.js +2 -3
- package/cjs/picker/constants.js.map +1 -1
- package/cjs/picker/pick-interceptor.d.ts +2 -7
- package/cjs/picker/pick-interceptor.js +2 -19
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/picker/pick-modules.js +4 -7
- package/cjs/picker/pick-modules.js.map +1 -1
- package/cjs/picker/picker-service.d.ts +2 -4
- package/cjs/picker/picker-service.js +12 -13
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js +48 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/cjs/plugins/builtin-plugin/edit-module.js +28 -84
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +217 -280
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +0 -1
- package/cjs/render/contributions/render/base-render.js +2 -20
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +4 -32
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-interceptor.js +3 -2
- package/cjs/render/contributions/render/draw-interceptor.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +12 -15
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.d.ts +1 -1
- package/cjs/render/contributions/render/text-render.js +24 -46
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +2 -1
- package/cjs/render/contributions/render/utils.js +20 -4
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/dist/index.es.js +18297 -18772
- package/es/animate/Ticker/default-ticker.d.ts +2 -3
- package/es/animate/Ticker/default-ticker.js +5 -8
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/animate.js +1 -1
- package/es/animate/animate.js.map +1 -1
- package/es/animate/custom-animate.d.ts +2 -0
- package/es/animate/custom-animate.js +11 -2
- package/es/animate/custom-animate.js.map +1 -1
- package/es/animate/easing.d.ts +0 -3
- package/es/animate/easing.js +1 -9
- package/es/animate/easing.js.map +1 -1
- package/es/color-string/store.js +2 -1
- package/es/common/3d-interceptor.js +1 -2
- package/es/common/bezier-utils.d.ts +0 -3
- package/es/common/bezier-utils.js +0 -14
- package/es/common/bezier-utils.js.map +1 -1
- package/es/common/color-utils.js +2 -2
- package/es/common/color-utils.js.map +1 -1
- package/es/common/custom-path2d.d.ts +0 -4
- package/es/common/custom-path2d.js +12 -44
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/render-area.js +2 -1
- package/es/common/render-command-list.js +1 -2
- package/es/common/segment/curve/arc.d.ts +1 -4
- package/es/common/segment/curve/arc.js +1 -10
- package/es/common/segment/curve/arc.js.map +1 -1
- package/es/common/segment/curve/base.d.ts +1 -4
- package/es/common/segment/curve/base.js.map +1 -1
- package/es/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/es/common/segment/curve/cubic-bezier.js +1 -22
- package/es/common/segment/curve/cubic-bezier.js.map +1 -1
- package/es/common/segment/curve/curve-context.js +3 -6
- package/es/common/segment/curve/curve-context.js.map +1 -1
- package/es/common/segment/curve/ellipse.d.ts +1 -4
- package/es/common/segment/curve/ellipse.js +0 -9
- package/es/common/segment/curve/ellipse.js.map +1 -1
- package/es/common/segment/curve/line.d.ts +1 -4
- package/es/common/segment/curve/line.js +0 -18
- package/es/common/segment/curve/line.js.map +1 -1
- package/es/common/segment/curve/move.d.ts +1 -4
- package/es/common/segment/curve/move.js +0 -9
- package/es/common/segment/curve/move.js.map +1 -1
- package/es/common/segment/curve/path.d.ts +1 -2
- package/es/common/segment/curve/path.js +2 -5
- package/es/common/segment/curve/path.js.map +1 -1
- package/es/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/es/common/segment/curve/quadratic-bezier.js +5 -28
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/es/common/store.js +1 -1
- package/es/common/utils.d.ts +1 -0
- package/es/common/utils.js +6 -1
- package/es/common/utils.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +56 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js +122 -17
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/contributions/textMeasure/layout.d.ts +8 -3
- package/es/core/contributions/textMeasure/layout.js +55 -44
- package/es/core/contributions/textMeasure/layout.js.map +1 -1
- package/es/core/stage.d.ts +5 -0
- package/es/core/stage.js +21 -6
- package/es/core/stage.js.map +1 -1
- package/es/event/event-manager.d.ts +1 -0
- package/es/event/event-manager.js +1 -1
- package/es/event/event-manager.js.map +1 -1
- package/es/event/event-system.js +2 -1
- package/es/event/event-system.js.map +1 -1
- package/es/graphic/builtin-symbol/rect.d.ts +1 -2
- package/es/graphic/builtin-symbol/rect.js +0 -28
- package/es/graphic/builtin-symbol/rect.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +1 -2
- package/es/graphic/builtin-symbol/utils.js +0 -5
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.d.ts +1 -1
- package/es/graphic/config.js +9 -8
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.js +1 -2
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/richtext/line.js +10 -3
- package/es/graphic/richtext/line.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +4 -3
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.d.ts +2 -1
- package/es/graphic/richtext/utils.js +6 -2
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext/wrapper.d.ts +0 -1
- package/es/graphic/richtext/wrapper.js +1 -1
- package/es/graphic/richtext/wrapper.js.map +1 -1
- package/es/graphic/richtext.js +1 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/text.d.ts +11 -11
- package/es/graphic/text.js +101 -163
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/wrap-text.js +16 -4
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -2
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +2 -5
- package/es/interface/animate.js.map +1 -1
- package/es/interface/context.d.ts +1 -0
- package/es/interface/context.js.map +1 -1
- package/es/interface/graphic/path.d.ts +0 -1
- package/es/interface/graphic/path.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +0 -2
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic/text.d.ts +11 -3
- package/es/interface/graphic/text.js +6 -1
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +3 -6
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/path.d.ts +0 -5
- package/es/interface/path.js.map +1 -1
- package/es/interface/picker.d.ts +0 -13
- package/es/interface/picker.js.map +1 -1
- package/es/interface/stage.d.ts +2 -0
- package/es/interface/stage.js.map +1 -1
- package/es/interface/text.d.ts +9 -1
- package/es/interface/text.js.map +1 -1
- package/es/picker/constants.d.ts +0 -2
- package/es/picker/constants.js +0 -4
- package/es/picker/constants.js.map +1 -1
- package/es/picker/pick-interceptor.d.ts +2 -7
- package/es/picker/pick-interceptor.js +1 -19
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/picker/pick-modules.js +3 -5
- package/es/picker/pick-modules.js.map +1 -1
- package/es/picker/picker-service.d.ts +2 -4
- package/es/picker/picker-service.js +13 -13
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js +41 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/es/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/es/plugins/builtin-plugin/edit-module.js +25 -79
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +214 -283
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc3d-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +0 -1
- package/es/render/contributions/render/base-render.js +2 -21
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/contributions/arc-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/circle-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +2 -28
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-interceptor.js +3 -2
- package/es/render/contributions/render/draw-interceptor.js.map +1 -1
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +13 -16
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/text-render.d.ts +1 -1
- package/es/render/contributions/render/text-render.js +23 -45
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +2 -1
- package/es/render/contributions/render/utils.js +18 -0
- package/es/render/contributions/render/utils.js.map +1 -1
- package/package.json +6 -5
- package/cjs/animate/easing-func.d.ts +0 -1
- package/cjs/animate/easing-func.js +0 -16
- package/cjs/animate/easing-func.js.map +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
- package/es/animate/easing-func.d.ts +0 -1
- package/es/animate/easing-func.js +0 -10
- package/es/animate/easing-func.js.map +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/path.ts"],"names":[],"mappings":"","file":"path.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D } from '../path';\n// TODO: Path svg <Path path='' />\n\nexport type IPathAttribute = {\n path: ICustomPath2D | string;\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/path.ts"],"names":[],"mappings":"","file":"path.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D } from '../path';\n// TODO: Path svg <Path path='' />\n\nexport type IPathAttribute = {\n path: ICustomPath2D | string;\n customPath: (context: ICustomPath2D, pathMark: IPath) => void;\n};\n\nexport type IPathGraphicAttribute = Partial<IGraphicAttribute> & Partial<IPathAttribute>;\n\nexport type ShapeType = 'area' | 'circle' | 'ellipse' | 'line' | 'rect';\n\nexport interface IPath extends IGraphic<IPathGraphicAttribute> {\n originType?: ShapeType;\n cache?: ICustomPath2D;\n pathShape: ICustomPath2D;\n\n getParsedPathShape: () => ICustomPath2D;\n}\n"]}
|
|
@@ -4,7 +4,6 @@ import type { ICustomPath2D, IPath2D } from '../path';
|
|
|
4
4
|
export type ISymbolAttribute = {
|
|
5
5
|
symbolType: SymbolType;
|
|
6
6
|
size: number | [number, number];
|
|
7
|
-
clipRange: number;
|
|
8
7
|
};
|
|
9
8
|
export type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;
|
|
10
9
|
export interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {
|
|
@@ -17,7 +16,6 @@ export interface ISymbolClass {
|
|
|
17
16
|
pathStr: string;
|
|
18
17
|
isSvg?: boolean;
|
|
19
18
|
draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
|
|
20
|
-
drawWithClipRange?: (ctx: IPath2D, size: number | [number, number], x: number, y: number, clipRange: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
|
|
21
19
|
drawOffset: (ctx: IPath2D, size: number | [number, number], x: number, y: number, offset: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
|
|
22
20
|
drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;
|
|
23
21
|
bounds: (size: number | [number, number], bounds: IBounds) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n};\n\nexport type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;\n\nexport interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {\n getParsedPath: () => ISymbolClass;\n}\n\nexport type SymbolType =\n | 'circle'\n | 'cross'\n | 'diamond'\n | 'square'\n | 'arrow'\n | 'arrowLeft'\n | 'arrowRight'\n | 'arrow2Left'\n | 'arrow2Right'\n | 'wedge'\n | 'thinTriangle'\n | 'triangle'\n | 'triangleUp'\n | 'triangleDown'\n | 'triangleRight'\n | 'triangleLeft'\n | 'stroke'\n | 'star'\n | 'wye'\n | 'rect'\n | 'rectRound'\n | 'roundLine'\n | string;\n\nexport interface ISymbolClass {\n type: SymbolType | string;\n path?: ICustomPath2D;\n pathStr: string;\n isSvg?: boolean;\n\n // 返回true表示内部已经调用closePath,返回false表示没有调用closePath,外部需要调用closePath\n draw: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n z?: number,\n cb?: (p: ICustomPath2D, a: any) => void\n ) => boolean;\n drawOffset: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n offset: number,\n z?: number,\n cb?: (p: ICustomPath2D, a: any) => void\n ) => boolean;\n\n drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;\n\n bounds: (size: number | [number, number], bounds: IBounds) => void;\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IAABBBounds } from '@visactor/vutils';
|
|
2
1
|
import type { IGraphicAttribute, IGraphic } from '../graphic';
|
|
3
2
|
export interface TextLayoutBBox {
|
|
4
3
|
width: number;
|
|
@@ -11,6 +10,9 @@ export interface LayoutItemType {
|
|
|
11
10
|
leftOffset?: number;
|
|
12
11
|
topOffset?: number;
|
|
13
12
|
width: number;
|
|
13
|
+
ascent: number;
|
|
14
|
+
descent: number;
|
|
15
|
+
keepCenterInLine: boolean;
|
|
14
16
|
}
|
|
15
17
|
export interface SimplifyLayoutType {
|
|
16
18
|
lines: LayoutItemType[];
|
|
@@ -25,9 +27,15 @@ export interface LayoutType {
|
|
|
25
27
|
textAlign: TextAlignType;
|
|
26
28
|
textBaseline: TextBaselineType;
|
|
27
29
|
}
|
|
30
|
+
export declare enum MeasureModeEnum {
|
|
31
|
+
estimate = 0,
|
|
32
|
+
actualBounding = 1,
|
|
33
|
+
fontBounding = 2
|
|
34
|
+
}
|
|
28
35
|
export type ITextAttribute = {
|
|
29
36
|
text: string | number | string[] | number[];
|
|
30
37
|
maxLineWidth: number;
|
|
38
|
+
maxWidth: number;
|
|
31
39
|
textAlign: TextAlignType;
|
|
32
40
|
textBaseline: TextBaselineType;
|
|
33
41
|
fontSize: number;
|
|
@@ -52,6 +60,8 @@ export type ITextAttribute = {
|
|
|
52
60
|
underlineDash: number[];
|
|
53
61
|
underlineOffset: number;
|
|
54
62
|
disableAutoClipedPoptip?: boolean;
|
|
63
|
+
measureMode?: MeasureModeEnum;
|
|
64
|
+
keepCenterInLine?: boolean;
|
|
55
65
|
};
|
|
56
66
|
export type ITextCache = {
|
|
57
67
|
clipedText?: string;
|
|
@@ -78,8 +88,6 @@ export interface IText extends IGraphic<ITextGraphicAttribute> {
|
|
|
78
88
|
cache?: ITextCache;
|
|
79
89
|
getBaselineMapAlign: () => Record<string, string>;
|
|
80
90
|
getAlignMapBaseline: () => Record<string, string>;
|
|
81
|
-
updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;
|
|
82
|
-
updateSingallineAABBBounds: (text: number | string) => IAABBBounds;
|
|
83
91
|
}
|
|
84
92
|
export type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';
|
|
85
93
|
export type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var MeasureModeEnum;
|
|
2
|
+
|
|
3
|
+
!function(MeasureModeEnum) {
|
|
4
|
+
MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding",
|
|
5
|
+
MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
|
|
6
|
+
}(MeasureModeEnum || (MeasureModeEnum = {}));
|
|
2
7
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"AAkCA,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,6DAAY,CAAA;IACZ,yEAAkB,CAAA;IAClB,qEAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B","file":"text.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n ascent: number;\n descent: number;\n keepCenterInLine: boolean;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport enum MeasureModeEnum {\n estimate = 0,\n actualBounding = 1,\n fontBounding = 2\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n maxWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number | string;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all' | 'keep-all';\n ignoreBuf: boolean;\n heightLimit: number;\n lineClamp: number;\n wrap: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n suffixPosition: 'start' | 'end' | 'middle';\n underlineDash: number[];\n underlineOffset: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n disableAutoClipedPoptip?: boolean;\n // @since 0.21.0\n // 测量模式,默认使用actualBounding\n measureMode?: MeasureModeEnum;\n // @since 0.21.0\n // 保持在行中间的位置\n keepCenterInLine?: boolean;\n};\nexport type ITextCache = {\n // 单行文本的时候缓存(多行文本没有)\n clipedText?: string;\n clipedWidth?: number;\n // 文本的布局缓存(单行文本也有)\n layoutData?: LayoutType;\n // 垂直布局的列表\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n isMultiLine: boolean;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';
|
|
2
|
-
import type { IAnimate, IStep, EasingType, IAnimateTarget
|
|
2
|
+
import type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';
|
|
3
3
|
import type { IColor } from './color';
|
|
4
4
|
import type { IGroup } from './graphic/group';
|
|
5
5
|
import type { IShadowRoot } from './graphic/shadow-root';
|
|
@@ -16,7 +16,7 @@ type IStrokeSeg = {
|
|
|
16
16
|
end: number;
|
|
17
17
|
length: number;
|
|
18
18
|
};
|
|
19
|
-
export type GraphicType = 'area' | 'circle' | 'ellipse' | 'line' | 'rect' | 'rect3d' | 'path' | 'richtext' | 'text' | 'arc' | 'arc3d' | 'image' | 'symbol' | 'group' | 'shadowroot' | 'polygon' | 'pyramid3d' | 'glyph'
|
|
19
|
+
export type GraphicType = 'area' | 'circle' | 'ellipse' | 'line' | 'rect' | 'rect3d' | 'path' | 'richtext' | 'text' | 'arc' | 'arc3d' | 'image' | 'symbol' | 'group' | 'shadowroot' | 'polygon' | 'pyramid3d' | 'glyph';
|
|
20
20
|
export type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'all-scroll' | 'col-resize' | 'row-resize' | 'n-resize' | 'e-resize' | 's-resize' | 'w-resize' | 'ne-resize' | 'nw-resize' | 'se-resize' | 'sw-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'zoom-in' | 'zoom-out';
|
|
21
21
|
export type ITransform = {
|
|
22
22
|
x: number;
|
|
@@ -120,9 +120,6 @@ export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
|
|
|
120
120
|
backgroundFit: boolean;
|
|
121
121
|
backgroundCornerRadius: number | number[];
|
|
122
122
|
backgroundOpacity: number;
|
|
123
|
-
autoAnimateTexture: boolean;
|
|
124
|
-
textureRatio: number;
|
|
125
|
-
textureOptions: any;
|
|
126
123
|
background: IBackgroundType | {
|
|
127
124
|
background: IBackgroundType;
|
|
128
125
|
dx?: number;
|
|
@@ -173,6 +170,7 @@ export type IGraphicAttribute = IDebugType & IGraphicStyle & ITransform & {
|
|
|
173
170
|
globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';
|
|
174
171
|
overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';
|
|
175
172
|
fillStrokeOrder: number;
|
|
173
|
+
keepStrokeScale: boolean;
|
|
176
174
|
};
|
|
177
175
|
export interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {
|
|
178
176
|
attribute: Partial<T>;
|
|
@@ -194,7 +192,6 @@ export type ISetAttributeContext = {
|
|
|
194
192
|
export type IGraphicAnimateParams = {
|
|
195
193
|
slience?: boolean;
|
|
196
194
|
id?: number | string;
|
|
197
|
-
timeline?: ITimeline;
|
|
198
195
|
onStart?: () => void;
|
|
199
196
|
onFrame?: (step: IStep, ratio: number) => void;
|
|
200
197
|
onEnd?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget, ITimeline } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph'\n | string;\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n id?: string;\n container: string | HTMLElement | null; // id或者dom\n visible?: boolean;\n pointerEvents?: boolean | string;\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n forceBoundsWidth: number | (() => number) | undefined;\n forceBoundsHeight: number | (() => number) | undefined;\n opacity: number;\n shadowGraphic?: IGraphic | undefined;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n // 纹理是否自动做动画\n autoAnimateTexture: boolean;\n // 如果做动画的话,这里代表ratio\n textureRatio: number;\n textureOptions: any;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html:\n | ({\n dom: string | HTMLElement; // dom字符串或者dom\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n react:\n | ({\n element: any; // react场景节点\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n // 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n fillStrokeOrder: number;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n timeline?: ITimeline;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\n\ntype IStrokeSeg = {\n start: number; // 百分比\n // end和length二选一\n end: number; // 百分比\n length: number; // 像素长度\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph';\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n x: number;\n y: number;\n z: number;\n dx: number;\n dy: number;\n dz: number;\n scrollX: number;\n scrollY: number;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n angle: number;\n alpha: number;\n beta: number;\n scaleCenter: [number | string, number | string];\n anchor: [number | string, number | string]; // 基于AABB的锚点位置,用于简单的定位某些path\n anchor3d: [number | string, number | string, number] | [number | string, number | string]; // 3d的锚点位置\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n fillOpacity: number;\n shadowBlur: number;\n shadowColor: string;\n shadowOffsetX: number;\n shadowOffsetY: number;\n fill: IFillType;\n};\n\nexport type ILayout = {\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n distance: number | string;\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n outerBorder: Partial<IBorderStyle>;\n innerBorder: Partial<IBorderStyle>;\n strokeOpacity: number;\n lineDash: number[];\n lineDashOffset: number;\n lineWidth: number;\n lineCap: CanvasLineCap;\n lineJoin: CanvasLineJoin;\n miterLimit: number;\n // 描边的boundsBuffer,用于控制bounds的buffer\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n // 连接,取零或者断开\n connectedType: 'connect' | 'zero' | 'none';\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n width: number; // 容器的宽度\n height: number; // 容器的高度\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n id?: string;\n container: string | HTMLElement | null; // id或者dom\n visible?: boolean;\n pointerEvents?: boolean | string;\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n forceBoundsWidth: number | (() => number) | undefined;\n forceBoundsHeight: number | (() => number) | undefined;\n opacity: number;\n shadowGraphic?: IGraphic | undefined;\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; // 填充模式(与具体图元有关)\n backgroundFit: boolean; // 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n backgroundCornerRadius: number | number[];\n backgroundOpacity: number;\n background:\n | IBackgroundType\n | {\n background: IBackgroundType;\n dx?: number;\n dy?: number;\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n texture: TextureType | string; // 纹理\n textureColor: string; // 纹理颜色\n textureSize: number; // 纹理大小\n texturePadding: number; // 纹理间隙\n blur: number;\n cursor: Cursor | null; // 鼠标样式\n renderStyle?: 'default' | 'rough' | any;\n // HTML的dom或者string\n html:\n | ({\n dom: string | HTMLElement; // dom字符串或者dom\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n react:\n | ({\n element: any; // react场景节点\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n // 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n // 包围盒的padding\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n globalZIndex: number;\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n // 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n // 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n fillStrokeOrder: number;\n // @since 0.20.15\n // 保持stroke的scale,默认为false,为true的话stroke显示的宽度会随着scale变化\n keepStrokeScale: boolean;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
|
package/es/interface/path.d.ts
CHANGED
|
@@ -36,9 +36,6 @@ export interface ICurve<T> {
|
|
|
36
36
|
getPointAt: (t: number) => IPointLike;
|
|
37
37
|
getAngleAt: (t: number) => number;
|
|
38
38
|
getLength: (direction?: IDirection) => number;
|
|
39
|
-
draw: (path: IPath2D, x: number, y: number, sx: number, sy: number, percent: number) => void;
|
|
40
|
-
getYAt: (x: number) => number;
|
|
41
|
-
includeX: (x: number) => boolean;
|
|
42
39
|
}
|
|
43
40
|
export interface ICubicBezierCurve extends ICurve<IPoint> {
|
|
44
41
|
type: CurveTypeEnum.CubicBezierCurve;
|
|
@@ -99,7 +96,5 @@ export interface ICustomPath2D extends ICurvePath<IPoint>, IPath2D, Releaseable
|
|
|
99
96
|
fromString: (pathStr: string, x?: number, y?: number, sX?: number, sY?: number) => ICustomPath2D;
|
|
100
97
|
fromCustomPath2D: (path: ICustomPath2D, x?: number, y?: number, sX?: number, sY?: number) => ICustomPath2D;
|
|
101
98
|
addCurve: (curve: ICurve<IPoint>) => void;
|
|
102
|
-
getYAt: (x: number) => number;
|
|
103
99
|
clear: () => void;
|
|
104
|
-
drawWithClipRange: (ctx: IPath2D, size: number, x: number, y: number, clipRange: number) => void;
|
|
105
100
|
}
|
package/es/interface/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/path.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK;IACL,OAAO;IACP,eAAe;IACf,WAAW;IACX,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,kBAAkB;IAClB,MAAM;CACP,CAAC","file":"path.js","sourcesContent":["import type { IAABBBounds, IPoint, IPointLike } from '@visactor/vutils';\nimport type { Releaseable, IDirection } from './common';\nimport type { CurveTypeEnum } from '../common/enums';\n\nexport const strCommandMap = [\n 'arc',\n 'arcTo',\n 'bezierCurveTo',\n 'closePath',\n 'ellipse',\n 'lineTo',\n 'moveTo',\n 'quadraticCurveTo',\n 'rect'\n];\n\nexport type CommandType = [\n number,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?\n];\n\nexport type CommandStrType = [\n string,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?\n];\n\nexport interface ICurve<T> {\n type: number;\n defined: boolean;\n originP1?: IPointLike;\n originP2?: IPointLike;\n readonly p0: T;\n readonly p1?: T;\n readonly p2?: T;\n readonly p3?: T;\n getPointAt: (t: number) => IPointLike;\n getAngleAt: (t: number) => number;\n getLength: (direction?: IDirection) => number;\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/path.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK;IACL,OAAO;IACP,eAAe;IACf,WAAW;IACX,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,kBAAkB;IAClB,MAAM;CACP,CAAC","file":"path.js","sourcesContent":["import type { IAABBBounds, IPoint, IPointLike } from '@visactor/vutils';\nimport type { Releaseable, IDirection } from './common';\nimport type { CurveTypeEnum } from '../common/enums';\n\nexport const strCommandMap = [\n 'arc',\n 'arcTo',\n 'bezierCurveTo',\n 'closePath',\n 'ellipse',\n 'lineTo',\n 'moveTo',\n 'quadraticCurveTo',\n 'rect'\n];\n\nexport type CommandType = [\n number,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?\n];\n\nexport type CommandStrType = [\n string,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?,\n (number | boolean)?\n];\n\nexport interface ICurve<T> {\n type: number;\n defined: boolean;\n originP1?: IPointLike;\n originP2?: IPointLike;\n readonly p0: T;\n readonly p1?: T;\n readonly p2?: T;\n readonly p3?: T;\n getPointAt: (t: number) => IPointLike;\n getAngleAt: (t: number) => number;\n getLength: (direction?: IDirection) => number;\n}\n\nexport interface ICubicBezierCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.CubicBezierCurve;\n // p0: IPoint;\n readonly p1: IPoint;\n readonly p2: IPoint;\n readonly p3: IPoint;\n}\n\nexport interface IQuadraticBezierCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.QuadraticBezierCurve;\n // p0: IPoint;\n readonly p1: IPoint;\n readonly p2: IPoint;\n}\n\nexport interface IArcCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.ArcCurve;\n // p0: IPoint;\n readonly p1: IPoint;\n radius: number;\n}\n\nexport interface ILineCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.LineCurve;\n // p0: IPoint;\n readonly p1: IPoint;\n}\n\nexport interface IEllipseCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.EllipseCurve;\n // p0: IPoint;\n radiusX: number;\n radiusY: number;\n rotation: number;\n startAngle: number;\n endAngle: number;\n anticlockwise?: boolean;\n}\n\nexport interface IMoveCurve extends ICurve<IPoint> {\n type: CurveTypeEnum.MoveCurve;\n // p0: IPoint;\n readonly p1: IPoint;\n}\n\nexport interface ICurvePath<T> {\n curves: ICurve<T>[];\n bounds?: IAABBBounds;\n getPointAt: (t: number) => IPointLike;\n getCurveLengths: () => number[];\n getLength: (direction?: IDirection) => number;\n getBounds?: () => IAABBBounds;\n}\n\nexport interface IPath2D {\n moveTo: (x: number, y: number, z?: number) => void;\n lineTo: (x: number, y: number, z?: number) => void;\n quadraticCurveTo: (aCPx: number, aCPy: number, aX: number, aY: number, z?: number) => void;\n bezierCurveTo: (\n aCP1x: number,\n aCP1y: number,\n aCP2x: number,\n aCP2y: number,\n aX: number,\n aY: number,\n z?: number\n ) => void;\n arcTo: (aX1: number, aY1: number, aX2: number, aY2: number, aRadius: number, z?: number) => void;\n ellipse: (\n aX: number,\n aY: number,\n xRadius: number,\n yRadius: number,\n aRotation: number,\n aStartAngle: number,\n aEndAngle: number,\n aClockwise: boolean\n ) => void;\n rect: (x: number, y: number, w: number, h: number, z?: number) => void;\n arc: (\n x: number,\n y: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n counterclockwise?: boolean,\n z?: number\n ) => void;\n closePath: () => void;\n}\n\n// 用户可以直接操作path2D\nexport interface ICustomPath2D extends ICurvePath<IPoint>, IPath2D, Releaseable {\n commandList: CommandType[];\n\n toString: () => string;\n transform: (x: number, y: number, sx: number, sy: number) => void;\n fromString: (pathStr: string, x?: number, y?: number, sX?: number, sY?: number) => ICustomPath2D;\n fromCustomPath2D: (path: ICustomPath2D, x?: number, y?: number, sX?: number, sY?: number) => ICustomPath2D;\n addCurve: (curve: ICurve<IPoint>) => void;\n clear: () => void;\n}\n"]}
|
package/es/interface/picker.d.ts
CHANGED
|
@@ -57,19 +57,6 @@ export interface IPickItemInterceptorContribution {
|
|
|
57
57
|
parentMatrix: IMatrix;
|
|
58
58
|
}) => PickResult | null;
|
|
59
59
|
}
|
|
60
|
-
export interface IPickServiceInterceptorContribution {
|
|
61
|
-
order: number;
|
|
62
|
-
beforePickItem?: (result: PickResult, pickerService: IPickerService, point: IPointLike, drawContext: {
|
|
63
|
-
in3dInterceptor?: boolean;
|
|
64
|
-
}, params?: {
|
|
65
|
-
parentMatrix: IMatrix;
|
|
66
|
-
}) => PickResult | null;
|
|
67
|
-
afterPickItem?: (result: PickResult, pickerService: IPickerService, point: IPointLike, drawContext: {
|
|
68
|
-
in3dInterceptor?: boolean;
|
|
69
|
-
}, params?: {
|
|
70
|
-
parentMatrix: IMatrix;
|
|
71
|
-
}) => PickResult | null;
|
|
72
|
-
}
|
|
73
60
|
export interface IBoundsPicker {
|
|
74
61
|
type: string;
|
|
75
62
|
numberType?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/picker.ts"],"names":[],"mappings":"","file":"picker.js","sourcesContent":["import type { IBounds, IMatrix, IPoint, IPointLike } from '@visactor/vutils';\nimport type { IGraphic } from './graphic';\nimport type { IContext2d } from './context';\nimport type { EnvType, IGlobal } from './global';\nimport type { IGroup } from './graphic/group';\nimport type { IDrawContribution } from './render';\n\ntype ISubPickEventParams =\n | boolean\n | {\n graphic?: any;\n group?: any;\n params: ISubPickEventParams;\n };\n\nexport type IPickEventParams =\n | {\n shadowTarget?: IGraphic;\n }\n | ISubPickEventParams;\n\nexport type PickResult = {\n graphic?: IGraphic | null;\n group?: IGroup | null;\n params?:\n | {\n shadowTarget?: IGraphic;\n }\n | ISubPickEventParams;\n};\n\nexport interface IGraphicPicker {\n type: string;\n numberType: number;\n\n contains: (graphic: IGraphic, point: IPointLike, params?: IPickParams) => boolean | any;\n}\n\nexport interface IPickParams {\n group?: boolean;\n graphic?: boolean;\n bounds?: IBounds;\n pickContext?: IContext2d;\n pickerService?: IPickerService;\n // 内部设置\n in3dInterceptor?: boolean;\n hack_pieFace?: string;\n}\n\nexport interface IPickerService {\n type: string;\n\n pickContext?: IContext2d;\n pickerMap: Map<number, IGraphicPicker>;\n configure: (global: IGlobal, env: EnvType) => void;\n pick: (group: IGraphic[], point: IPoint, params?: IPickParams) => PickResult;\n pickGroup: (group: IGroup, point: IPointLike, parentMatrix: IMatrix, params: IPickParams) => PickResult;\n pickItem: (\n graphic: IGraphic,\n point: IPointLike,\n parentMatrix: IMatrix | null,\n params?: IPickParams\n ) => PickResult | null;\n containsPoint: (graphic: IGraphic, point: IPointLike, params?: IPickParams) => boolean;\n drawContribution?: IDrawContribution;\n}\n\nexport interface IPickItemInterceptorContribution {\n order: number;\n // null代表没匹配到,boolean代表是否pick中\n beforePickItem?: (\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n drawContext: {\n in3dInterceptor?: boolean;\n },\n params?: {\n parentMatrix: IMatrix;\n }\n ) => PickResult | null;\n\n afterPickItem?: (\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n drawContext: {\n in3dInterceptor?: boolean;\n },\n params?: {\n parentMatrix: IMatrix;\n }\n ) => PickResult | null;\n // afterPickItem?: (\n // graphic: IGraphic,\n // pickerService: IPickerService,\n // ) => boolean;\n}\
|
|
1
|
+
{"version":3,"sources":["../src/interface/picker.ts"],"names":[],"mappings":"","file":"picker.js","sourcesContent":["import type { IBounds, IMatrix, IPoint, IPointLike } from '@visactor/vutils';\nimport type { IGraphic } from './graphic';\nimport type { IContext2d } from './context';\nimport type { EnvType, IGlobal } from './global';\nimport type { IGroup } from './graphic/group';\nimport type { IDrawContribution } from './render';\n\ntype ISubPickEventParams =\n | boolean\n | {\n graphic?: any;\n group?: any;\n params: ISubPickEventParams;\n };\n\nexport type IPickEventParams =\n | {\n shadowTarget?: IGraphic;\n }\n | ISubPickEventParams;\n\nexport type PickResult = {\n graphic?: IGraphic | null;\n group?: IGroup | null;\n params?:\n | {\n shadowTarget?: IGraphic;\n }\n | ISubPickEventParams;\n};\n\nexport interface IGraphicPicker {\n type: string;\n numberType: number;\n\n contains: (graphic: IGraphic, point: IPointLike, params?: IPickParams) => boolean | any;\n}\n\nexport interface IPickParams {\n group?: boolean;\n graphic?: boolean;\n bounds?: IBounds;\n pickContext?: IContext2d;\n pickerService?: IPickerService;\n // 内部设置\n in3dInterceptor?: boolean;\n hack_pieFace?: string;\n}\n\nexport interface IPickerService {\n type: string;\n\n pickContext?: IContext2d;\n pickerMap: Map<number, IGraphicPicker>;\n configure: (global: IGlobal, env: EnvType) => void;\n pick: (group: IGraphic[], point: IPoint, params?: IPickParams) => PickResult;\n pickGroup: (group: IGroup, point: IPointLike, parentMatrix: IMatrix, params: IPickParams) => PickResult;\n pickItem: (\n graphic: IGraphic,\n point: IPointLike,\n parentMatrix: IMatrix | null,\n params?: IPickParams\n ) => PickResult | null;\n containsPoint: (graphic: IGraphic, point: IPointLike, params?: IPickParams) => boolean;\n drawContribution?: IDrawContribution;\n}\n\nexport interface IPickItemInterceptorContribution {\n order: number;\n // null代表没匹配到,boolean代表是否pick中\n beforePickItem?: (\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n drawContext: {\n in3dInterceptor?: boolean;\n },\n params?: {\n parentMatrix: IMatrix;\n }\n ) => PickResult | null;\n\n afterPickItem?: (\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n drawContext: {\n in3dInterceptor?: boolean;\n },\n params?: {\n parentMatrix: IMatrix;\n }\n ) => PickResult | null;\n // afterPickItem?: (\n // graphic: IGraphic,\n // pickerService: IPickerService,\n // ) => boolean;\n}\n\nexport interface IBoundsPicker {\n type: string;\n numberType?: number;\n\n contains: (graphic: IGraphic, point: IPointLike, params?: IPickParams) => boolean;\n}\n"]}
|
package/es/interface/stage.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface IStageParams {
|
|
|
28
28
|
canvasControled: boolean;
|
|
29
29
|
title: string;
|
|
30
30
|
autoRender: boolean;
|
|
31
|
+
autoRefresh: boolean;
|
|
31
32
|
enableLayout: boolean;
|
|
32
33
|
disableDirtyBounds: boolean;
|
|
33
34
|
interactiveLayer: boolean;
|
|
@@ -54,6 +55,7 @@ export type EventConfig = {
|
|
|
54
55
|
export type IOptimizeType = {
|
|
55
56
|
skipRenderWithOutRange?: boolean;
|
|
56
57
|
disableCheckGraphicWidthOutRange?: boolean;
|
|
58
|
+
tickRenderMode?: 'effect' | 'performance';
|
|
57
59
|
};
|
|
58
60
|
export interface IOption3D {
|
|
59
61
|
enableView3dTransform?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport type IStageCreateContext = {\n appName?: 'vchart' | 'vgrammar' | 'vtable' | string;\n};\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n\n context?: IStageCreateContext;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n getPickerService: () => IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: (sk?: number) => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => { x: number; y: number };\n pauseTriggerEvent: () => void;\n resumeTriggerEvent: () => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/stage.ts"],"names":[],"mappings":"","file":"stage.js","sourcesContent":["import type { INode } from './node-tree';\nimport type { ILayer, LayerMode } from './layer';\nimport type { IColor } from './color';\nimport type { IAABBBounds, IBounds, IBoundsLike, IMatrix } from '@visactor/vutils';\nimport type { ICamera } from './camera';\nimport type { vec3 } from './matrix';\nimport type { IDirectionLight } from './light';\nimport type { ISyncHook } from './sync-hook';\nimport type { IDrawContext, IRenderService } from './render';\nimport type { ITicker, ITimeline } from './animate';\nimport type { IPickerService, PickResult } from './picker';\nimport type { IPlugin, IPluginService } from './plugin';\nimport type { IWindow } from './window';\nimport type { ILayerService } from './core';\nimport type { IFullThemeSpec } from './graphic/theme';\n\nexport type IExportType = 'canvas' | 'imageData';\n\nexport type IStageCreateContext = {\n appName?: 'vchart' | 'vgrammar' | 'vtable' | string;\n};\nexport interface IStageParams {\n // x: number;\n // y: number;\n // // 视口的宽高\n // viewWidth: number;\n // viewHeight: number;\n\n // 视口的宽高\n viewBox: IBoundsLike;\n // 总的宽高\n width: number;\n height: number;\n dpr: number;\n // stage的背景\n background: string | IColor;\n // 外部的canvas\n canvas: string | HTMLCanvasElement;\n // canvas的container容器,如果不传入canvas,那就会在容器中创建canvas\n container: string | HTMLElement;\n // 是否是受控制的canvas,如果不是的话,不会进行resize等操作,也不会修改canvas的样式\n canvasControled: boolean;\n title: string;\n // 是否开启自动渲染\n autoRender: boolean;\n // 是否开启自动刷新\n autoRefresh: boolean;\n // 是否开启布局支持\n enableLayout: boolean;\n // 是否关闭脏矩形检测\n disableDirtyBounds: boolean;\n // 是否支持interactiveLayer,默认为true\n interactiveLayer: boolean;\n // 是否支持HTML属性\n enableHtmlAttribute: string | boolean | HTMLElement;\n // 是否支持react-dom(传入ReactDOM)\n ReactDOM: any;\n // 是否支持滚动条\n enableScroll: boolean;\n poptip: boolean;\n // 绘制之前的钩子函数\n beforeRender: (stage: IStage) => void;\n // 绘制之后的钩子函数\n afterRender: (stage: IStage) => void;\n renderStyle?: string;\n ticker?: ITicker;\n pluginList?: string[];\n // 优化配置\n optimize?: IOptimizeType;\n /**\n * 事件系统相关配置\n */\n event?: EventConfig;\n\n /**\n * @since 0.17.15\n * 是否支持touch事件,不支持就不监听touch事件\n */\n supportsTouchEvents?: boolean;\n\n /**\n * @since 0.17.15\n * 是否支持pointer事件,不支持就监听mouse事件\n */\n supportsPointerEvents?: boolean;\n\n context?: IStageCreateContext;\n}\n\nexport type EventConfig = {\n /** 是否自动阻止事件 */\n autoPreventDefault?: boolean;\n /**\n * 多次点击之间的最大时间,默认为 200 ms\n * @default 200\n */\n clickInterval?: number;\n [key: string]: any;\n};\n\nexport type IOptimizeType = {\n // 视口不在可视区,跳过渲染,默认为true\n skipRenderWithOutRange?: boolean;\n // 跳过图元在区间外的判断\n // 不存在dirtyBounds的时候,根据该配置判断是否关闭图元的超出边界判定\n // 如果有dirtyBounds那么该配置不生效\n disableCheckGraphicWidthOutRange?: boolean;\n // tick渲染模式,effect会在tick之后立刻执行render,保证动画效果正常。performance模式中tick和render均是RAF,属性可能会被篡改\n tickRenderMode?: 'effect' | 'performance';\n};\n\nexport interface IOption3D {\n enableView3dTransform?: boolean; // 是否开启view3d自动旋转\n alpha?: number; // x轴的转角\n beta?: number; // y轴的转角\n gama?: number; // z轴的转角\n center?: { x?: number; y?: number; z?: number; dx?: number; dy?: number; dz?: number }; // 中心位置\n fieldRatio?: number; // 透视的视域缩放比例\n fieldDepth?: number;\n light?: {\n dir?: vec3;\n color?: string;\n ambient?: number;\n };\n // 配置相机后,alpha、beta、gamma配置会失效\n camera?: any; // 相机配置\n}\n\n// TODO 命名方式\nexport interface IStage extends INode {\n stage?: IStage;\n parent: IStage | null;\n // rootNode: IStage;\n x: number;\n y: number;\n\n params: Partial<IStageParams>;\n\n window: IWindow;\n\n width: number;\n height: number;\n viewWidth: number;\n viewHeight: number;\n defaultLayer: ILayer;\n dirtyBounds: IBounds | null;\n\n autoRender: boolean;\n renderCount: number;\n\n hooks: {\n beforeRender: ISyncHook<[IStage]>;\n afterRender: ISyncHook<[IStage]>;\n };\n\n option3d?: IOption3D;\n\n set3dOptions: (options: IOption3D) => void;\n light?: IDirectionLight;\n camera?: ICamera;\n\n dpr: number;\n\n viewBox: IBoundsLike;\n background: string | IColor;\n ticker: ITicker;\n increaseAutoRender: boolean;\n readonly renderService: IRenderService;\n getPickerService: () => IPickerService;\n readonly pluginService: IPluginService;\n readonly layerService: ILayerService;\n // 如果传入CanvasId,如果存在相同Id,说明这两个图层使用相同的Canvas绘制\n // 但需要注意的是依然是两个图层(用于解决Table嵌入ChartSpace不影响Table的绘制)\n createLayer: (canvasId?: string, layerMode?: LayerMode) => ILayer;\n getLayer: (name: string) => ILayer;\n sortLayer: (cb: (layer1: ILayer, layer2: ILayer) => number) => void;\n removeLayer: (layerId: number) => ILayer | false;\n\n getTimeline: () => ITimeline;\n\n render: (layers?: ILayer[], params?: Partial<IDrawContext>) => void;\n /**\n * 下一帧渲染\n * @param layers 渲染的图层\n * @param force 是否强行下一帧渲染,不采取优化方案\n * @returns\n */\n renderNextFrame: (layers?: ILayer[], force?: boolean) => void;\n tryInitInteractiveLayer: () => void;\n\n // 画布操作\n resize: (w: number, h: number, rerender?: boolean) => void;\n resizeWindow: (w: number, h: number, rerender?: boolean) => void;\n resizeView: (w: number, h: number, rerender?: boolean) => void;\n setViewBox:\n | ((viewBox: IBoundsLike, rerender: boolean) => void)\n | ((x: number, y: number, w: number, h: number, rerender: boolean) => void)\n | ((x: number | IBoundsLike, y: number | boolean, w?: number, h?: number, rerender?: boolean) => void);\n setDpr: (dpr: number, rerender?: boolean) => void;\n setOrigin: (x: number, y: number) => void;\n export: (type: IExportType) => HTMLCanvasElement | ImageData;\n pick: (x: number, y: number) => PickResult | false;\n\n // 动画相关\n startAnimate: (t: number) => void;\n setToFrame: (t: number) => void;\n dirty: (b: IBounds, matrix?: IMatrix) => void;\n // 考虑操作回放\n\n renderTo: (window: IWindow, params: { x: number; y: number; width: number; height: number }) => void;\n\n renderToNewWindow: (fullImage?: boolean) => IWindow;\n\n toCanvas: (fullImage?: boolean, viewBox?: IAABBBounds) => HTMLCanvasElement | null;\n\n setBeforeRender: (cb: (stage: IStage) => void) => void;\n\n setAfterRender: (cb: (stage: IStage) => void) => void;\n\n afterNextRender: (cb: (stage: IStage) => void) => void;\n enableAutoRender: () => void;\n disableAutoRender: () => void;\n enableIncrementalAutoRender: () => void;\n disableIncrementalAutoRender: () => void;\n enableDirtyBounds: () => void;\n disableDirtyBounds: () => void;\n enableView3dTransform: () => void;\n disableView3dTranform: () => void;\n getPluginsByName: (name: string) => IPlugin[];\n clearViewBox: (color?: string) => void;\n release: () => void;\n setStage: (stage?: IStage) => void;\n\n pauseRender: (sk?: number) => void;\n resumeRender: () => void;\n\n setCursor: (mode?: string) => void;\n\n getTheme: () => IFullThemeSpec;\n eventPointTransform: (e: PointerEvent | WheelEvent | TouchEvent) => { x: number; y: number };\n pauseTriggerEvent: () => void;\n resumeTriggerEvent: () => void;\n}\n\nexport declare function combineStage(srages: IStage[], params: { canvas: string | HTMLCanvasElement }): IStage;\n"]}
|
package/es/interface/text.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { IContribution } from './contribution';
|
|
2
2
|
import type { IGraphicUtil } from './core';
|
|
3
|
+
import type { MeasureModeEnum } from './graphic/text';
|
|
3
4
|
export interface TextOptionsType {
|
|
4
5
|
fontSize?: number;
|
|
5
6
|
fontWeight?: string | number;
|
|
6
7
|
fontFamily?: string;
|
|
7
8
|
fontStyle?: string;
|
|
8
9
|
fontVariant?: string;
|
|
10
|
+
lineHeight?: number;
|
|
9
11
|
textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';
|
|
10
12
|
textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';
|
|
11
13
|
}
|
|
@@ -13,9 +15,15 @@ export interface ITextMeasure extends IContribution<IGraphicUtil> {
|
|
|
13
15
|
measureTextWidth: (text: string, options: TextOptionsType) => number;
|
|
14
16
|
measureTextPixelHeight: (text: string, options: TextOptionsType) => number;
|
|
15
17
|
measureTextBoundHieght: (text: string, options: TextOptionsType) => number;
|
|
18
|
+
measureTextPixelADscentAndWidth: (text: string, options: TextOptionsType, mode: MeasureModeEnum) => {
|
|
19
|
+
width: number;
|
|
20
|
+
ascent: number;
|
|
21
|
+
descent: number;
|
|
22
|
+
};
|
|
16
23
|
clipText: (text: string, options: TextOptionsType, width: number, wordBreak: boolean, keepAllBreak?: boolean) => {
|
|
17
24
|
str: string;
|
|
18
25
|
width: number;
|
|
26
|
+
wordBreaked?: number;
|
|
19
27
|
};
|
|
20
28
|
clipTextVertical: (verticalList: {
|
|
21
29
|
text: string;
|
|
@@ -29,7 +37,7 @@ export interface ITextMeasure extends IContribution<IGraphicUtil> {
|
|
|
29
37
|
}[];
|
|
30
38
|
width: number;
|
|
31
39
|
};
|
|
32
|
-
clipTextWithSuffix: (text: string, options: TextOptionsType, width: number, suffix: string, wordBreak: boolean, position: 'start' | 'end' | 'middle') => {
|
|
40
|
+
clipTextWithSuffix: (text: string, options: TextOptionsType, width: number, suffix: string | boolean, wordBreak: boolean, position: 'start' | 'end' | 'middle', forceSuffix?: boolean) => {
|
|
33
41
|
str: string;
|
|
34
42
|
width: number;
|
|
35
43
|
};
|
package/es/interface/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';\n textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n clipText: (\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ) => { str: string; width: number };\n clipTextVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle'\n ) => { str: string; width: number };\n clipTextWithSuffixVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n suffixPosition: 'start' | 'end' | 'middle'\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IContribution } from './contribution';\nimport type { IGraphicUtil } from './core';\nimport type { MeasureModeEnum } from './graphic/text';\n\nexport interface TextOptionsType {\n fontSize?: number;\n fontWeight?: string | number;\n fontFamily?: string;\n fontStyle?: string;\n fontVariant?: string;\n lineHeight?: number;\n textBaseline?: 'alphabetic' | 'top' | 'middle' | 'bottom';\n textAlign?: 'left' | 'center' | 'right' | 'start' | 'end';\n}\n\nexport interface ITextMeasure extends IContribution<IGraphicUtil> {\n measureTextWidth: (text: string, options: TextOptionsType) => number;\n measureTextPixelHeight: (text: string, options: TextOptionsType) => number;\n measureTextBoundHieght: (text: string, options: TextOptionsType) => number;\n measureTextPixelADscentAndWidth: (\n text: string,\n options: TextOptionsType,\n mode: MeasureModeEnum\n ) => { width: number; ascent: number; descent: number };\n clipText: (\n text: string,\n options: TextOptionsType,\n width: number,\n wordBreak: boolean,\n keepAllBreak?: boolean\n ) => { str: string; width: number; wordBreaked?: number };\n clipTextVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n wordBreak: boolean\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n clipTextWithSuffix: (\n text: string,\n options: TextOptionsType,\n width: number,\n suffix: string | boolean,\n wordBreak: boolean,\n position: 'start' | 'end' | 'middle',\n forceSuffix?: boolean\n ) => { str: string; width: number };\n clipTextWithSuffixVertical: (\n verticalList: { text: string; width?: number; direction: number }[],\n options: TextOptionsType,\n width: number,\n suffix: string,\n wordBreak: boolean,\n suffixPosition: 'start' | 'end' | 'middle'\n ) => { verticalList: { text: string; width?: number; direction: number }[]; width: number };\n measureText: (text: string, options: TextOptionsType) => { width: number };\n}\n"]}
|
package/es/picker/constants.d.ts
CHANGED
|
@@ -2,5 +2,3 @@ export declare const GraphicPicker: unique symbol;
|
|
|
2
2
|
export declare const PickerService: unique symbol;
|
|
3
3
|
export declare const BoundsPicker: unique symbol;
|
|
4
4
|
export declare const GlobalPickerService: unique symbol;
|
|
5
|
-
export declare const PickItemInterceptor: unique symbol;
|
|
6
|
-
export declare const PickServiceInterceptor: unique symbol;
|
package/es/picker/constants.js
CHANGED
|
@@ -5,8 +5,4 @@ export const PickerService = Symbol.for("PickerService");
|
|
|
5
5
|
export const BoundsPicker = Symbol.for("BoundsPicker");
|
|
6
6
|
|
|
7
7
|
export const GlobalPickerService = Symbol.for("GlobalPickerService");
|
|
8
|
-
|
|
9
|
-
export const PickItemInterceptor = Symbol.for("PickItemInterceptor");
|
|
10
|
-
|
|
11
|
-
export const PickServiceInterceptor = Symbol.for("PickServiceInterceptor");
|
|
12
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC
|
|
1
|
+
{"version":3,"sources":["../src/picker/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC","file":"constants.js","sourcesContent":["export const GraphicPicker = Symbol.for('GraphicPicker');\nexport const PickerService = Symbol.for('PickerService');\n\nexport const BoundsPicker = Symbol.for('BoundsPicker');\nexport const GlobalPickerService = Symbol.for('GlobalPickerService');\n"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { IMatrix, IPointLike } from '@visactor/vutils';
|
|
2
|
-
import type { IContext2d, IGraphic, IPickItemInterceptorContribution, IPickParams,
|
|
3
|
-
export declare
|
|
4
|
-
order: number;
|
|
5
|
-
afterPickItem(result: PickResult, pickerService: IPickerService, point: IPointLike, pickParams: IPickParams, params?: {
|
|
6
|
-
parentMatrix: IMatrix;
|
|
7
|
-
}): null | PickResult;
|
|
8
|
-
}
|
|
2
|
+
import type { IContext2d, IGraphic, IPickItemInterceptorContribution, IPickParams, IPickerService, PickResult } from '../interface';
|
|
3
|
+
export declare const PickItemInterceptor: unique symbol;
|
|
9
4
|
export declare class ShadowRootPickItemInterceptorContribution implements IPickItemInterceptorContribution {
|
|
10
5
|
order: number;
|
|
11
6
|
afterPickItem(graphic: IGraphic, pickerService: IPickerService, point: IPointLike, pickParams: IPickParams, params?: {
|
|
@@ -14,25 +14,7 @@ import { draw3dItem } from "../common/3d-interceptor";
|
|
|
14
14
|
|
|
15
15
|
import { getTheme } from "../graphic";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
constructor() {
|
|
19
|
-
this.order = 1;
|
|
20
|
-
}
|
|
21
|
-
afterPickItem(result, pickerService, point, pickParams, params) {
|
|
22
|
-
if (result.graphic) {
|
|
23
|
-
let g = result.graphic;
|
|
24
|
-
for (;g.parent; ) g = g.parent;
|
|
25
|
-
g.shadowHost && (result.params = {
|
|
26
|
-
shadowTarget: result.graphic
|
|
27
|
-
}, result.graphic = g.shadowHost);
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
ShadowPickServiceInterceptorContribution = __decorate([ injectable() ], ShadowPickServiceInterceptorContribution);
|
|
34
|
-
|
|
35
|
-
export { ShadowPickServiceInterceptorContribution };
|
|
17
|
+
export const PickItemInterceptor = Symbol.for("PickItemInterceptor");
|
|
36
18
|
|
|
37
19
|
let ShadowRootPickItemInterceptorContribution = class {
|
|
38
20
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/pick-interceptor.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAWtD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG/B,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IAA9C;QACL,UAAK,GAAW,CAAC,CAAC;IAwBpB,CAAC;IAvBC,aAAa,CACX,MAAkB,EAClB,aAA6B,EAC7B,KAAiB,EACjB,UAAuB,EACvB,MAEC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;YACvB,OAAO,CAAC,CAAC,MAAM,EAAE;gBACf,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;aACd;YACD,IAAI,CAAC,CAAC,UAAU,EAAE;gBAChB,MAAM,CAAC,MAAM,GAAG;oBACd,YAAY,EAAE,MAAM,CAAC,OAAO;iBAC7B,CAAC;gBACF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,UAAU,CAAC;aAC/B;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AAzBY,wCAAwC;IADpD,UAAU,EAAE;GACA,wCAAwC,CAyBpD;SAzBY,wCAAwC;AA+B9C,IAAM,yCAAyC,GAA/C,MAAM,yCAAyC;IAA/C;QACL,UAAK,GAAW,CAAC,CAAC;IAiFpB,CAAC;IAhFC,aAAa,CACX,OAAiB,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GAAG,UAAU,CACvB,OAAO,EACP,OAAO,EACP,GAAG,EAAE;gBACH,OAAO,aAAa,CAAC,SAAS,CAAC,OAAiB,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YAC5F,CAAC,EACD,UAAU,CACX,CAAC;YAEF,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAEtB,UAAU,CAAC,eAAe,GAAG,KAAK,CAAC;YACnC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF,CAAA;AArDY,2BAA2B;IADvC,UAAU,EAAE;GACA,2BAA2B,CAqDvC;SArDY,2BAA2B","file":"pick-interceptor.js","sourcesContent":["import type { IMatrix, IPointLike } from '@visactor/vutils';\nimport { Point } from '@visactor/vutils';\nimport { injectable } from '../common/inversify-lite';\nimport type {\n IContext2d,\n IGraphic,\n IGroup,\n IPickItemInterceptorContribution,\n IPickParams,\n IPickServiceInterceptorContribution,\n IPickerService,\n PickResult\n} from '../interface';\nimport { matrixAllocate } from '../allocator/matrix-allocate';\nimport { draw3dItem } from '../common/3d-interceptor';\nimport { getTheme } from '../graphic';\n\n@injectable()\nexport class ShadowPickServiceInterceptorContribution implements IPickServiceInterceptorContribution {\n order: number = 1;\n afterPickItem(\n result: PickResult,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n if (result.graphic) {\n let g = result.graphic;\n while (g.parent) {\n g = g.parent;\n }\n if (g.shadowHost) {\n result.params = {\n shadowTarget: result.graphic\n };\n result.graphic = g.shadowHost;\n }\n }\n return result;\n }\n}\n\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n@injectable()\nexport class ShadowRootPickItemInterceptorContribution implements IPickItemInterceptorContribution {\n order: number = 1;\n afterPickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n return this._pickItem(graphic, pickerService, point, pickParams, params);\n }\n return null;\n }\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n if (graphic.attribute.shadowRootIdx < 0) {\n return this._pickItem(graphic, pickerService, point, pickParams, params);\n }\n return null;\n }\n\n protected _pickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): PickResult | null {\n if (!graphic.shadowRoot) {\n return null;\n }\n const { parentMatrix } = params || {};\n if (!parentMatrix) {\n return null;\n }\n\n const context = pickerService.pickContext;\n context.highPerformanceSave();\n\n const theme = (getTheme(graphic) as any)?.[graphic.type];\n const { shadowPickMode = theme?.shadowPickMode } = graphic.attribute;\n const g = graphic.shadowRoot;\n const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);\n const newPoint = new Point(\n currentGroupMatrix.a * point.x + currentGroupMatrix.c * point.y + currentGroupMatrix.e,\n currentGroupMatrix.b * point.x + currentGroupMatrix.d * point.y + currentGroupMatrix.f\n );\n // const transMatrix = graphic.transMatrix;\n // currentGroupMatrix.multiply(\n // transMatrix.a,\n // transMatrix.b,\n // transMatrix.c,\n // transMatrix.d,\n // transMatrix.e,\n // transMatrix.f\n // );\n\n // currentGroupMatrix.transformPoint(newPoint, newPoint);\n const result = pickerService.pickGroup(g, newPoint, currentGroupMatrix, pickParams);\n\n context.highPerformanceRestore();\n\n // 影子节点pick到group也算pick到graphic\n if (!result.graphic && result.group && shadowPickMode === 'full') {\n result.graphic = result.group;\n }\n\n return result;\n }\n}\n\n@injectable()\nexport class InteractivePickItemInterceptorContribution implements IPickItemInterceptorContribution {\n order: number = 1;\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n const originGraphic = graphic.baseGraphic;\n if (originGraphic && originGraphic.parent) {\n const newPoint = new Point(point.x, point.y);\n const context = pickerService.pickContext;\n context.highPerformanceSave();\n const parentMatrix = originGraphic.parent.globalTransMatrix;\n parentMatrix.transformPoint(newPoint, newPoint);\n\n const result = originGraphic.isContainer\n ? pickerService.pickGroup(originGraphic, newPoint.clone(), parentMatrix, pickParams)\n : pickerService.pickItem(originGraphic, newPoint.clone(), parentMatrix, pickParams);\n context.highPerformanceRestore();\n return result;\n }\n return null;\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n@injectable()\nexport class Canvas3DPickItemInterceptor implements IPickItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ) {\n if (!graphic.in3dMode || pickParams.in3dInterceptor) {\n return null;\n }\n\n const context = pickerService.pickContext;\n const stage = graphic.stage;\n if (!(context && stage)) {\n return null;\n }\n pickParams.in3dInterceptor = true;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n const result = draw3dItem(\n context,\n graphic,\n () => {\n return pickerService.pickGroup(graphic as IGroup, point, params.parentMatrix, pickParams);\n },\n pickParams\n );\n\n context.camera = null;\n\n pickParams.in3dInterceptor = false;\n context.restore();\n return result;\n }\n context.restore();\n return null;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"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,CAAC,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC,eAAe,EAAE;YACnD,OAAO,IAAI,CAAC;SACb;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC;QAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC;SACb;QACD,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC;QAGlC,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAG9B,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,MAAM,MAAM,GAAG,UAAU,CACvB,OAAO,EACP,OAAO,EACP,GAAG,EAAE;gBACH,OAAO,aAAa,CAAC,SAAS,CAAC,OAAiB,EAAE,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YAC5F,CAAC,EACD,UAAU,CACX,CAAC;YAEF,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAEtB,UAAU,CAAC,eAAe,GAAG,KAAK,CAAC;YACnC,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF,CAAA;AArDY,2BAA2B;IADvC,UAAU,EAAE;GACA,2BAA2B,CAqDvC;SArDY,2BAA2B","file":"pick-interceptor.js","sourcesContent":["import type { IMatrix, IPointLike } from '@visactor/vutils';\nimport { Point } from '@visactor/vutils';\nimport { injectable } from '../common/inversify-lite';\nimport type {\n IContext2d,\n IGraphic,\n IGroup,\n IPickItemInterceptorContribution,\n IPickParams,\n IPickerService,\n PickResult\n} from '../interface';\nimport { matrixAllocate } from '../allocator/matrix-allocate';\nimport { draw3dItem } from '../common/3d-interceptor';\nimport { getTheme } from '../graphic';\n\n// 拦截器\nexport const PickItemInterceptor = Symbol.for('PickItemInterceptor');\n\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n@injectable()\nexport class ShadowRootPickItemInterceptorContribution implements IPickItemInterceptorContribution {\n order: number = 1;\n afterPickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n return this._pickItem(graphic, pickerService, point, pickParams, params);\n }\n return null;\n }\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n if (graphic.attribute.shadowRootIdx < 0) {\n return this._pickItem(graphic, pickerService, point, pickParams, params);\n }\n return null;\n }\n\n protected _pickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): PickResult | null {\n if (!graphic.shadowRoot) {\n return null;\n }\n const { parentMatrix } = params || {};\n if (!parentMatrix) {\n return null;\n }\n\n const context = pickerService.pickContext;\n context.highPerformanceSave();\n\n const theme = (getTheme(graphic) as any)?.[graphic.type];\n const { shadowPickMode = theme?.shadowPickMode } = graphic.attribute;\n const g = graphic.shadowRoot;\n const currentGroupMatrix = matrixAllocate.allocateByObj(parentMatrix);\n const newPoint = new Point(\n currentGroupMatrix.a * point.x + currentGroupMatrix.c * point.y + currentGroupMatrix.e,\n currentGroupMatrix.b * point.x + currentGroupMatrix.d * point.y + currentGroupMatrix.f\n );\n // const transMatrix = graphic.transMatrix;\n // currentGroupMatrix.multiply(\n // transMatrix.a,\n // transMatrix.b,\n // transMatrix.c,\n // transMatrix.d,\n // transMatrix.e,\n // transMatrix.f\n // );\n\n // currentGroupMatrix.transformPoint(newPoint, newPoint);\n const result = pickerService.pickGroup(g, newPoint, currentGroupMatrix, pickParams);\n\n context.highPerformanceRestore();\n\n // 影子节点pick到group也算pick到graphic\n if (!result.graphic && result.group && shadowPickMode === 'full') {\n result.graphic = result.group;\n }\n\n return result;\n }\n}\n\n@injectable()\nexport class InteractivePickItemInterceptorContribution implements IPickItemInterceptorContribution {\n order: number = 1;\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ): null | PickResult {\n const originGraphic = graphic.baseGraphic;\n if (originGraphic && originGraphic.parent) {\n const newPoint = new Point(point.x, point.y);\n const context = pickerService.pickContext;\n context.highPerformanceSave();\n const parentMatrix = originGraphic.parent.globalTransMatrix;\n parentMatrix.transformPoint(newPoint, newPoint);\n\n const result = originGraphic.isContainer\n ? pickerService.pickGroup(originGraphic, newPoint.clone(), parentMatrix, pickParams)\n : pickerService.pickItem(originGraphic, newPoint.clone(), parentMatrix, pickParams);\n context.highPerformanceRestore();\n return result;\n }\n return null;\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n@injectable()\nexport class Canvas3DPickItemInterceptor implements IPickItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforePickItem(\n graphic: IGraphic,\n pickerService: IPickerService,\n point: IPointLike,\n pickParams: IPickParams,\n params?: {\n parentMatrix: IMatrix;\n }\n ) {\n if (!graphic.in3dMode || pickParams.in3dInterceptor) {\n return null;\n }\n\n const context = pickerService.pickContext;\n const stage = graphic.stage;\n if (!(context && stage)) {\n return null;\n }\n pickParams.in3dInterceptor = true;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n const result = draw3dItem(\n context,\n graphic,\n () => {\n return pickerService.pickGroup(graphic as IGroup, point, params.parentMatrix, pickParams);\n },\n pickParams\n );\n\n context.camera = null;\n\n pickParams.in3dInterceptor = false;\n context.restore();\n return result;\n }\n context.restore();\n return null;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContainerModule } from "../common/inversify-lite";
|
|
2
2
|
|
|
3
|
-
import { PickerService, GlobalPickerService
|
|
3
|
+
import { PickerService, GlobalPickerService } from "./constants";
|
|
4
4
|
|
|
5
|
-
import { Canvas3DPickItemInterceptor, InteractivePickItemInterceptorContribution,
|
|
5
|
+
import { Canvas3DPickItemInterceptor, InteractivePickItemInterceptorContribution, PickItemInterceptor, ShadowRootPickItemInterceptorContribution } from "./pick-interceptor";
|
|
6
6
|
|
|
7
7
|
import { bindContributionProvider } from "../common/contribution-provider";
|
|
8
8
|
|
|
@@ -11,8 +11,6 @@ export default new ContainerModule(((bind, unbind, isBound) => {
|
|
|
11
11
|
bind(Canvas3DPickItemInterceptor).toSelf().inSingletonScope(), bind(PickItemInterceptor).toService(Canvas3DPickItemInterceptor),
|
|
12
12
|
bind(ShadowRootPickItemInterceptorContribution).toSelf().inSingletonScope(), bind(PickItemInterceptor).toService(ShadowRootPickItemInterceptorContribution),
|
|
13
13
|
bind(InteractivePickItemInterceptorContribution).toSelf().inSingletonScope(), bind(PickItemInterceptor).toService(InteractivePickItemInterceptorContribution),
|
|
14
|
-
bindContributionProvider(bind, PickItemInterceptor)
|
|
15
|
-
bind(PickServiceInterceptor).toService(ShadowPickServiceInterceptorContribution),
|
|
16
|
-
bindContributionProvider(bind, PickServiceInterceptor);
|
|
14
|
+
bindContributionProvider(bind, PickItemInterceptor);
|
|
17
15
|
}));
|
|
18
16
|
//# sourceMappingURL=pick-modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/picker/pick-modules.ts"],"names":[],"mappings":"A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["import { ContainerModule } from '../common/inversify-lite';\nimport { PickerService, GlobalPickerService } from './constants';\nimport { DefaultGlobalPickerService } from './global-picker-service';\n// import { DefaultCanvasPickerService } from './canvas-picker-service';\n// import { DefaultMathPickerService } from './math-picker-service';\nimport {\n Canvas3DPickItemInterceptor,\n InteractivePickItemInterceptorContribution,\n PickItemInterceptor,\n ShadowRootPickItemInterceptorContribution\n} from './pick-interceptor';\nimport { bindContributionProvider } from '../common/contribution-provider';\n\nexport default new ContainerModule((bind, unbind, isBound) => {\n if (!isBound(PickerService)) {\n bind(GlobalPickerService).toSelf();\n bind(PickerService).toService(GlobalPickerService);\n }\n // bind(PickerService).toService(GlobalPickerService);\n\n // bind(DefaultGlobalPickerService).toSelf().inSingletonScope();\n // bind(GlobalPickerService).toService(DefaultGlobalPickerService);\n\n // interceptor\n bind(Canvas3DPickItemInterceptor).toSelf().inSingletonScope();\n bind(PickItemInterceptor).toService(Canvas3DPickItemInterceptor);\n\n // shadow root\n bind(ShadowRootPickItemInterceptorContribution).toSelf().inSingletonScope();\n bind(PickItemInterceptor).toService(ShadowRootPickItemInterceptorContribution);\n\n // interactive\n bind(InteractivePickItemInterceptorContribution).toSelf().inSingletonScope();\n bind(PickItemInterceptor).toService(InteractivePickItemInterceptorContribution);\n bindContributionProvider(bind, PickItemInterceptor);\n});\n"]}
|