@visactor/vrender-core 0.20.0-alpha.2 → 0.20.0-alpha.4

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.
@@ -44,6 +44,7 @@ export declare class Path extends Graphic<IPathGraphicAttribute> implements IPat
44
44
  getParsedPathShape(): CustomPath2D;
45
45
  getGraphicTheme(): Required<IPathGraphicAttribute>;
46
46
  protected updateAABBBounds(attribute: IPathGraphicAttribute, pathTheme: Required<IPathGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
47
+ protected doUpdateAABBBounds(full?: boolean): import("@visactor/vutils").IBounds;
47
48
  protected doUpdatePathShape(): void;
48
49
  protected needUpdateTags(keys: string[]): boolean;
49
50
  protected needUpdateTag(key: string): boolean;
@@ -43,6 +43,9 @@ class Path extends graphic_1.Graphic {
43
43
  return application_1.application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this),
44
44
  aabbBounds;
45
45
  }
46
+ doUpdateAABBBounds(full) {
47
+ return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
48
+ }
46
49
  doUpdatePathShape() {
47
50
  const attribute = this.attribute;
48
51
  (0, vutils_1.isString)(attribute.path, !0) ? this.cache = (new custom_path2d_1.CustomPath2D).fromString(attribute.path) : attribute.customPath && (this.cache = new custom_path2d_1.CustomPath2D,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/path.ts"],"names":[],"mappings":";;;AACA,6CAAmD;AACnD,uCAAiF;AAEjF,2DAAuD;AACvD,mCAAmC;AACnC,gDAA6C;AAC7C,2CAA+C;AAC/C,2FAA8F;AAE9F,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,gCAAsB,CAAC,CAAC;AAE9E,MAAa,IAAK,SAAQ,iBAA8B;IAUtD,YAAY,MAA6B;QACvC,KAAK,CAAC,MAAM,CAAC,CAAC;QAVhB,SAAI,GAAW,MAAM,CAAC;QAW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KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IACzD,CAAC;IACS,aAAa,CAAC,GAAW;QACjC,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IACvD,CAAC;IAED,YAAY;QACV,MAAM,CAAC,GAAG,CAAC,CAAC;QACZ,MAAM,CAAC,GAAG,CAAC,CAAC;QAEZ,OAAO,IAAI,4BAAY,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK;QACH,OAAO,IAAI,IAAI,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;IACzC,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;;AAzGH,oBA0GC;AAtGQ,wBAAmB,mBACxB,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,IACV,6BAAmB,EACtB;AAoGJ,SAAgB,UAAU,CAAC,UAAiC;IAC1D,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAFD,gCAEC","file":"path.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isString, isNil } from '@visactor/vutils';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type { ICustomPath2D, IPath, IPathGraphicAttribute } from '../interface';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { PATH_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\nconst PATH_UPDATE_TAG_KEY = ['path', 'customPath', ...GRAPHIC_UPDATE_TAG_KEY];\n\nexport class Path extends Graphic<IPathGraphicAttribute> implements IPath {\n type: 'path' = 'path';\n cache?: ICustomPath2D;\n\n static NOWORK_ANIMATE_ATTR = {\n path: 1,\n customPath: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params: IPathGraphicAttribute) {\n super(params);\n this.numberType = PATH_NUMBER_TYPE;\n }\n\n get pathShape(): ICustomPath2D {\n this.tryUpdateAABBBounds();\n return this.getParsedPathShape();\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { path } = this.attribute;\n return path != null && path !== '';\n }\n\n getParsedPathShape(): CustomPath2D {\n const pathTheme = this.getGraphicTheme();\n if (!this.valid) {\n return pathTheme.path as CustomPath2D;\n }\n const attribute = this.attribute;\n if (attribute.path instanceof CustomPath2D) {\n return attribute.path;\n }\n\n if (isNil(this.cache)) {\n this.doUpdatePathShape();\n }\n\n if (this.cache instanceof CustomPath2D) {\n return this.cache;\n }\n return pathTheme.path as CustomPath2D;\n }\n\n getGraphicTheme(): Required<IPathGraphicAttribute> {\n return getTheme(this).path;\n }\n\n protected updateAABBBounds(\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n if (!application.graphicService.validCheck(attribute, pathTheme, aabbBounds, this)) {\n return aabbBounds;\n }\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n const pathShape = this.getParsedPathShape();\n aabbBounds.union(pathShape.getBounds());\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n const { lineJoin = pathTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, lineJoin === 'miter', this);\n return aabbBounds;\n }\n\n protected doUpdatePathShape() {\n const attribute = this.attribute;\n if (isString(attribute.path, true)) {\n this.cache = new CustomPath2D().fromString(attribute.path as string);\n } else if (attribute.customPath) {\n this.cache = new CustomPath2D();\n attribute.customPath(this.cache, this);\n }\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), x, y);\n }\n\n clone() {\n return new Path({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Path.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createPath(attributes: IPathGraphicAttribute): IPath {\n return new Path(attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/path.ts"],"names":[],"mappings":";;;AACA,6CAAmD;AACnD,uCAAiF;AAEjF,2DAAuD;AACvD,mCAAmC;AACnC,gDAA6C;AAC7C,2CAA+C;AAC/C,2FAA8F;AAE9F,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,gCAAsB,CAAC,CAAC;AAE9E,MAAa,IAAK,SAAQ,iBAA8B;IAUtD,YAAY,MAA6B;QACvC,KAAK,CAAC,MAAM,CAAC,CAAC;QAVhB,SAAI,GAAW,MAAM,CAAC;QAWpB,IAAI,CAAC,UAAU,GAAG,4BAAgB,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;IACO,QAAQ;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;IACrC,CAAC;IAED,kBAAkB;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,EA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E,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK;QACH,OAAO,IAAI,IAAI,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;IACzC,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;;AA9GH,oBA+GC;AA3GQ,wBAAmB,mBACxB,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,IACV,6BAAmB,EACtB;AAyGJ,SAAgB,UAAU,CAAC,UAAiC;IAC1D,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAFD,gCAEC","file":"path.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isString, isNil } from '@visactor/vutils';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type { ICustomPath2D, IPath, IPathGraphicAttribute } from '../interface';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { PATH_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\nconst PATH_UPDATE_TAG_KEY = ['path', 'customPath', ...GRAPHIC_UPDATE_TAG_KEY];\n\nexport class Path extends Graphic<IPathGraphicAttribute> implements IPath {\n type: 'path' = 'path';\n cache?: ICustomPath2D;\n\n static NOWORK_ANIMATE_ATTR = {\n path: 1,\n customPath: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params: IPathGraphicAttribute) {\n super(params);\n this.numberType = PATH_NUMBER_TYPE;\n }\n\n get pathShape(): ICustomPath2D {\n this.tryUpdateAABBBounds();\n return this.getParsedPathShape();\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { path } = this.attribute;\n return path != null && path !== '';\n }\n\n getParsedPathShape(): CustomPath2D {\n const pathTheme = this.getGraphicTheme();\n if (!this.valid) {\n return pathTheme.path as CustomPath2D;\n }\n const attribute = this.attribute;\n if (attribute.path instanceof CustomPath2D) {\n return attribute.path;\n }\n\n if (isNil(this.cache)) {\n this.doUpdatePathShape();\n }\n\n if (this.cache instanceof CustomPath2D) {\n return this.cache;\n }\n return pathTheme.path as CustomPath2D;\n }\n\n getGraphicTheme(): Required<IPathGraphicAttribute> {\n return getTheme(this).path;\n }\n\n protected updateAABBBounds(\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n if (!application.graphicService.validCheck(attribute, pathTheme, aabbBounds, this)) {\n return aabbBounds;\n }\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n const pathShape = this.getParsedPathShape();\n aabbBounds.union(pathShape.getBounds());\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n const { lineJoin = pathTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, lineJoin === 'miter', this);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(full?: boolean) {\n this.doUpdatePathShape();\n return super.doUpdateAABBBounds(full);\n }\n\n protected doUpdatePathShape() {\n const attribute = this.attribute;\n if (isString(attribute.path, true)) {\n this.cache = new CustomPath2D().fromString(attribute.path as string);\n } else if (attribute.customPath) {\n this.cache = new CustomPath2D();\n attribute.customPath(this.cache, this);\n }\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), x, y);\n }\n\n clone() {\n return new Path({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Path.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createPath(attributes: IPathGraphicAttribute): IPath {\n return new Path(attributes);\n}\n"]}
@@ -1,10 +1,11 @@
1
- import type { IPlugin, IPluginService } from '../../interface';
1
+ import type { IGraphic, IPlugin, IPluginService } from '../../interface';
2
2
  export declare class AutoRenderPlugin implements IPlugin {
3
3
  name: 'AutoRenderPlugin';
4
4
  activeEvent: 'onRegister';
5
5
  pluginService: IPluginService;
6
6
  _uid: number;
7
7
  key: string;
8
+ handleChange: (graphic: IGraphic) => void;
8
9
  activate(context: IPluginService): void;
9
10
  deactivate(context: IPluginService): void;
10
11
  }
@@ -9,18 +9,20 @@ const generator_1 = require("../../common/generator"), application_1 = require("
9
9
  class AutoRenderPlugin {
10
10
  constructor() {
11
11
  this.name = "AutoRenderPlugin", this.activeEvent = "onRegister", this._uid = generator_1.Generator.GenAutoIncrementId(),
12
- this.key = this.name + this._uid;
12
+ this.key = this.name + this._uid, this.handleChange = graphic => {
13
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
14
+ };
13
15
  }
14
16
  activate(context) {
15
- this.pluginService = context, application_1.application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
16
- graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === context.stage && null != graphic.stage && graphic.stage.renderNextFrame();
17
- })), application_1.application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
18
- graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === context.stage && null != graphic.stage && graphic.stage.renderNextFrame();
19
- }));
17
+ this.pluginService = context, application_1.application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange),
18
+ application_1.application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange),
19
+ application_1.application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);
20
20
  }
21
21
  deactivate(context) {
22
- application_1.application.graphicService.hooks.onAttributeUpdate.taps = application_1.application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
23
- application_1.application.graphicService.hooks.onSetStage.taps = application_1.application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
22
+ const filterByName = taps => taps.filter((item => item.name !== this.key));
23
+ application_1.application.graphicService.hooks.onAttributeUpdate.taps = filterByName(application_1.application.graphicService.hooks.onAttributeUpdate.taps),
24
+ application_1.application.graphicService.hooks.onSetStage.taps = filterByName(application_1.application.graphicService.hooks.onSetStage.taps),
25
+ application_1.application.graphicService.hooks.onRemove.taps = filterByName(application_1.application.graphicService.hooks.onRemove.taps);
24
26
  }
25
27
  }
26
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAgD;AAGhD,MAAa,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IA8BtC,CAAC;IA5BC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YACzE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBAC5D,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;QACH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YAClE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBAC5D,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI;YACrD,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACpE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAChH,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnCD,4CAmCC","file":"auto-render-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRenderPlugin implements IPlugin {\n name: 'AutoRenderPlugin' = 'AutoRenderPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === context.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n });\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === context.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAgD;AAGhD,MAAa,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEpC,iBAAY,GAAG,CAAC,OAAiB,EAAE,EAAE;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC;IAqBJ,CAAC;IAnBC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACpF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7E,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7E,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,EAAE;YACvC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,GAAG,YAAY,CACpE,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CACxD,CAAC;QACF,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClH,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChH,CAAC;CACF;AAnCD,4CAmCC","file":"auto-render-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { FullTap, IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRenderPlugin implements IPlugin {\n name: 'AutoRenderPlugin' = 'AutoRenderPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange);\n application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange);\n application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);\n }\n deactivate(context: IPluginService): void {\n const filterByName = (taps: FullTap[]) => {\n return taps.filter(item => {\n return item.name !== this.key;\n });\n };\n\n application.graphicService.hooks.onAttributeUpdate.taps = filterByName(\n application.graphicService.hooks.onAttributeUpdate.taps\n );\n application.graphicService.hooks.onSetStage.taps = filterByName(application.graphicService.hooks.onSetStage.taps);\n application.graphicService.hooks.onRemove.taps = filterByName(application.graphicService.hooks.onRemove.taps);\n }\n}\n"]}
@@ -37,7 +37,7 @@ let DefaultCanvasSymbolRender = class extends base_render_1.BaseRender {
37
37
  if (symbol._parsedPath.svgCache) {
38
38
  const obj = Object.assign({}, a);
39
39
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
40
- obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
40
+ obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity,
41
41
  obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
42
42
  a = obj;
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAE3E,iFAA6E;AAC7E,kDAAkD;AAClD,0DAAgE;AAgBhE,+CAA2C;AAC3C,yDAAqE;AACrE,6CAA2C;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AAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAxLY,yBAAyB;IADrC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,oCAAwB,CAAC,CAAA;;GANvB,yBAAyB,CAwLrC;AAxLY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.fill ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n a = obj;\n }\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (\n parsedPath.draw(\n context,\n isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX,\n p.x,\n p.y,\n undefined,\n callback\n ) === false\n ) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (parsedPath.draw(context, size, x, y, z, callback) === false) {\n context.closePath();\n }\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAE3E,iFAA6E;AAC7E,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,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAxLY,yBAAyB;IADrC,IAAA,2BAAU,GAAE;IAMR,WAAA,IAAA,uBAAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,oCAAwB,CAAC,CAAA;;GANvB,yBAAyB,CAwLrC;AAxLY,8DAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n a = obj;\n }\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (\n parsedPath.draw(\n context,\n isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX,\n p.x,\n p.y,\n undefined,\n callback\n ) === false\n ) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (parsedPath.draw(context, size, x, y, z, callback) === false) {\n context.closePath();\n }\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -17594,7 +17594,7 @@ let DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends BaseRend
17594
17594
  if (symbol._parsedPath.svgCache) {
17595
17595
  const obj = Object.assign({}, a);
17596
17596
  obj.fill = (_a = a.fill) !== null && _a !== void 0 ? _a : symbol.attribute.fill;
17597
- obj.opacity = (_b = a.fill) !== null && _b !== void 0 ? _b : symbol.attribute.opacity;
17597
+ obj.opacity = (_b = a.opacity) !== null && _b !== void 0 ? _b : symbol.attribute.opacity;
17598
17598
  obj.fillOpacity = symbol.attribute.fillOpacity;
17599
17599
  obj.stroke = (_c = a.stroke) !== null && _c !== void 0 ? _c : symbol.attribute.stroke;
17600
17600
  a = obj;
@@ -22470,6 +22470,10 @@ class Path extends Graphic {
22470
22470
  application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, lineJoin === 'miter', this);
22471
22471
  return aabbBounds;
22472
22472
  }
22473
+ doUpdateAABBBounds(full) {
22474
+ this.doUpdatePathShape();
22475
+ return super.doUpdateAABBBounds(full);
22476
+ }
22473
22477
  doUpdatePathShape() {
22474
22478
  const attribute = this.attribute;
22475
22479
  if (isString(attribute.path, true)) {
@@ -24267,34 +24271,30 @@ class AutoRenderPlugin {
24267
24271
  this.activeEvent = 'onRegister';
24268
24272
  this._uid = Generator.GenAutoIncrementId();
24269
24273
  this.key = this.name + this._uid;
24270
- }
24271
- activate(context) {
24272
- this.pluginService = context;
24273
- application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {
24274
- if (graphic.glyphHost) {
24275
- graphic = graphic.glyphHost;
24276
- }
24277
- if (graphic.stage === context.stage && graphic.stage != null) {
24278
- graphic.stage.renderNextFrame();
24279
- }
24280
- });
24281
- application.graphicService.hooks.onSetStage.tap(this.key, graphic => {
24274
+ this.handleChange = (graphic) => {
24282
24275
  if (graphic.glyphHost) {
24283
24276
  graphic = graphic.glyphHost;
24284
24277
  }
24285
- if (graphic.stage === context.stage && graphic.stage != null) {
24278
+ if (graphic.stage === this.pluginService.stage && graphic.stage != null) {
24286
24279
  graphic.stage.renderNextFrame();
24287
24280
  }
24288
- });
24281
+ };
24282
+ }
24283
+ activate(context) {
24284
+ this.pluginService = context;
24285
+ application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange);
24286
+ application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange);
24287
+ application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);
24289
24288
  }
24290
24289
  deactivate(context) {
24291
- application.graphicService.hooks.onAttributeUpdate.taps =
24292
- application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {
24290
+ const filterByName = (taps) => {
24291
+ return taps.filter(item => {
24293
24292
  return item.name !== this.key;
24294
24293
  });
24295
- application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {
24296
- return item.name !== this.key;
24297
- });
24294
+ };
24295
+ application.graphicService.hooks.onAttributeUpdate.taps = filterByName(application.graphicService.hooks.onAttributeUpdate.taps);
24296
+ application.graphicService.hooks.onSetStage.taps = filterByName(application.graphicService.hooks.onSetStage.taps);
24297
+ application.graphicService.hooks.onRemove.taps = filterByName(application.graphicService.hooks.onRemove.taps);
24298
24298
  }
24299
24299
  }
24300
24300
 
@@ -44,6 +44,7 @@ export declare class Path extends Graphic<IPathGraphicAttribute> implements IPat
44
44
  getParsedPathShape(): CustomPath2D;
45
45
  getGraphicTheme(): Required<IPathGraphicAttribute>;
46
46
  protected updateAABBBounds(attribute: IPathGraphicAttribute, pathTheme: Required<IPathGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
47
+ protected doUpdateAABBBounds(full?: boolean): import("@visactor/vutils").IBounds;
47
48
  protected doUpdatePathShape(): void;
48
49
  protected needUpdateTags(keys: string[]): boolean;
49
50
  protected needUpdateTag(key: string): boolean;
@@ -51,6 +51,9 @@ export class Path extends Graphic {
51
51
  return application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this),
52
52
  aabbBounds;
53
53
  }
54
+ doUpdateAABBBounds(full) {
55
+ return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
56
+ }
54
57
  doUpdatePathShape() {
55
58
  const attribute = this.attribute;
56
59
  isString(attribute.path, !0) ? this.cache = (new CustomPath2D).fromString(attribute.path) : attribute.customPath && (this.cache = new CustomPath2D,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/path.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAE9F,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,sBAAsB,CAAC,CAAC;AAE9E,MAAM,OAAO,IAAK,SAAQ,OAA8B;IAUtD,YAAY,MAA6B;QACvC,KAAK,CAAC,MAAM,CAAC,CAAC;QAVhB,SAAI,GAAW,MAAM,CAAC;QAWpB,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;IACO,QAAQ;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,K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AI,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;IACzC,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;;AArGM,wBAAmB,mBACxB,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,IACV,mBAAmB,EACtB;AAoGJ,MAAM,UAAU,UAAU,CAAC,UAAiC;IAC1D,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC","file":"path.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isString, isNil } from '@visactor/vutils';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type { ICustomPath2D, IPath, IPathGraphicAttribute } from '../interface';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { PATH_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\nconst PATH_UPDATE_TAG_KEY = ['path', 'customPath', ...GRAPHIC_UPDATE_TAG_KEY];\n\nexport class Path extends Graphic<IPathGraphicAttribute> implements IPath {\n type: 'path' = 'path';\n cache?: ICustomPath2D;\n\n static NOWORK_ANIMATE_ATTR = {\n path: 1,\n customPath: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params: IPathGraphicAttribute) {\n super(params);\n this.numberType = PATH_NUMBER_TYPE;\n }\n\n get pathShape(): ICustomPath2D {\n this.tryUpdateAABBBounds();\n return this.getParsedPathShape();\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { path } = this.attribute;\n return path != null && path !== '';\n }\n\n getParsedPathShape(): CustomPath2D {\n const pathTheme = this.getGraphicTheme();\n if (!this.valid) {\n return pathTheme.path as CustomPath2D;\n }\n const attribute = this.attribute;\n if (attribute.path instanceof CustomPath2D) {\n return attribute.path;\n }\n\n if (isNil(this.cache)) {\n this.doUpdatePathShape();\n }\n\n if (this.cache instanceof CustomPath2D) {\n return this.cache;\n }\n return pathTheme.path as CustomPath2D;\n }\n\n getGraphicTheme(): Required<IPathGraphicAttribute> {\n return getTheme(this).path;\n }\n\n protected updateAABBBounds(\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n if (!application.graphicService.validCheck(attribute, pathTheme, aabbBounds, this)) {\n return aabbBounds;\n }\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n const pathShape = this.getParsedPathShape();\n aabbBounds.union(pathShape.getBounds());\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n const { lineJoin = pathTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, lineJoin === 'miter', this);\n return aabbBounds;\n }\n\n protected doUpdatePathShape() {\n const attribute = this.attribute;\n if (isString(attribute.path, true)) {\n this.cache = new CustomPath2D().fromString(attribute.path as string);\n } else if (attribute.customPath) {\n this.cache = new CustomPath2D();\n attribute.customPath(this.cache, this);\n }\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), x, y);\n }\n\n clone() {\n return new Path({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Path.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createPath(attributes: IPathGraphicAttribute): IPath {\n return new Path(attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/path.ts"],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,CAAC;IAClC,CAAC;;AA1GM,wBAAmB,mBACxB,IAAI,EAAE,CAAC,EACP,UAAU,EAAE,CAAC,IACV,mBAAmB,EACtB;AAyGJ,MAAM,UAAU,UAAU,CAAC,UAAiC;IAC1D,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC","file":"path.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isString, isNil } from '@visactor/vutils';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type { ICustomPath2D, IPath, IPathGraphicAttribute } from '../interface';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { PATH_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\nconst PATH_UPDATE_TAG_KEY = ['path', 'customPath', ...GRAPHIC_UPDATE_TAG_KEY];\n\nexport class Path extends Graphic<IPathGraphicAttribute> implements IPath {\n type: 'path' = 'path';\n cache?: ICustomPath2D;\n\n static NOWORK_ANIMATE_ATTR = {\n path: 1,\n customPath: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params: IPathGraphicAttribute) {\n super(params);\n this.numberType = PATH_NUMBER_TYPE;\n }\n\n get pathShape(): ICustomPath2D {\n this.tryUpdateAABBBounds();\n return this.getParsedPathShape();\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { path } = this.attribute;\n return path != null && path !== '';\n }\n\n getParsedPathShape(): CustomPath2D {\n const pathTheme = this.getGraphicTheme();\n if (!this.valid) {\n return pathTheme.path as CustomPath2D;\n }\n const attribute = this.attribute;\n if (attribute.path instanceof CustomPath2D) {\n return attribute.path;\n }\n\n if (isNil(this.cache)) {\n this.doUpdatePathShape();\n }\n\n if (this.cache instanceof CustomPath2D) {\n return this.cache;\n }\n return pathTheme.path as CustomPath2D;\n }\n\n getGraphicTheme(): Required<IPathGraphicAttribute> {\n return getTheme(this).path;\n }\n\n protected updateAABBBounds(\n attribute: IPathGraphicAttribute,\n pathTheme: Required<IPathGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n if (!application.graphicService.validCheck(attribute, pathTheme, aabbBounds, this)) {\n return aabbBounds;\n }\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n const pathShape = this.getParsedPathShape();\n aabbBounds.union(pathShape.getBounds());\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n const { lineJoin = pathTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, lineJoin === 'miter', this);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(full?: boolean) {\n this.doUpdatePathShape();\n return super.doUpdateAABBBounds(full);\n }\n\n protected doUpdatePathShape() {\n const attribute = this.attribute;\n if (isString(attribute.path, true)) {\n this.cache = new CustomPath2D().fromString(attribute.path as string);\n } else if (attribute.customPath) {\n this.cache = new CustomPath2D();\n attribute.customPath(this.cache, this);\n }\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), x, y);\n }\n\n clone() {\n return new Path({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Path.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createPath(attributes: IPathGraphicAttribute): IPath {\n return new Path(attributes);\n}\n"]}
@@ -1,10 +1,11 @@
1
- import type { IPlugin, IPluginService } from '../../interface';
1
+ import type { IGraphic, IPlugin, IPluginService } from '../../interface';
2
2
  export declare class AutoRenderPlugin implements IPlugin {
3
3
  name: 'AutoRenderPlugin';
4
4
  activeEvent: 'onRegister';
5
5
  pluginService: IPluginService;
6
6
  _uid: number;
7
7
  key: string;
8
+ handleChange: (graphic: IGraphic) => void;
8
9
  activate(context: IPluginService): void;
9
10
  deactivate(context: IPluginService): void;
10
11
  }
@@ -5,18 +5,19 @@ import { application } from "../../application";
5
5
  export class AutoRenderPlugin {
6
6
  constructor() {
7
7
  this.name = "AutoRenderPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
8
- this.key = this.name + this._uid;
8
+ this.key = this.name + this._uid, this.handleChange = graphic => {
9
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
10
+ };
9
11
  }
10
12
  activate(context) {
11
- this.pluginService = context, application.graphicService.hooks.onAttributeUpdate.tap(this.key, (graphic => {
12
- graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === context.stage && null != graphic.stage && graphic.stage.renderNextFrame();
13
- })), application.graphicService.hooks.onSetStage.tap(this.key, (graphic => {
14
- graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === context.stage && null != graphic.stage && graphic.stage.renderNextFrame();
15
- }));
13
+ this.pluginService = context, application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange),
14
+ application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange), application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);
16
15
  }
17
16
  deactivate(context) {
18
- application.graphicService.hooks.onAttributeUpdate.taps = application.graphicService.hooks.onAttributeUpdate.taps.filter((item => item.name !== this.key)),
19
- application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter((item => item.name !== this.key));
17
+ const filterByName = taps => taps.filter((item => item.name !== this.key));
18
+ application.graphicService.hooks.onAttributeUpdate.taps = filterByName(application.graphicService.hooks.onAttributeUpdate.taps),
19
+ application.graphicService.hooks.onSetStage.taps = filterByName(application.graphicService.hooks.onSetStage.taps),
20
+ application.graphicService.hooks.onRemove.taps = filterByName(application.graphicService.hooks.onRemove.taps);
20
21
  }
21
22
  }
22
23
  //# sourceMappingURL=auto-render-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IA8BtC,CAAC;IA5BC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YACzE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBAC5D,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;YAClE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBAC5D,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI;YACrD,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACpE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAChH,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","file":"auto-render-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRenderPlugin implements IPlugin {\n name: 'AutoRenderPlugin' = 'AutoRenderPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === context.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n });\n application.graphicService.hooks.onSetStage.tap(this.key, graphic => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === context.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n });\n }\n deactivate(context: IPluginService): void {\n application.graphicService.hooks.onAttributeUpdate.taps =\n application.graphicService.hooks.onAttributeUpdate.taps.filter(item => {\n return item.name !== this.key;\n });\n application.graphicService.hooks.onSetStage.taps = application.graphicService.hooks.onSetStage.taps.filter(item => {\n return item.name !== this.key;\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/auto-render-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,gBAAgB;IAA7B;QACE,SAAI,GAAuB,kBAAkB,CAAC;QAC9C,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEpC,iBAAY,GAAG,CAAC,OAAiB,EAAE,EAAE;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC;IAqBJ,CAAC;IAnBC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACpF,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7E,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7E,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,EAAE;YACvC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,GAAG,YAAY,CACpE,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CACxD,CAAC;QACF,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClH,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChH,CAAC;CACF","file":"auto-render-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { FullTap, IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRenderPlugin implements IPlugin {\n name: 'AutoRenderPlugin' = 'AutoRenderPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n application.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handleChange);\n application.graphicService.hooks.onSetStage.tap(this.key, this.handleChange);\n application.graphicService.hooks.onRemove.tap(this.key, this.handleChange);\n }\n deactivate(context: IPluginService): void {\n const filterByName = (taps: FullTap[]) => {\n return taps.filter(item => {\n return item.name !== this.key;\n });\n };\n\n application.graphicService.hooks.onAttributeUpdate.taps = filterByName(\n application.graphicService.hooks.onAttributeUpdate.taps\n );\n application.graphicService.hooks.onSetStage.taps = filterByName(application.graphicService.hooks.onSetStage.taps);\n application.graphicService.hooks.onRemove.taps = filterByName(application.graphicService.hooks.onRemove.taps);\n }\n}\n"]}
@@ -45,7 +45,7 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
45
45
  if (symbol._parsedPath.svgCache) {
46
46
  const obj = Object.assign({}, a);
47
47
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill,
48
- obj.opacity = null !== (_b = a.fill) && void 0 !== _b ? _b : symbol.attribute.opacity,
48
+ obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity,
49
49
  obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke,
50
50
  a = obj;
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/symbol-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAgBhE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OA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EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAxLY,yBAAyB;IADrC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,wBAAwB,CAAC,CAAA;;GANvB,yBAAyB,CAwLrC;SAxLY,yBAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.fill ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n a = obj;\n }\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (\n parsedPath.draw(\n context,\n isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX,\n p.x,\n p.y,\n undefined,\n callback\n ) === false\n ) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (parsedPath.draw(context, size, x, y, z, callback) === false) {\n context.closePath();\n }\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}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AAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,eAAe,CAChB,CAAC;gBACF,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;QAED,IAAI,CAAC,eAAe,CAClB,MAAM,EACN,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAxLY,yBAAyB;IADrC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,wBAAwB,CAAC,CAAA;;GANvB,yBAAyB,CAwLrC;SAxLY,yBAAyB","file":"symbol-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport { SYMBOL_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n ICustomPath2D\n} from '../../../interface';\nimport type {} from '../../render-service';\nimport { BaseRender } from './base-render';\nimport { SymbolRenderContribution } from './contributions/constants';\nimport { isArray } from '@visactor/vutils';\nimport {\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolRenderContribution,\n defaultSymbolTextureRenderContribution\n} from './contributions';\n\n@injectable()\nexport class DefaultCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number = SYMBOL_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(SymbolRenderContribution)\n protected readonly symbolRenderContribitions: IContributionProvider<ISymbolRenderContribution>\n ) {\n super();\n this.builtinContributions = [\n defaultSymbolRenderContribution,\n defaultSymbolBackgroundRenderContribution,\n defaultSymbolTextureRenderContribution\n ];\n this.init(symbolRenderContribitions);\n }\n\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) {\n // const symbolAttribute = graphicService.themeService.getCurrentTheme().symbolAttribute;\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n\n const {\n size = symbolAttribute.size,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY\n } = symbol.attribute;\n\n const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { keepDirIn3d = symbolAttribute.keepDirIn3d } = symbol.attribute;\n const z = this.z ?? 0;\n context.beginPath();\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (symbol._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? symbol.attribute.fill;\n obj.opacity = a.opacity ?? symbol.attribute.opacity;\n obj.fillOpacity = symbol.attribute.fillOpacity;\n obj.stroke = a.stroke ?? symbol.attribute.stroke;\n a = obj;\n }\n if (a.fill) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else {\n context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);\n context.stroke();\n }\n }\n };\n if (keepDirIn3d && context.camera && context.project) {\n const p = context.project(x, y, z);\n const camera = context.camera;\n context.camera = null;\n if (\n parsedPath.draw(\n context,\n isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX,\n p.x,\n p.y,\n undefined,\n callback\n ) === false\n ) {\n context.closePath();\n }\n context.camera = camera;\n } else {\n if (parsedPath.draw(context, size, x, y, z, callback) === false) {\n context.closePath();\n }\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n this.beforeRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n // if (fill !== false) {\n // context.setCommonStyle(symbol.attribute, symbolAttribute);\n // context.fill();\n // }\n // if (stroke !== false) {\n // context.setStrokeStyle(symbol.attribute, symbolAttribute);\n // context.stroke();\n // }\n\n // svg就不用fill和stroke了\n if (doFill && !parsedPath.isSvg) {\n if (fillCb) {\n fillCb(context, symbol.attribute, symbolAttribute);\n } else if (fVisible) {\n context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);\n context.fill();\n }\n }\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, symbol.attribute, symbolAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n symbol,\n symbol.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute\n );\n context.stroke();\n }\n }\n\n this.afterRenderStep(\n symbol,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n symbolAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const symbolAttribute = getTheme(symbol, params?.theme).symbol;\n this._draw(symbol, symbolAttribute, false, drawContext, params);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-core",
3
- "version": "0.20.0-alpha.2",
3
+ "version": "0.20.0-alpha.4",
4
4
  "description": "",
5
5
  "sideEffects": [
6
6
  "./src/modules.ts",
@@ -35,9 +35,9 @@
35
35
  "vite": "3.2.6",
36
36
  "typescript": "4.9.5",
37
37
  "cross-env": "^7.0.3",
38
- "@internal/eslint-config": "0.0.1",
38
+ "@internal/bundler": "0.0.1",
39
39
  "@internal/ts-config": "0.0.1",
40
- "@internal/bundler": "0.0.1"
40
+ "@internal/eslint-config": "0.0.1"
41
41
  },
42
42
  "keywords": [
43
43
  "VisActor",