@visactor/vrender-core 0.20.6-alpha.0 → 0.20.6-alpha.2

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/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isPointInLine, pi, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, isArray, cos, sin, pointAt, isNumber, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint, isNumberClose, isNil, Bounds, getIntersectPoint, Color, DEFAULT_COLORS, normalTransform, isValidUrl, isBase64, acos, sqrt, LRU, lowerCamelCaseToMiddle, isValid, transformBoundsWithMatrix, arrayEqual, getContextFont, clampAngleByRadian, asin, getRectIntersect, isRectIntersect, merge, calculateAnchorOfBounds, styleStringToObject } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isPointInLine, pi, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, isArray, cos, sin, pointAt, isNumber, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint, isNumberClose, isNil, Bounds, getIntersectPoint, Color, DEFAULT_COLORS, OBBBounds, normalTransform, isValidUrl, isBase64, acos, sqrt, LRU, lowerCamelCaseToMiddle, isValid, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, getRectIntersect, isRectIntersect, merge, calculateAnchorOfBounds, styleStringToObject } from '@visactor/vutils';
2
2
 
3
3
  class Generator {
4
4
  static GenAutoIncrementId() {
@@ -10953,6 +10953,9 @@ class Graphic extends Node {
10953
10953
  get AABBBounds() {
10954
10954
  return this.tryUpdateAABBBounds(this.attribute.boundsMode === 'imprecise');
10955
10955
  }
10956
+ get OBBBounds() {
10957
+ return this.tryUpdateOBBBounds();
10958
+ }
10956
10959
  get globalAABBBounds() {
10957
10960
  return this.tryUpdateGlobalAABBBounds();
10958
10961
  }
@@ -10969,6 +10972,7 @@ class Graphic extends Node {
10969
10972
  this._updateTag = UpdateTag.INIT;
10970
10973
  this.attribute = params;
10971
10974
  this.valid = this.isValid();
10975
+ this.updateAABBBoundsStamp = 0;
10972
10976
  if (params.background) {
10973
10977
  this.loadImage((_a = params.background.background) !== null && _a !== void 0 ? _a : params.background, true);
10974
10978
  }
@@ -11015,13 +11019,33 @@ class Graphic extends Node {
11015
11019
  application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, true);
11016
11020
  return bounds;
11017
11021
  }
11022
+ tryUpdateOBBBounds() {
11023
+ if (!this._OBBBounds) {
11024
+ this._OBBBounds = new OBBBounds();
11025
+ }
11026
+ this.tryUpdateAABBBounds();
11027
+ if (this.updateOBBBoundsStamp === this.updateAABBBoundsStamp) {
11028
+ return this._OBBBounds;
11029
+ }
11030
+ this.updateOBBBoundsStamp = this.updateAABBBoundsStamp;
11031
+ if (!this.valid) {
11032
+ this._OBBBounds.clear();
11033
+ return this._OBBBounds;
11034
+ }
11035
+ const bounds = this.doUpdateOBBBounds();
11036
+ return bounds;
11037
+ }
11018
11038
  combindShadowAABBBounds(bounds) {
11019
11039
  if (this.shadowRoot) {
11020
11040
  const b = this.shadowRoot.AABBBounds.clone();
11021
11041
  bounds.union(b);
11022
11042
  }
11023
11043
  }
11044
+ doUpdateOBBBounds() {
11045
+ return this._OBBBounds;
11046
+ }
11024
11047
  doUpdateAABBBounds(full) {
11048
+ this.updateAABBBoundsStamp++;
11025
11049
  const graphicTheme = this.getGraphicTheme();
11026
11050
  this._AABBBounds.clear();
11027
11051
  const attribute = this.attribute;
@@ -12628,6 +12652,7 @@ class Group extends Graphic {
12628
12652
  return originalAABBBounds;
12629
12653
  }
12630
12654
  doUpdateAABBBounds() {
12655
+ this.updateAABBBoundsStamp++;
12631
12656
  const bounds = super.doUpdateAABBBounds();
12632
12657
  this.parent && this.parent.addChildUpdateBoundTag();
12633
12658
  this._emitCustomEvent('AAABBBoundsChange');
@@ -18567,7 +18592,16 @@ class InteractiveDrawItemInterceptorContribution {
18567
18592
  }
18568
18593
  beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params) {
18569
18594
  const baseGraphic = graphic.baseGraphic;
18570
- if (!baseGraphic.stage) {
18595
+ let intree = !!baseGraphic.stage;
18596
+ let _g = baseGraphic.parent;
18597
+ while (intree && _g) {
18598
+ if (_g.stage === _g) {
18599
+ break;
18600
+ }
18601
+ intree = !!_g.stage;
18602
+ _g = _g.parent;
18603
+ }
18604
+ if (!intree) {
18571
18605
  const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');
18572
18606
  if (interactiveLayer) {
18573
18607
  const shadowRoot = this.getShadowRoot(interactiveLayer);
@@ -19051,6 +19085,29 @@ class Text extends Graphic {
19051
19085
  getGraphicTheme() {
19052
19086
  return getTheme(this).text;
19053
19087
  }
19088
+ doUpdateOBBBounds() {
19089
+ const graphicTheme = this.getGraphicTheme();
19090
+ this._OBBBounds.clear();
19091
+ const attribute = this.attribute;
19092
+ const { angle = graphicTheme.angle } = attribute;
19093
+ if (!angle) {
19094
+ const b = this.AABBBounds;
19095
+ this._OBBBounds.setValue(b.x1, b.y1, b.x2, b.y2);
19096
+ return this._OBBBounds;
19097
+ }
19098
+ if (!this.obbText) {
19099
+ this.obbText = new Text({});
19100
+ }
19101
+ this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), { angle: 0 }));
19102
+ const bounds1 = this.obbText.AABBBounds;
19103
+ const { x, y } = attribute;
19104
+ const boundsCenter = { x: (bounds1.x1 + bounds1.x2) / 2, y: (bounds1.y1 + bounds1.y2) / 2 };
19105
+ const center = rotatePoint(boundsCenter, angle, { x, y });
19106
+ this._OBBBounds.copy(bounds1);
19107
+ this._OBBBounds.translate(center.x - boundsCenter.x, center.y - boundsCenter.y);
19108
+ this._OBBBounds.angle = angle;
19109
+ return this._OBBBounds;
19110
+ }
19054
19111
  updateAABBBounds(attribute, textTheme, aabbBounds) {
19055
19112
  const { text = textTheme.text } = this.attribute;
19056
19113
  if (Array.isArray(text)) {
@@ -20847,6 +20904,7 @@ class Glyph extends Graphic {
20847
20904
  return aabbBounds;
20848
20905
  }
20849
20906
  doUpdateAABBBounds() {
20907
+ this.updateAABBBoundsStamp++;
20850
20908
  this._AABBBounds.clear();
20851
20909
  const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds);
20852
20910
  this.clearUpdateBoundTag();
@@ -22678,12 +22736,13 @@ class Arc extends Graphic {
22678
22736
  return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
22679
22737
  }
22680
22738
  toCustomPath() {
22739
+ var _a, _b, _c, _d;
22681
22740
  const x = 0;
22682
22741
  const y = 0;
22683
22742
  const attribute = this.attribute;
22684
22743
  const { startAngle, endAngle } = this.getParsedAngle();
22685
- let innerRadius = attribute.innerRadius - (attribute.innerPadding || 0);
22686
- let outerRadius = attribute.outerRadius - (attribute.outerPadding || 0);
22744
+ let innerRadius = ((_a = attribute.innerRadius) !== null && _a !== void 0 ? _a : 0) - ((_b = attribute.innerPadding) !== null && _b !== void 0 ? _b : 0);
22745
+ let outerRadius = ((_c = attribute.outerRadius) !== null && _c !== void 0 ? _c : 0) - ((_d = attribute.outerPadding) !== null && _d !== void 0 ? _d : 0);
22687
22746
  const deltaAngle = abs(endAngle - startAngle);
22688
22747
  const clockwise = endAngle > startAngle;
22689
22748
  if (outerRadius < innerRadius) {
package/es/graphic/arc.js CHANGED
@@ -135,8 +135,9 @@ export class Arc extends Graphic {
135
135
  return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
136
136
  }
137
137
  toCustomPath() {
138
+ var _a, _b, _c, _d;
138
139
  const attribute = this.attribute, {startAngle: startAngle, endAngle: endAngle} = this.getParsedAngle();
139
- let innerRadius = attribute.innerRadius - (attribute.innerPadding || 0), outerRadius = attribute.outerRadius - (attribute.outerPadding || 0);
140
+ let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0), outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
140
141
  const deltaAngle = abs(endAngle - startAngle), clockwise = endAngle > startAngle;
141
142
  if (outerRadius < innerRadius) {
142
143
  const temp = outerRadius;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/arc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElH,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAmB9F,MAAM,kBAAkB,GAAG;IACzB,aAAa;IACb,aAAa;IACb,YAAY;IACZ,UAAU;IACV,cAAc;IACd,UAAU;IACV,WAAW;IACX,KAAK;IACL,GAAG,sBAAsB;CAC1B,CAAC;AAMF,MAAM,OAAO,GAAI,SAAQ,OAA6B;IA8CpD,YAAY,MAA4B;QACtC,KAAK,CAAC,MAAM,CAAC,CAAC;QA9ChB,SAAI,GAAgB,KAAK,CAAC;QA+CxB,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC;IACpC,CA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,OAAO,IAAI,GAAG,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;IACxC,CAAC;IAED,oBAAoB;QAClB,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACjC,CAAC;;AA1VM,uBAAmB,mBACxB,GAAG,EAAE,CAAC,IACH,mBAAmB,EACtB;AA0VJ,MAAM,UAAU,SAAS,CAAC,UAAgC;IACxD,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","file":"arc.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { pi2, sin, epsilon, abs, asin, clampAngleByRadian, isNumber, cos, sqrt, isArray } from '@visactor/vutils';\nimport type { IArc, IArcGraphicAttribute } from '../interface/graphic/arc';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { circleBounds } from '../common/utils';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport type { GraphicType } from '../interface';\nimport { ARC_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\n/**\n * 部分代码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\nconst ARC_UPDATE_TAG_KEY = [\n 'innerRadius',\n 'outerRadius',\n 'startAngle',\n 'endAngle',\n 'cornerRadius',\n 'padAngle',\n 'padRadius',\n 'cap',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\n/**\n * 圆形图元\n * 默认顺时针绘制\n */\nexport class Arc extends Graphic<IArcGraphicAttribute> implements IArc {\n type: GraphicType = 'arc';\n\n static NOWORK_ANIMATE_ATTR = {\n cap: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n // static parseCornerRadius(r: IArcGraphicAttribute['cornerRadius']) {\n // if (isArray(r)) {\n // if ((r as any[]).length === 1) {\n // const value = r[0];\n // return [value, value, value, value];\n // }\n\n // if ((r as any[]).length === 2) {\n // return [r[0], r[0], r[1], r[1]];\n // }\n\n // if ((r as any[]).length === 3) {\n // return [r[0], r[1], r[2], 0];\n // }\n\n // return (r as any[]).slice(0, 4);\n // }\n\n // return [r as string | number, r as string | number, r as string | number, r as string | number];\n // }\n\n // static isCornerRadiusEqual(oldR: IArcGraphicAttribute['cornerRadius'], newR: IArcGraphicAttribute['cornerRadius']) {\n // throw new Error('暂不支持');\n // if (oldR === newR) {\n // return true;\n // }\n\n // if (isArray(oldR) && !isArray(newR)) {\n // return (oldR as (string | number)[]).every(r => r === newR);\n // }\n\n // if (!isArray(oldR) && isArray(newR)) {\n // return (newR as (string | number)[]).every(r => r === oldR);\n // }\n\n // return arrayEqual(oldR as (string | number)[], newR as (string | number)[]);\n // }\n\n constructor(params: IArcGraphicAttribute) {\n super(params);\n this.numberType = ARC_NUMBER_TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { startAngle, endAngle, outerRadius, innerRadius } = this.attribute;\n return (\n this._validNumber(startAngle) &&\n this._validNumber(endAngle) &&\n this._validNumber(outerRadius) &&\n this._validNumber(innerRadius)\n );\n }\n\n getParsedCornerRadius() {\n const arcTheme = this.getGraphicTheme();\n const {\n cornerRadius = arcTheme.cornerRadius,\n innerPadding = arcTheme.innerPadding,\n outerPadding = arcTheme.outerPadding\n } = this.attribute;\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (cornerRadius === 0 || cornerRadius === '0%') {\n return 0;\n }\n const deltaRadius = Math.abs(outerRadius - innerRadius);\n const parseCR = (cornerRadius: number | string) => {\n return Math.min(\n isNumber(cornerRadius, true)\n ? (cornerRadius as number)\n : (deltaRadius * parseFloat(cornerRadius as string)) / 100,\n deltaRadius / 2\n );\n };\n if (isArray(cornerRadius)) {\n const crList = cornerRadius.map(cr => parseCR(cr) || 0);\n if (crList.length === 0) {\n return [crList[0], crList[0], crList[0], crList[0]];\n } else if (crList.length === 2) {\n return [crList[0], crList[1], crList[0], crList[1]];\n } else if (crList.length === 3) {\n crList.push(0);\n }\n return crList;\n }\n return parseCR(cornerRadius);\n }\n\n getParsedAngle() {\n const arcTheme = this.getGraphicTheme();\n let { startAngle = arcTheme.startAngle, endAngle = arcTheme.endAngle } = this.attribute;\n const { cap = arcTheme.cap } = this.attribute;\n\n const sign = endAngle - startAngle >= 0 ? 1 : -1;\n const deltaAngle = endAngle - startAngle;\n\n startAngle = clampAngleByRadian(startAngle);\n endAngle = startAngle + deltaAngle;\n\n if (cap && abs(deltaAngle) < pi2 - epsilon) {\n let startCap = 1;\n let endCap = 1;\n if ((cap as boolean[]).length) {\n startCap = Number((cap as boolean[])[0]);\n endCap = Number((cap as boolean[])[1]);\n }\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n const capWidth = Math.abs(outerRadius - innerRadius) / 2;\n // 以外边界长度为准\n const capAngle = capWidth / outerRadius;\n\n if (capWidth > epsilon && outerRadius > epsilon) {\n return {\n startAngle: startAngle - sign * capAngle * startCap,\n endAngle: endAngle + sign * capAngle * endCap,\n sc: sign * capAngle * startCap,\n ec: sign * capAngle * endCap\n };\n }\n }\n\n return {\n startAngle: startAngle,\n endAngle: endAngle\n };\n }\n\n // 参考 https://github.com/d3/d3-shape/blob/main/src/arc.js\n getParsePadAngle(startAngle: number, endAngle: number) {\n const arcTheme = this.getGraphicTheme();\n const {\n innerPadding = arcTheme.innerPadding,\n outerPadding = arcTheme.outerPadding,\n padAngle = arcTheme.padAngle\n } = this.attribute;\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n\n const { padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius) } = this.attribute;\n const deltaAngle = abs(endAngle - startAngle);\n\n // Or is it a circular or annular sector?\n let outerStartAngle = startAngle;\n let outerEndAngle = endAngle;\n let innerStartAngle = startAngle;\n let innerEndAngle = endAngle;\n const halfPadAngle = padAngle / 2;\n let innerDeltaAngle = deltaAngle;\n let outerDeltaAngle = deltaAngle;\n\n // Apply padding? Note that since r1 ≥ r0, outerDeltaAngle ≥ innerDeltaAngle.\n if (halfPadAngle > epsilon && padRadius > epsilon) {\n const sign = endAngle > startAngle ? 1 : -1;\n\n let p0 = asin((Number(padRadius) / innerRadius) * sin(halfPadAngle));\n let p1 = asin((Number(padRadius) / outerRadius) * sin(halfPadAngle));\n if ((innerDeltaAngle -= p0 * 2) > epsilon) {\n p0 *= sign;\n innerStartAngle += p0;\n innerEndAngle -= p0;\n } else {\n innerDeltaAngle = 0;\n innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2;\n }\n if ((outerDeltaAngle -= p1 * 2) > epsilon) {\n p1 *= sign;\n outerStartAngle += p1;\n outerEndAngle -= p1;\n } else {\n outerDeltaAngle = 0;\n outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2;\n }\n\n return {\n outerStartAngle,\n outerEndAngle,\n innerStartAngle,\n innerEndAngle,\n innerDeltaAngle,\n outerDeltaAngle\n };\n }\n\n return {\n outerStartAngle,\n outerEndAngle,\n innerStartAngle,\n innerEndAngle,\n innerDeltaAngle,\n outerDeltaAngle\n };\n }\n\n getGraphicTheme(): Required<IArcGraphicAttribute> {\n return getTheme(this).arc;\n }\n\n protected updateAABBBounds(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n full?: boolean\n ) {\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n full\n ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds)\n : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds);\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n\n const { lineJoin = arcTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, lineJoin === 'miter', this);\n\n return aabbBounds;\n }\n\n protected updateArcAABBBoundsImprecise(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds\n ): IAABBBounds {\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (outerRadius < innerRadius) {\n outerRadius = innerRadius;\n }\n\n aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius);\n\n return aabbBounds;\n }\n protected updateArcAABBBoundsAccurate(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds\n ): IAABBBounds {\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (outerRadius < innerRadius) {\n // 不用解构,避免性能问题\n const temp = outerRadius;\n outerRadius = innerRadius;\n innerRadius = temp;\n }\n let { endAngle = arcTheme.endAngle, startAngle = arcTheme.startAngle } = attribute;\n\n if (startAngle > endAngle) {\n const temp = startAngle;\n startAngle = endAngle;\n endAngle = temp;\n }\n\n if (outerRadius <= epsilon) {\n aabbBounds.set(0, 0, 0, 0);\n } else if (Math.abs(endAngle - startAngle) > pi2 - epsilon) {\n aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius);\n } else {\n // 直接内外两个radius叠加即可,不需要更精确\n circleBounds(startAngle, endAngle, outerRadius, aabbBounds);\n circleBounds(startAngle, endAngle, innerRadius, aabbBounds);\n }\n\n return aabbBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n const attribute = this.attribute;\n const { startAngle, endAngle } = this.getParsedAngle();\n let innerRadius = attribute.innerRadius - (attribute.innerPadding || 0);\n let outerRadius = attribute.outerRadius - (attribute.outerPadding || 0);\n const deltaAngle = abs(endAngle - startAngle);\n const clockwise: boolean = endAngle > startAngle;\n\n if (outerRadius < innerRadius) {\n const temp = outerRadius;\n outerRadius = innerRadius;\n innerRadius = temp;\n }\n\n const path = new CustomPath2D();\n\n if (outerRadius <= epsilon) {\n path.moveTo(x, y);\n } else if (deltaAngle >= pi2 - epsilon) {\n // 是个完整的圆环\n // Or is it a circle or annulus?\n path.moveTo(x + outerRadius * cos(startAngle), y + outerRadius * sin(startAngle));\n path.arc(x, y, outerRadius, startAngle, endAngle, !clockwise);\n if (innerRadius > epsilon) {\n path.moveTo(x + innerRadius * cos(endAngle), y + innerRadius * sin(endAngle));\n path.arc(x, y, innerRadius, endAngle, startAngle, clockwise);\n }\n } else {\n const xors = outerRadius * cos(startAngle);\n const yors = outerRadius * sin(startAngle);\n const xire = innerRadius * cos(endAngle);\n const yire = innerRadius * sin(endAngle);\n\n path.moveTo(x + xors, y + yors);\n path.arc(x, y, outerRadius, startAngle, endAngle, !clockwise);\n path.lineTo(x + xire, y + yire);\n path.arc(x, y, innerRadius, endAngle, startAngle, clockwise);\n path.closePath();\n }\n\n return path;\n }\n\n clone() {\n return new Arc({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Arc.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createArc(attributes: IArcGraphicAttribute): IArc {\n return new Arc(attributes);\n}\n\n// addAttributeToPrototype(DefaultCircleStyle, Circle, PURE_STYLE_KEY);\n"]}
1
+ {"version":3,"sources":["../src/graphic/arc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElH,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAmB9F,MAAM,kBAAkB,GAAG;IACzB,aAAa;IACb,aAAa;IACb,YAAY;IACZ,UAAU;IACV,cA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U,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;YAC7D,IAAI,CAAC,SAAS,EAAE,CAAC;SAClB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,IAAI,GAAG,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;IACxC,CAAC;IAED,oBAAoB;QAClB,OAAO,GAAG,CAAC,mBAAmB,CAAC;IACjC,CAAC;;AA1VM,uBAAmB,mBACxB,GAAG,EAAE,CAAC,IACH,mBAAmB,EACtB;AA0VJ,MAAM,UAAU,SAAS,CAAC,UAAgC;IACxD,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","file":"arc.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { pi2, sin, epsilon, abs, asin, clampAngleByRadian, isNumber, cos, sqrt, isArray } from '@visactor/vutils';\nimport type { IArc, IArcGraphicAttribute } from '../interface/graphic/arc';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { CustomPath2D } from '../common/custom-path2d';\nimport { circleBounds } from '../common/utils';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport type { GraphicType } from '../interface';\nimport { ARC_NUMBER_TYPE } from './constants';\nimport { updateBoundsOfCommonOuterBorder } from './graphic-service/common-outer-boder-bounds';\n\n/**\n * 部分代码参考 https://github.com/d3/d3-shape/\n * Copyright 2010-2022 Mike Bostock\n\n Permission to use, copy, modify, and/or distribute this software for any purpose\n with or without fee is hereby granted, provided that the above copyright notice\n and this permission notice appear in all copies.\n\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\n FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\n THIS SOFTWARE.\n */\n\nconst ARC_UPDATE_TAG_KEY = [\n 'innerRadius',\n 'outerRadius',\n 'startAngle',\n 'endAngle',\n 'cornerRadius',\n 'padAngle',\n 'padRadius',\n 'cap',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\n/**\n * 圆形图元\n * 默认顺时针绘制\n */\nexport class Arc extends Graphic<IArcGraphicAttribute> implements IArc {\n type: GraphicType = 'arc';\n\n static NOWORK_ANIMATE_ATTR = {\n cap: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n // static parseCornerRadius(r: IArcGraphicAttribute['cornerRadius']) {\n // if (isArray(r)) {\n // if ((r as any[]).length === 1) {\n // const value = r[0];\n // return [value, value, value, value];\n // }\n\n // if ((r as any[]).length === 2) {\n // return [r[0], r[0], r[1], r[1]];\n // }\n\n // if ((r as any[]).length === 3) {\n // return [r[0], r[1], r[2], 0];\n // }\n\n // return (r as any[]).slice(0, 4);\n // }\n\n // return [r as string | number, r as string | number, r as string | number, r as string | number];\n // }\n\n // static isCornerRadiusEqual(oldR: IArcGraphicAttribute['cornerRadius'], newR: IArcGraphicAttribute['cornerRadius']) {\n // throw new Error('暂不支持');\n // if (oldR === newR) {\n // return true;\n // }\n\n // if (isArray(oldR) && !isArray(newR)) {\n // return (oldR as (string | number)[]).every(r => r === newR);\n // }\n\n // if (!isArray(oldR) && isArray(newR)) {\n // return (newR as (string | number)[]).every(r => r === oldR);\n // }\n\n // return arrayEqual(oldR as (string | number)[], newR as (string | number)[]);\n // }\n\n constructor(params: IArcGraphicAttribute) {\n super(params);\n this.numberType = ARC_NUMBER_TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n private _isValid(): boolean {\n const { startAngle, endAngle, outerRadius, innerRadius } = this.attribute;\n return (\n this._validNumber(startAngle) &&\n this._validNumber(endAngle) &&\n this._validNumber(outerRadius) &&\n this._validNumber(innerRadius)\n );\n }\n\n getParsedCornerRadius() {\n const arcTheme = this.getGraphicTheme();\n const {\n cornerRadius = arcTheme.cornerRadius,\n innerPadding = arcTheme.innerPadding,\n outerPadding = arcTheme.outerPadding\n } = this.attribute;\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (cornerRadius === 0 || cornerRadius === '0%') {\n return 0;\n }\n const deltaRadius = Math.abs(outerRadius - innerRadius);\n const parseCR = (cornerRadius: number | string) => {\n return Math.min(\n isNumber(cornerRadius, true)\n ? (cornerRadius as number)\n : (deltaRadius * parseFloat(cornerRadius as string)) / 100,\n deltaRadius / 2\n );\n };\n if (isArray(cornerRadius)) {\n const crList = cornerRadius.map(cr => parseCR(cr) || 0);\n if (crList.length === 0) {\n return [crList[0], crList[0], crList[0], crList[0]];\n } else if (crList.length === 2) {\n return [crList[0], crList[1], crList[0], crList[1]];\n } else if (crList.length === 3) {\n crList.push(0);\n }\n return crList;\n }\n return parseCR(cornerRadius);\n }\n\n getParsedAngle() {\n const arcTheme = this.getGraphicTheme();\n let { startAngle = arcTheme.startAngle, endAngle = arcTheme.endAngle } = this.attribute;\n const { cap = arcTheme.cap } = this.attribute;\n\n const sign = endAngle - startAngle >= 0 ? 1 : -1;\n const deltaAngle = endAngle - startAngle;\n\n startAngle = clampAngleByRadian(startAngle);\n endAngle = startAngle + deltaAngle;\n\n if (cap && abs(deltaAngle) < pi2 - epsilon) {\n let startCap = 1;\n let endCap = 1;\n if ((cap as boolean[]).length) {\n startCap = Number((cap as boolean[])[0]);\n endCap = Number((cap as boolean[])[1]);\n }\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n const capWidth = Math.abs(outerRadius - innerRadius) / 2;\n // 以外边界长度为准\n const capAngle = capWidth / outerRadius;\n\n if (capWidth > epsilon && outerRadius > epsilon) {\n return {\n startAngle: startAngle - sign * capAngle * startCap,\n endAngle: endAngle + sign * capAngle * endCap,\n sc: sign * capAngle * startCap,\n ec: sign * capAngle * endCap\n };\n }\n }\n\n return {\n startAngle: startAngle,\n endAngle: endAngle\n };\n }\n\n // 参考 https://github.com/d3/d3-shape/blob/main/src/arc.js\n getParsePadAngle(startAngle: number, endAngle: number) {\n const arcTheme = this.getGraphicTheme();\n const {\n innerPadding = arcTheme.innerPadding,\n outerPadding = arcTheme.outerPadding,\n padAngle = arcTheme.padAngle\n } = this.attribute;\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = this.attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n\n const { padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius) } = this.attribute;\n const deltaAngle = abs(endAngle - startAngle);\n\n // Or is it a circular or annular sector?\n let outerStartAngle = startAngle;\n let outerEndAngle = endAngle;\n let innerStartAngle = startAngle;\n let innerEndAngle = endAngle;\n const halfPadAngle = padAngle / 2;\n let innerDeltaAngle = deltaAngle;\n let outerDeltaAngle = deltaAngle;\n\n // Apply padding? Note that since r1 ≥ r0, outerDeltaAngle ≥ innerDeltaAngle.\n if (halfPadAngle > epsilon && padRadius > epsilon) {\n const sign = endAngle > startAngle ? 1 : -1;\n\n let p0 = asin((Number(padRadius) / innerRadius) * sin(halfPadAngle));\n let p1 = asin((Number(padRadius) / outerRadius) * sin(halfPadAngle));\n if ((innerDeltaAngle -= p0 * 2) > epsilon) {\n p0 *= sign;\n innerStartAngle += p0;\n innerEndAngle -= p0;\n } else {\n innerDeltaAngle = 0;\n innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2;\n }\n if ((outerDeltaAngle -= p1 * 2) > epsilon) {\n p1 *= sign;\n outerStartAngle += p1;\n outerEndAngle -= p1;\n } else {\n outerDeltaAngle = 0;\n outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2;\n }\n\n return {\n outerStartAngle,\n outerEndAngle,\n innerStartAngle,\n innerEndAngle,\n innerDeltaAngle,\n outerDeltaAngle\n };\n }\n\n return {\n outerStartAngle,\n outerEndAngle,\n innerStartAngle,\n innerEndAngle,\n innerDeltaAngle,\n outerDeltaAngle\n };\n }\n\n getGraphicTheme(): Required<IArcGraphicAttribute> {\n return getTheme(this).arc;\n }\n\n protected updateAABBBounds(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds,\n full?: boolean\n ) {\n if (!this.updatePathProxyAABBBounds(aabbBounds)) {\n full\n ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds)\n : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds);\n }\n\n const { tb1, tb2 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1);\n aabbBounds.union(tb1);\n tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);\n\n const { lineJoin = arcTheme.lineJoin } = attribute;\n application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, lineJoin === 'miter', this);\n\n return aabbBounds;\n }\n\n protected updateArcAABBBoundsImprecise(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds\n ): IAABBBounds {\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (outerRadius < innerRadius) {\n outerRadius = innerRadius;\n }\n\n aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius);\n\n return aabbBounds;\n }\n protected updateArcAABBBoundsAccurate(\n attribute: IArcGraphicAttribute,\n arcTheme: Required<IArcGraphicAttribute>,\n aabbBounds: IAABBBounds\n ): IAABBBounds {\n let { outerRadius = arcTheme.outerRadius, innerRadius = arcTheme.innerRadius } = attribute;\n const { outerPadding = arcTheme.outerPadding, innerPadding = arcTheme.innerPadding } = attribute;\n outerRadius += outerPadding;\n innerRadius -= innerPadding;\n if (outerRadius < innerRadius) {\n // 不用解构,避免性能问题\n const temp = outerRadius;\n outerRadius = innerRadius;\n innerRadius = temp;\n }\n let { endAngle = arcTheme.endAngle, startAngle = arcTheme.startAngle } = attribute;\n\n if (startAngle > endAngle) {\n const temp = startAngle;\n startAngle = endAngle;\n endAngle = temp;\n }\n\n if (outerRadius <= epsilon) {\n aabbBounds.set(0, 0, 0, 0);\n } else if (Math.abs(endAngle - startAngle) > pi2 - epsilon) {\n aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius);\n } else {\n // 直接内外两个radius叠加即可,不需要更精确\n circleBounds(startAngle, endAngle, outerRadius, aabbBounds);\n circleBounds(startAngle, endAngle, innerRadius, aabbBounds);\n }\n\n return aabbBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);\n }\n\n toCustomPath() {\n const x = 0;\n const y = 0;\n\n const attribute = this.attribute;\n const { startAngle, endAngle } = this.getParsedAngle();\n let innerRadius = (attribute.innerRadius ?? 0) - (attribute.innerPadding ?? 0);\n let outerRadius = (attribute.outerRadius ?? 0) - (attribute.outerPadding ?? 0);\n const deltaAngle = abs(endAngle - startAngle);\n const clockwise: boolean = endAngle > startAngle;\n\n if (outerRadius < innerRadius) {\n const temp = outerRadius;\n outerRadius = innerRadius;\n innerRadius = temp;\n }\n\n const path = new CustomPath2D();\n\n if (outerRadius <= epsilon) {\n path.moveTo(x, y);\n } else if (deltaAngle >= pi2 - epsilon) {\n // 是个完整的圆环\n // Or is it a circle or annulus?\n path.moveTo(x + outerRadius * cos(startAngle), y + outerRadius * sin(startAngle));\n path.arc(x, y, outerRadius, startAngle, endAngle, !clockwise);\n if (innerRadius > epsilon) {\n path.moveTo(x + innerRadius * cos(endAngle), y + innerRadius * sin(endAngle));\n path.arc(x, y, innerRadius, endAngle, startAngle, clockwise);\n }\n } else {\n const xors = outerRadius * cos(startAngle);\n const yors = outerRadius * sin(startAngle);\n const xire = innerRadius * cos(endAngle);\n const yire = innerRadius * sin(endAngle);\n\n path.moveTo(x + xors, y + yors);\n path.arc(x, y, outerRadius, startAngle, endAngle, !clockwise);\n path.lineTo(x + xire, y + yire);\n path.arc(x, y, innerRadius, endAngle, startAngle, clockwise);\n path.closePath();\n }\n\n return path;\n }\n\n clone() {\n return new Arc({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Arc.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createArc(attributes: IArcGraphicAttribute): IArc {\n return new Arc(attributes);\n}\n\n// addAttributeToPrototype(DefaultCircleStyle, Circle, PURE_STYLE_KEY);\n"]}
@@ -80,7 +80,7 @@ export class Glyph extends Graphic {
80
80
  })), aabbBounds;
81
81
  }
82
82
  doUpdateAABBBounds() {
83
- this._AABBBounds.clear();
83
+ this.updateAABBBoundsStamp++, this._AABBBounds.clear();
84
84
  const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds);
85
85
  return this.clearUpdateBoundTag(), bounds;
86
86
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/glyph.ts"],"names":[],"mappings":"AACA,OAAO,EAA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AsB;QAChC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;YACvC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;gBAChC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;gBACrF,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;YAC7B,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;SAChF;aAAM;YACL,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,MAAM,KAAK,GAAG,IAAI,KAAK,mBAAM,IAAI,CAAC,SAAS,EAAG,CAAC;QAC/C,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oBAAoB;QAClB,OAAO,KAAK,CAAC,mBAAmB,CAAC;IACnC,CAAC;;AA7NM,yBAAmB,GAAG,mBAAmB,CAAC;AAgOnD,MAAM,UAAU,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","file":"glyph.js","sourcesContent":["import type { AABBBounds, IAABBBounds, IPointLike } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { GLYPH_NUMBER_TYPE } from './constants';\n\nexport class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {\n type: GraphicType = 'glyph';\n declare _onInit: (g: IGlyph) => void;\n declare _onUpdate: (g: IGlyph) => void;\n declare glyphStates?: Record<\n string,\n {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n }\n >;\n declare glyphStateProxy?: (\n stateName: string,\n targetStates?: string[]\n ) => {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n protected declare subGraphic: IGraphic[];\n\n static NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;\n\n constructor(params: Partial<IGlyphGraphicAttribute>) {\n super(params);\n this.numberType = GLYPH_NUMBER_TYPE;\n this.subGraphic = [];\n this._onInit && this._onInit(this);\n this.valid = this.isValid();\n }\n\n setSubGraphic(subGraphic: IGraphic[]) {\n this.detachSubGraphic();\n this.subGraphic = subGraphic;\n subGraphic.forEach(g => {\n g.glyphHost = this;\n Object.setPrototypeOf(g.attribute, this.attribute);\n });\n this.valid = this.isValid();\n this.addUpdateBoundTag();\n }\n\n protected detachSubGraphic() {\n this.subGraphic.forEach(g => {\n g.glyphHost = null;\n Object.setPrototypeOf(g.attribute, {});\n });\n }\n\n getSubGraphic() {\n return this.subGraphic;\n }\n\n onInit(cb: (g: this) => void): void {\n this._onInit = cb;\n }\n\n onUpdate(cb: (g: this) => void): void {\n this._onUpdate = cb;\n }\n\n isValid(): boolean {\n return true;\n }\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) {\n super.setAttribute(key, value, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n setAttributes(\n params: Partial<IGlyphGraphicAttribute>,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ) {\n super.setAttributes(params, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n translate(x: number, y: number) {\n super.translate(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n translateTo(x: number, y: number) {\n super.translateTo(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scale(scaleX: number, scaleY: number, scaleCenter?: IPointLike) {\n super.scale(scaleX, scaleY, scaleCenter);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scaleTo(scaleX: number, scaleY: number) {\n super.scaleTo(scaleX, scaleY);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotate(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotateTo(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n getGraphicTheme(): Required<IGlyphGraphicAttribute> {\n return getTheme(this as IGraphic).glyph;\n }\n\n protected updateAABBBounds(\n attribute: IGlyphGraphicAttribute,\n theme: Required<IGlyphGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n // 添加子节点\n this.getSubGraphic().forEach((node: IGraphic) => {\n aabbBounds.union(node.AABBBounds);\n });\n\n // glyph不需要计算AABBBounds\n // this.transformAABBBounds(attribute, aabbBounds, theme, graphic);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n this._AABBBounds.clear();\n const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds) as AABBBounds;\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n return false;\n }\n\n useStates(states: string[], hasAnimation?: boolean): void {\n if (!states.length) {\n this.clearStates(hasAnimation);\n return;\n }\n\n const isChange =\n this.currentStates?.length !== states.length ||\n states.some((stateName, index) => this.currentStates[index] !== stateName);\n if (!isChange) {\n return;\n }\n\n this.stopStateAnimates();\n\n const stateAttrs = {};\n const subAttrs = this.subGraphic.map(() => ({}));\n states.forEach(stateName => {\n const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];\n\n if (attrs) {\n Object.assign(stateAttrs, attrs.attributes);\n\n if (attrs.subAttributes?.length) {\n subAttrs.forEach((subAttrs, index) => {\n Object.assign(subAttrs, attrs.subAttributes[index]);\n });\n }\n }\n });\n\n this.subGraphic.forEach((graphic, index) => {\n graphic.updateNormalAttrs(subAttrs[index]);\n graphic.applyStateAttrs(subAttrs[index], states, hasAnimation);\n });\n\n this.updateNormalAttrs(stateAttrs);\n this.currentStates = states;\n this.applyStateAttrs(stateAttrs, states, hasAnimation);\n }\n\n clearStates(hasAnimation?: boolean) {\n this.stopStateAnimates();\n if (this.hasState() && this.normalAttrs) {\n this.currentStates = [];\n this.subGraphic.forEach(graphic => {\n graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, true);\n graphic.normalAttrs = null;\n });\n this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, true);\n } else {\n this.currentStates = [];\n }\n this.normalAttrs = null;\n }\n\n clone(): IGraphic<Partial<IGlyphGraphicAttribute>> {\n const glyph = new Glyph({ ...this.attribute });\n glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));\n return glyph;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Glyph.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph {\n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ounds, IPointLike } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { getTheme } from './theme';\nimport { application } from '../application';\nimport { GLYPH_NUMBER_TYPE } from './constants';\n\nexport class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {\n type: GraphicType = 'glyph';\n declare _onInit: (g: IGlyph) => void;\n declare _onUpdate: (g: IGlyph) => void;\n declare glyphStates?: Record<\n string,\n {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n }\n >;\n declare glyphStateProxy?: (\n stateName: string,\n targetStates?: string[]\n ) => {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n protected declare subGraphic: IGraphic[];\n\n static NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;\n\n constructor(params: Partial<IGlyphGraphicAttribute>) {\n super(params);\n this.numberType = GLYPH_NUMBER_TYPE;\n this.subGraphic = [];\n this._onInit && this._onInit(this);\n this.valid = this.isValid();\n }\n\n setSubGraphic(subGraphic: IGraphic[]) {\n this.detachSubGraphic();\n this.subGraphic = subGraphic;\n subGraphic.forEach(g => {\n g.glyphHost = this;\n Object.setPrototypeOf(g.attribute, this.attribute);\n });\n this.valid = this.isValid();\n this.addUpdateBoundTag();\n }\n\n protected detachSubGraphic() {\n this.subGraphic.forEach(g => {\n g.glyphHost = null;\n Object.setPrototypeOf(g.attribute, {});\n });\n }\n\n getSubGraphic() {\n return this.subGraphic;\n }\n\n onInit(cb: (g: this) => void): void {\n this._onInit = cb;\n }\n\n onUpdate(cb: (g: this) => void): void {\n this._onUpdate = cb;\n }\n\n isValid(): boolean {\n return true;\n }\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) {\n super.setAttribute(key, value, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n setAttributes(\n params: Partial<IGlyphGraphicAttribute>,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ) {\n super.setAttributes(params, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n translate(x: number, y: number) {\n super.translate(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n translateTo(x: number, y: number) {\n super.translateTo(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scale(scaleX: number, scaleY: number, scaleCenter?: IPointLike) {\n super.scale(scaleX, scaleY, scaleCenter);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scaleTo(scaleX: number, scaleY: number) {\n super.scaleTo(scaleX, scaleY);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotate(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotateTo(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n getGraphicTheme(): Required<IGlyphGraphicAttribute> {\n return getTheme(this as IGraphic).glyph;\n }\n\n protected updateAABBBounds(\n attribute: IGlyphGraphicAttribute,\n theme: Required<IGlyphGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n // 添加子节点\n this.getSubGraphic().forEach((node: IGraphic) => {\n aabbBounds.union(node.AABBBounds);\n });\n\n // glyph不需要计算AABBBounds\n // this.transformAABBBounds(attribute, aabbBounds, theme, graphic);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n this.updateAABBBoundsStamp++;\n this._AABBBounds.clear();\n const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds) as AABBBounds;\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n return false;\n }\n\n useStates(states: string[], hasAnimation?: boolean): void {\n if (!states.length) {\n this.clearStates(hasAnimation);\n return;\n }\n\n const isChange =\n this.currentStates?.length !== states.length ||\n states.some((stateName, index) => this.currentStates[index] !== stateName);\n if (!isChange) {\n return;\n }\n\n this.stopStateAnimates();\n\n const stateAttrs = {};\n const subAttrs = this.subGraphic.map(() => ({}));\n states.forEach(stateName => {\n const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];\n\n if (attrs) {\n Object.assign(stateAttrs, attrs.attributes);\n\n if (attrs.subAttributes?.length) {\n subAttrs.forEach((subAttrs, index) => {\n Object.assign(subAttrs, attrs.subAttributes[index]);\n });\n }\n }\n });\n\n this.subGraphic.forEach((graphic, index) => {\n graphic.updateNormalAttrs(subAttrs[index]);\n graphic.applyStateAttrs(subAttrs[index], states, hasAnimation);\n });\n\n this.updateNormalAttrs(stateAttrs);\n this.currentStates = states;\n this.applyStateAttrs(stateAttrs, states, hasAnimation);\n }\n\n clearStates(hasAnimation?: boolean) {\n this.stopStateAnimates();\n if (this.hasState() && this.normalAttrs) {\n this.currentStates = [];\n this.subGraphic.forEach(graphic => {\n graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, true);\n graphic.normalAttrs = null;\n });\n this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, true);\n } else {\n this.currentStates = [];\n }\n this.normalAttrs = null;\n }\n\n clone(): IGraphic<Partial<IGlyphGraphicAttribute>> {\n const glyph = new Glyph({ ...this.attribute });\n glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));\n return glyph;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Glyph.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph {\n return new Glyph(attributes);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { ICustomPath2D } from './../interface/path';
2
- import type { Dict, IPointLike, IAABBBounds } from '@visactor/vutils';
2
+ import type { Dict, IPointLike, IAABBBounds, IOBBBounds } from '@visactor/vutils';
3
3
  import { Matrix, Point } from '@visactor/vutils';
4
4
  import type { GraphicType, IAnimateConfig, IGraphicAttribute, IGraphic, IGraphicAnimateParams, IGraphicJson, ISetAttributeContext, ITransform, GraphicReleaseStatus } from '../interface/graphic';
5
5
  import { Node } from './node-tree';
@@ -61,6 +61,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
61
61
  in3dMode?: boolean;
62
62
  protected _AABBBounds: IAABBBounds;
63
63
  get AABBBounds(): IAABBBounds;
64
+ protected _OBBBounds?: IOBBBounds;
65
+ get OBBBounds(): IOBBBounds;
64
66
  protected _globalAABBBounds: IAABBBounds;
65
67
  get globalAABBBounds(): IAABBBounds;
66
68
  protected _transMatrix: Matrix;
@@ -83,6 +85,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
83
85
  finalAttrs?: T;
84
86
  pathProxy?: ICustomPath2D;
85
87
  attachedThemeGraphic?: IGraphic;
88
+ protected updateAABBBoundsStamp: number;
89
+ protected updateOBBBoundsStamp?: number;
86
90
  constructor(params?: T);
87
91
  setMode(mode: '2d' | '3d'): void;
88
92
  set3dMode(): void;
@@ -90,8 +94,10 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
90
94
  getOffsetXY(attr?: ITransform, includeScroll?: boolean): Point;
91
95
  onAnimateBind(animate: IAnimate | ISubAnimate): void;
92
96
  protected tryUpdateAABBBounds(full?: boolean): IAABBBounds;
97
+ protected tryUpdateOBBBounds(): IOBBBounds;
93
98
  protected combindShadowAABBBounds(bounds: IAABBBounds): void;
94
99
  abstract getGraphicTheme(): T;
100
+ protected doUpdateOBBBounds(): IOBBBounds;
95
101
  protected abstract updateAABBBounds(attribute: T, symbolTheme: Required<T>, aabbBounds: IAABBBounds, full?: boolean): IAABBBounds;
96
102
  protected doUpdateAABBBounds(full?: boolean): IAABBBounds;
97
103
  updatePathProxyAABBBounds(aabbBounds: IAABBBounds): boolean;
@@ -1,3 +1,5 @@
1
+ import { OBBBounds } from "@visactor/vutils";
2
+
1
3
  import { AABBBounds, Matrix, normalTransform, Point, isNil, has, isString, isValidUrl, isBase64, isObject } from "@visactor/vutils";
2
4
 
3
5
  import { Node } from "./node-tree";
@@ -74,6 +76,9 @@ export class Graphic extends Node {
74
76
  get AABBBounds() {
75
77
  return this.tryUpdateAABBBounds("imprecise" === this.attribute.boundsMode);
76
78
  }
79
+ get OBBBounds() {
80
+ return this.tryUpdateOBBBounds();
81
+ }
77
82
  get globalAABBBounds() {
78
83
  return this.tryUpdateGlobalAABBBounds();
79
84
  }
@@ -86,7 +91,7 @@ export class Graphic extends Node {
86
91
  constructor(params = {}) {
87
92
  var _a;
88
93
  super(), this._AABBBounds = new AABBBounds, this._updateTag = UpdateTag.INIT, this.attribute = params,
89
- this.valid = this.isValid(), params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
94
+ this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background ? this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
90
95
  }
91
96
  setMode(mode) {
92
97
  "3d" === mode ? this.set3dMode() : this.set2dMode();
@@ -117,13 +122,24 @@ export class Graphic extends Node {
117
122
  return application.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0),
118
123
  bounds;
119
124
  }
125
+ tryUpdateOBBBounds() {
126
+ if (this._OBBBounds || (this._OBBBounds = new OBBBounds), this.tryUpdateAABBBounds(),
127
+ this.updateOBBBoundsStamp === this.updateAABBBoundsStamp) return this._OBBBounds;
128
+ if (this.updateOBBBoundsStamp = this.updateAABBBoundsStamp, !this.valid) return this._OBBBounds.clear(),
129
+ this._OBBBounds;
130
+ return this.doUpdateOBBBounds();
131
+ }
120
132
  combindShadowAABBBounds(bounds) {
121
133
  if (this.shadowRoot) {
122
134
  const b = this.shadowRoot.AABBBounds.clone();
123
135
  bounds.union(b);
124
136
  }
125
137
  }
138
+ doUpdateOBBBounds() {
139
+ return this._OBBBounds;
140
+ }
126
141
  doUpdateAABBBounds(full) {
142
+ this.updateAABBBoundsStamp++;
127
143
  const graphicTheme = this.getGraphicTheme();
128
144
  this._AABBBounds.clear();
129
145
  const attribute = this.attribute, bounds = this.updateAABBBounds(attribute, graphicTheme, this._AABBBounds, full), {boundsPadding: boundsPadding = graphicTheme.boundsPadding} = attribute, paddingArray = parsePadding(boundsPadding);