@visactor/vrender-core 1.0.13-alpha.1 → 1.0.14-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/cjs/common/color-utils.d.ts +9 -0
  2. package/cjs/common/color-utils.js +29 -12
  3. package/cjs/common/color-utils.js.map +1 -1
  4. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +1 -0
  5. package/cjs/core/contributions/textMeasure/AtextMeasure.js +3 -0
  6. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  7. package/cjs/core/contributions/textMeasure/textMeasure-contribution.d.ts +1 -0
  8. package/cjs/core/contributions/textMeasure/textMeasure-contribution.js +5 -1
  9. package/cjs/core/contributions/textMeasure/textMeasure-contribution.js.map +1 -1
  10. package/cjs/core/graphic-utils.d.ts +2 -0
  11. package/cjs/core/graphic-utils.js +7 -2
  12. package/cjs/core/graphic-utils.js.map +1 -1
  13. package/cjs/graphic/graphic.d.ts +1 -0
  14. package/cjs/graphic/graphic.js.map +1 -1
  15. package/cjs/graphic/richtext.js +2 -1
  16. package/cjs/graphic/richtext.js.map +1 -1
  17. package/cjs/graphic/text.js +9 -9
  18. package/cjs/graphic/text.js.map +1 -1
  19. package/cjs/graphic/wrap-text.js +3 -3
  20. package/cjs/graphic/wrap-text.js.map +1 -1
  21. package/cjs/index.d.ts +1 -0
  22. package/cjs/index.js +15 -14
  23. package/cjs/index.js.map +1 -1
  24. package/cjs/interface/core.d.ts +1 -0
  25. package/cjs/interface/core.js.map +1 -1
  26. package/cjs/interface/text.d.ts +1 -0
  27. package/cjs/interface/text.js.map +1 -1
  28. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +18 -4
  29. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  30. package/dist/index.es.js +96 -38
  31. package/es/common/color-utils.d.ts +9 -0
  32. package/es/common/color-utils.js +29 -12
  33. package/es/common/color-utils.js.map +1 -1
  34. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +1 -0
  35. package/es/core/contributions/textMeasure/AtextMeasure.js +3 -0
  36. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  37. package/es/core/contributions/textMeasure/textMeasure-contribution.d.ts +1 -0
  38. package/es/core/contributions/textMeasure/textMeasure-contribution.js +5 -1
  39. package/es/core/contributions/textMeasure/textMeasure-contribution.js.map +1 -1
  40. package/es/core/graphic-utils.d.ts +2 -0
  41. package/es/core/graphic-utils.js +7 -2
  42. package/es/core/graphic-utils.js.map +1 -1
  43. package/es/graphic/graphic.d.ts +1 -0
  44. package/es/graphic/graphic.js.map +1 -1
  45. package/es/graphic/richtext.js +2 -1
  46. package/es/graphic/richtext.js.map +1 -1
  47. package/es/graphic/text.js +9 -9
  48. package/es/graphic/text.js.map +1 -1
  49. package/es/graphic/wrap-text.js +3 -3
  50. package/es/graphic/wrap-text.js.map +1 -1
  51. package/es/index.d.ts +1 -0
  52. package/es/index.js +2 -0
  53. package/es/index.js.map +1 -1
  54. package/es/interface/core.d.ts +1 -0
  55. package/es/interface/core.js.map +1 -1
  56. package/es/interface/text.d.ts +1 -0
  57. package/es/interface/text.js.map +1 -1
  58. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +18 -4
  59. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  60. package/package.json +3 -3
package/dist/index.es.js CHANGED
@@ -3821,6 +3821,48 @@ class GradientParser {
3821
3821
  }
3822
3822
  return c;
3823
3823
  }
3824
+ static processColorStops(colorStops) {
3825
+ if (!colorStops || colorStops.length === 0) {
3826
+ return [];
3827
+ }
3828
+ const anyStopHasLength = colorStops.some((item) => item.length);
3829
+ if (anyStopHasLength) {
3830
+ const stops = colorStops.map((item) => ({
3831
+ color: item.value,
3832
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
3833
+ }));
3834
+ if (stops[0].offset < 0) {
3835
+ stops[0].offset = 0;
3836
+ }
3837
+ if (stops[stops.length - 1].offset < 0) {
3838
+ stops[stops.length - 1].offset = 1;
3839
+ }
3840
+ for (let i = 1; i < stops.length - 1; i++) {
3841
+ if (stops[i].offset < 0) {
3842
+ const prevWithOffsetIdx = i - 1;
3843
+ let nextWithOffsetIdx = i + 1;
3844
+ while (nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0) {
3845
+ nextWithOffsetIdx++;
3846
+ }
3847
+ const startOffset = stops[prevWithOffsetIdx].offset;
3848
+ const endOffset = stops[nextWithOffsetIdx].offset;
3849
+ const unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
3850
+ for (let j = 1; j < unspecCount; j++) {
3851
+ stops[prevWithOffsetIdx + j].offset = startOffset + ((endOffset - startOffset) * j) / unspecCount;
3852
+ }
3853
+ i = nextWithOffsetIdx - 1;
3854
+ }
3855
+ }
3856
+ return stops;
3857
+ }
3858
+ return colorStops.map((item, index) => {
3859
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
3860
+ return {
3861
+ color: item.value,
3862
+ offset
3863
+ };
3864
+ });
3865
+ }
3824
3866
  static ParseConic(datum) {
3825
3867
  const { orientation, colorStops = [] } = datum;
3826
3868
  const halfPi = pi / 2;
@@ -3831,12 +3873,7 @@ class GradientParser {
3831
3873
  y: 0.5,
3832
3874
  startAngle: sa,
3833
3875
  endAngle: sa + pi2,
3834
- stops: colorStops.map((item) => {
3835
- return {
3836
- color: item.value,
3837
- offset: parseFloat(item.length.value) / 100
3838
- };
3839
- })
3876
+ stops: GradientParser.processColorStops(colorStops)
3840
3877
  };
3841
3878
  }
3842
3879
  static ParseRadial(datum) {
@@ -3849,12 +3886,7 @@ class GradientParser {
3849
3886
  y1: 0.5,
3850
3887
  r0: 0,
3851
3888
  r1: 1,
3852
- stops: colorStops.map((item) => {
3853
- return {
3854
- color: item.value,
3855
- offset: parseFloat(item.length.value) / 100
3856
- };
3857
- })
3889
+ stops: GradientParser.processColorStops(colorStops)
3858
3890
  };
3859
3891
  }
3860
3892
  static ParseLinear(datum) {
@@ -3900,12 +3932,7 @@ class GradientParser {
3900
3932
  y0,
3901
3933
  x1,
3902
3934
  y1,
3903
- stops: colorStops.map((item) => {
3904
- return {
3905
- color: item.value,
3906
- offset: parseFloat(item.length.value) / 100
3907
- };
3908
- })
3935
+ stops: GradientParser.processColorStops(colorStops)
3909
3936
  };
3910
3937
  }
3911
3938
  }
@@ -4198,6 +4225,9 @@ function measureTextCanvas(text, character, mode = 'actual') {
4198
4225
  }
4199
4226
 
4200
4227
  let ATextMeasure = class ATextMeasure {
4228
+ constructor() {
4229
+ this.id = 'ATextMeasure';
4230
+ }
4201
4231
  configure(service, env) {
4202
4232
  this.canvas = service.canvas;
4203
4233
  this.context = service.context;
@@ -4655,6 +4685,10 @@ ATextMeasure = __decorate([
4655
4685
 
4656
4686
  const TextMeasureContribution = Symbol.for('TextMeasureContribution');
4657
4687
  let DefaultTextMeasureContribution = class DefaultTextMeasureContribution extends ATextMeasure {
4688
+ constructor() {
4689
+ super(...arguments);
4690
+ this.id = 'DefaultTextMeasureContribution';
4691
+ }
4658
4692
  };
4659
4693
  DefaultTextMeasureContribution = __decorate([
4660
4694
  injectable()
@@ -5589,6 +5623,7 @@ let DefaultGraphicUtil = class DefaultGraphicUtil {
5589
5623
  this.contributions = contributions;
5590
5624
  this.configured = false;
5591
5625
  this.global = application.global;
5626
+ this._textMeasureMap = new Map();
5592
5627
  this.global.hooks.onSetEnv.tap('graphic-util', (lastEnv, env, global) => {
5593
5628
  this.configured = false;
5594
5629
  this.configure(global, env);
@@ -5600,6 +5635,13 @@ let DefaultGraphicUtil = class DefaultGraphicUtil {
5600
5635
  }
5601
5636
  return this._textMeasure;
5602
5637
  }
5638
+ getTextMeasureInstance(textMeasureId) {
5639
+ if (!textMeasureId) {
5640
+ return this.textMeasure;
5641
+ }
5642
+ const tm = this._textMeasureMap.get(textMeasureId);
5643
+ return tm || this.textMeasure;
5644
+ }
5603
5645
  configure(global, env) {
5604
5646
  if (this.configured) {
5605
5647
  return;
@@ -5617,7 +5659,12 @@ let DefaultGraphicUtil = class DefaultGraphicUtil {
5617
5659
  }
5618
5660
  }
5619
5661
  bindTextMeasure(tm) {
5620
- this._textMeasure = tm;
5662
+ if (!this._textMeasure || tm.id === 'DefaultTextMeasureContribution') {
5663
+ this._textMeasure = tm;
5664
+ }
5665
+ if (!this._textMeasureMap.has(tm.id)) {
5666
+ this._textMeasureMap.set(tm.id, tm);
5667
+ }
5621
5668
  }
5622
5669
  measureText(text, tc, method = 'native') {
5623
5670
  var _a;
@@ -13645,7 +13692,7 @@ class Text extends Graphic {
13645
13692
  return fontSize ? fontSize * 0.1 : 0;
13646
13693
  }
13647
13694
  updateHorizontalMultilineAABBBounds(text) {
13648
- var _a;
13695
+ var _a, _b;
13649
13696
  const textTheme = this.getGraphicTheme();
13650
13697
  const attribute = this.attribute;
13651
13698
  const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, measureMode = textTheme.measureMode, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition, ignoreBuf = textTheme.ignoreBuf, keepCenterInLine = textTheme.keepCenterInLine } = attribute;
@@ -13662,7 +13709,7 @@ class Text extends Graphic {
13662
13709
  }
13663
13710
  return this._AABBBounds;
13664
13711
  }
13665
- const textMeasure = application.graphicUtil.textMeasure;
13712
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_b = this.stage) === null || _b === void 0 ? void 0 : _b.textMeasureId));
13666
13713
  const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily, lineHeight }, textMeasure);
13667
13714
  const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, {
13668
13715
  lineWidth: maxLineWidth,
@@ -13680,7 +13727,7 @@ class Text extends Graphic {
13680
13727
  return this._AABBBounds;
13681
13728
  }
13682
13729
  updateWrapAABBBounds(text) {
13683
- var _a, _b, _c;
13730
+ var _a, _b, _c, _d;
13684
13731
  const textTheme = this.getGraphicTheme();
13685
13732
  const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, measureMode = textTheme.measureMode, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp, keepCenterInLine = textTheme.keepCenterInLine } = this.attribute;
13686
13733
  const buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize);
@@ -13693,7 +13740,7 @@ class Text extends Graphic {
13693
13740
  }
13694
13741
  return this._AABBBounds;
13695
13742
  }
13696
- const textMeasure = application.graphicUtil.textMeasure;
13743
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_b = this.stage) === null || _b === void 0 ? void 0 : _b.textMeasureId));
13697
13744
  const textOptions = { fontSize, fontWeight, fontFamily, lineHeight };
13698
13745
  const layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure);
13699
13746
  const lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()];
@@ -13727,8 +13774,8 @@ class Text extends Graphic {
13727
13774
  if ((str !== '' && clip.str === '') || clip.wordBreaked) {
13728
13775
  if (ellipsis) {
13729
13776
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, false, suffixPosition);
13730
- clip.str = (_b = clipEllipsis.str) !== null && _b !== void 0 ? _b : '';
13731
- clip.width = (_c = clipEllipsis.width) !== null && _c !== void 0 ? _c : 0;
13777
+ clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
13778
+ clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
13732
13779
  }
13733
13780
  else {
13734
13781
  clip.str = '';
@@ -13809,9 +13856,9 @@ class Text extends Graphic {
13809
13856
  return this._AABBBounds;
13810
13857
  }
13811
13858
  updateVerticalMultilineAABBBounds(text) {
13812
- var _a, _b;
13859
+ var _a, _b, _c;
13813
13860
  const textTheme = this.getGraphicTheme();
13814
- const textMeasure = application.graphicUtil.textMeasure;
13861
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_a = this.stage) === null || _a === void 0 ? void 0 : _a.textMeasureId));
13815
13862
  let width;
13816
13863
  const attribute = this.attribute;
13817
13864
  const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode, suffixPosition = textTheme.suffixPosition } = attribute;
@@ -13819,8 +13866,8 @@ class Text extends Graphic {
13819
13866
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
13820
13867
  if (!verticalMode) {
13821
13868
  const t = textAlign;
13822
- textAlign = (_a = Text.baselineMapAlign[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
13823
- textBaseline = (_b = Text.alignMapBaseline[t]) !== null && _b !== void 0 ? _b : 'top';
13869
+ textAlign = (_b = Text.baselineMapAlign[textBaseline]) !== null && _b !== void 0 ? _b : 'left';
13870
+ textBaseline = (_c = Text.alignMapBaseline[t]) !== null && _c !== void 0 ? _c : 'top';
13824
13871
  }
13825
13872
  width = 0;
13826
13873
  if (!this.shouldUpdateShape() && this.cache) {
@@ -13941,7 +13988,7 @@ class WrapText extends Text {
13941
13988
  return text != null && text !== '';
13942
13989
  }
13943
13990
  updateMultilineAABBBounds(text) {
13944
- var _a, _b, _c, _d;
13991
+ var _a, _b, _c, _d, _e;
13945
13992
  const textTheme = this.getGraphicTheme();
13946
13993
  const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, suffixPosition = textTheme.suffixPosition, lineClamp } = this.attribute;
13947
13994
  const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
@@ -13954,7 +14001,7 @@ class WrapText extends Text {
13954
14001
  }
13955
14002
  return this._AABBBounds;
13956
14003
  }
13957
- const textMeasure = application.graphicUtil.textMeasure;
14004
+ const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_c = this.stage) === null || _c === void 0 ? void 0 : _c.textMeasureId));
13958
14005
  const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
13959
14006
  const lines = text.map(l => l.toString());
13960
14007
  const linesLayout = [];
@@ -13986,8 +14033,8 @@ class WrapText extends Text {
13986
14033
  if (str !== '' && clip.str === '') {
13987
14034
  if (ellipsis) {
13988
14035
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false, suffixPosition);
13989
- clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
13990
- clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
14036
+ clip.str = (_d = clipEllipsis.str) !== null && _d !== void 0 ? _d : '';
14037
+ clip.width = (_e = clipEllipsis.width) !== null && _e !== void 0 ? _e : 0;
13991
14038
  }
13992
14039
  else {
13993
14040
  clip.str = '';
@@ -15961,6 +16008,14 @@ class RichText extends Graphic {
15961
16008
  deltaX = -aabbBounds.width();
15962
16009
  break;
15963
16010
  }
16011
+ if (!height) {
16012
+ if (this.verticalDirection === 'middle') {
16013
+ deltaY -= aabbBounds.height() / 2;
16014
+ }
16015
+ else if (this.verticalDirection === 'bottom') {
16016
+ deltaY -= aabbBounds.height();
16017
+ }
16018
+ }
15964
16019
  aabbBounds.translate(deltaX, deltaY);
15965
16020
  application.graphicService.updateTempAABBBounds(aabbBounds);
15966
16021
  if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {
@@ -25478,6 +25533,7 @@ class RichTextEditPlugin {
25478
25533
  return rt.AABBBounds;
25479
25534
  }
25480
25535
  tryShowInputBounds() {
25536
+ var _a, _b;
25481
25537
  if (!(this.currRt && this.focusing)) {
25482
25538
  return;
25483
25539
  }
@@ -25494,6 +25550,8 @@ class RichTextEditPlugin {
25494
25550
  this.shadowBounds.setAttributes({
25495
25551
  x: 0,
25496
25552
  y: 0,
25553
+ scaleX: 1 / ((_a = this.currRt.attribute.scaleX) !== null && _a !== void 0 ? _a : 1),
25554
+ scaleY: 1 / ((_b = this.currRt.attribute.scaleY) !== null && _b !== void 0 ? _b : 1),
25497
25555
  width,
25498
25556
  height,
25499
25557
  fill: false,
@@ -25592,7 +25650,7 @@ class RichTextEditPlugin {
25592
25650
  else {
25593
25651
  const x = 0;
25594
25652
  const y1 = 0;
25595
- const y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), { textConfig: [{ text: 'a' }] })).height();
25653
+ const y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), { textConfig: [{ text: 'a' }], scaleX: 1, scaleY: 1 })).height();
25596
25654
  this.startCursorPos = { x, y: (y1 + y2) / 2 };
25597
25655
  this.curCursorIdx = -0.1;
25598
25656
  this.selectionStartCursorIdx = -0.1;
@@ -25629,7 +25687,7 @@ class RichTextEditPlugin {
25629
25687
  if (!attr.textConfig.length) {
25630
25688
  attr = Object.assign(Object.assign({}, attr), { textConfig: [{ text: 'a' }] });
25631
25689
  }
25632
- b = getRichTextBounds(attr);
25690
+ b = getRichTextBounds(Object.assign(Object.assign({}, attr), { scaleX: 1, scaleY: 1 }));
25633
25691
  }
25634
25692
  if (textBaseline === 'middle') {
25635
25693
  dy = -b.height() / 2;
@@ -25920,11 +25978,11 @@ class RichTextEditPlugin {
25920
25978
  const { textBaseline } = rt.attribute;
25921
25979
  let dy = 0;
25922
25980
  if (textBaseline === 'middle') {
25923
- const b = getRichTextBounds(rt.attribute);
25981
+ const b = getRichTextBounds(Object.assign(Object.assign({}, rt.attribute), { scaleX: 1, scaleY: 1 }));
25924
25982
  dy = b.height() / 2;
25925
25983
  }
25926
25984
  else if (textBaseline === 'bottom') {
25927
- const b = getRichTextBounds(rt.attribute);
25985
+ const b = getRichTextBounds(Object.assign(Object.assign({}, rt.attribute), { scaleX: 1, scaleY: 1 }));
25928
25986
  dy = b.height();
25929
25987
  }
25930
25988
  p1.y += dy;
@@ -27938,4 +27996,4 @@ const registerFlexLayoutPlugin = () => {
27938
27996
  Factory.registerPlugin('FlexLayoutPlugin', FlexLayoutPlugin);
27939
27997
  };
27940
27998
 
27941
- export { ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, Circle, CircleRender, CircleRenderContribution, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, ContributionStore, CubicBezierCurve, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncrementalDrawContribution, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Mat4Allocate, MatrixAllocate, MeasureModeEnum, MonotoneX, MonotoneY, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PerformanceRAF, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, STAR_NUMBER_TYPE, STATUS$1 as STATUS, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step, StepClosed, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCanvasEventTransformer, createCircle, createColor, createConicalGradient, createEventTransformer, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, diff, divideCubic, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepClosedSegments, genStepSegments, genStepTypeSegments, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, interpolatePureColorArrayToStr, intersect, isBrowserEnv, isNodeEnv, isSvg, isXML, layerService, lineModule, lookAt, mapToCanvasPointForCanvas, mat3Tomat4, mat4Allocate, matrixAllocate, multiInject, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlobalEventTransformer, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWindowEventTransformer, registerWrapTextGraphic, renderCommandList, renderService, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformMat4, transformPointForCanvas, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
27999
+ export { ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, Circle, CircleRender, CircleRenderContribution, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, ContributionStore, CubicBezierCurve, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, GradientParser, Graphic, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncrementalDrawContribution, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Mat4Allocate, MatrixAllocate, MeasureModeEnum, MonotoneX, MonotoneY, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PerformanceRAF, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, STAR_NUMBER_TYPE, STATUS$1 as STATUS, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step, StepClosed, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCanvasEventTransformer, createCircle, createColor, createConicalGradient, createEventTransformer, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, diff, divideCubic, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepClosedSegments, genStepSegments, genStepTypeSegments, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, interpolatePureColorArrayToStr, intersect, isBrowserEnv, isNodeEnv, isSvg, isXML, layerService, lineModule, lookAt, mapToCanvasPointForCanvas, mat3Tomat4, mat4Allocate, matrixAllocate, multiInject, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlobalEventTransformer, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWindowEventTransformer, registerWrapTextGraphic, renderCommandList, renderService, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformMat4, transformPointForCanvas, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
@@ -3,6 +3,15 @@ export declare class GradientParser {
3
3
  static IsGradient(c: IColor): boolean;
4
4
  static IsGradientStr(c: IColor): boolean;
5
5
  static Parse(c: IColor): IColor;
6
+ static processColorStops(colorStops: Array<{
7
+ value: string;
8
+ length?: {
9
+ value: string;
10
+ };
11
+ }>): {
12
+ color: string;
13
+ offset: number;
14
+ }[];
6
15
  private static ParseConic;
7
16
  private static ParseRadial;
8
17
  private static ParseLinear;
@@ -169,6 +169,32 @@ export class GradientParser {
169
169
  }
170
170
  return c;
171
171
  }
172
+ static processColorStops(colorStops) {
173
+ if (!colorStops || 0 === colorStops.length) return [];
174
+ if (colorStops.some((item => item.length))) {
175
+ const stops = colorStops.map((item => ({
176
+ color: item.value,
177
+ offset: item.length ? parseFloat(item.length.value) / 100 : -1
178
+ })));
179
+ stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
180
+ for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
181
+ const prevWithOffsetIdx = i - 1;
182
+ let nextWithOffsetIdx = i + 1;
183
+ for (;nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0; ) nextWithOffsetIdx++;
184
+ const startOffset = stops[prevWithOffsetIdx].offset, endOffset = stops[nextWithOffsetIdx].offset, unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
185
+ for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
186
+ i = nextWithOffsetIdx - 1;
187
+ }
188
+ return stops;
189
+ }
190
+ return colorStops.map(((item, index) => {
191
+ const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
192
+ return {
193
+ color: item.value,
194
+ offset: offset
195
+ };
196
+ }));
197
+ }
172
198
  static ParseConic(datum) {
173
199
  const {orientation: orientation, colorStops: colorStops = []} = datum, halfPi = pi / 2, sa = parseFloat(orientation.value) / 180 * pi - halfPi;
174
200
  return {
@@ -177,10 +203,7 @@ export class GradientParser {
177
203
  y: .5,
178
204
  startAngle: sa,
179
205
  endAngle: sa + pi2,
180
- stops: colorStops.map((item => ({
181
- color: item.value,
182
- offset: parseFloat(item.length.value) / 100
183
- })))
206
+ stops: GradientParser.processColorStops(colorStops)
184
207
  };
185
208
  }
186
209
  static ParseRadial(datum) {
@@ -193,10 +216,7 @@ export class GradientParser {
193
216
  y1: .5,
194
217
  r0: 0,
195
218
  r1: 1,
196
- stops: colorStops.map((item => ({
197
- color: item.value,
198
- offset: parseFloat(item.length.value) / 100
199
- })))
219
+ stops: GradientParser.processColorStops(colorStops)
200
220
  };
201
221
  }
202
222
  static ParseLinear(datum) {
@@ -214,10 +234,7 @@ export class GradientParser {
214
234
  y0: y0,
215
235
  x1: x1,
216
236
  y1: y1,
217
- stops: colorStops.map((item => ({
218
- color: item.value,
219
- offset: parseFloat(item.length.value) / 100
220
- })))
237
+ stops: GradientParser.processColorStops(colorStops)
221
238
  };
222
239
  }
223
240
  }
@@ -1 +1 @@
1
- {"version":3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C,CAAC;YACP,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YAC/B,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;SAC3B;aAAM;YACL,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;YACxC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;SACzC;QACD,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,EAAE;YACF,EAAE;YACF,EAAE;YACF,EAAE;YACF,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;gBAClC,OAAO;oBACL,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG;iBAC5C,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF","file":"color-utils.js","sourcesContent":["// 解析字符串gradient-color\n/**\n * The MIT License (MIT)\n\n Copyright (c) 2014 Rafael Carício\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n// Copyright (c) 2014 Rafael Caricio. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport { pi, pi2 } from '@visactor/vutils';\nimport type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface';\n\n// @ts-ignore\n\nconst parse = (function () {\n const tokens = {\n linearGradient: /^(linear\\-gradient)/i,\n radialGradient: /^(radial\\-gradient)/i,\n conicGradient: /^(conic\\-gradient)/i,\n sideOrCorner:\n /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,\n extentKeywords: /^(closest\\-side|closest\\-corner|farthest\\-side|farthest\\-corner|contain|cover)/,\n positionKeywords: /^(left|center|right|top|bottom)/i,\n pixelValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))px/,\n percentageValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))\\%/,\n emValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))em/,\n angleValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n fromAngleValue: /^from\\s*(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n startCall: /^\\(/,\n endCall: /^\\)/,\n comma: /^,/,\n hexColor: /(^\\#[0-9a-fA-F]+)/,\n literalColor: /^([a-zA-Z]+)/,\n rgbColor: /^(rgb\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3}\\))/i,\n rgbaColor: /^(rgba\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3},\\s*((\\d\\.\\d+)|\\d{1,3})\\))/i,\n number: /^(([0-9]*\\.[0-9]+)|([0-9]+\\.?))/\n };\n\n let input = '';\n\n function error(msg: any) {\n const err: any = new Error(input + ': ' + msg);\n err.source = input;\n throw err;\n }\n\n function getAST() {\n const ast = matchListDefinitions();\n\n if (input.length > 0) {\n error('Invalid input not EOF');\n }\n\n return ast;\n }\n\n function matchListDefinitions() {\n return matchListing(matchDefinition);\n }\n\n function matchDefinition() {\n return (\n matchGradient('linear', tokens.linearGradient, matchLinearOrientation) ||\n matchGradient('radial', tokens.radialGradient, matchListRadialOrientations) ||\n matchGradient('conic', tokens.conicGradient, matchConicalOrientation)\n );\n }\n\n function matchGradient(gradientType: string, pattern: RegExp, orientationMatcher: any) {\n return matchCall(pattern, function (captures: any) {\n const orientation = orientationMatcher();\n if (orientation) {\n if (!scan(tokens.comma)) {\n error('Missing comma before color stops');\n }\n }\n\n return {\n type: gradientType,\n orientation: orientation,\n colorStops: matchListing(matchColorStop)\n };\n });\n }\n\n function matchCall(pattern: RegExp, callback: any) {\n const captures = scan(pattern);\n\n if (captures) {\n if (!scan(tokens.startCall)) {\n error('Missing (');\n }\n\n const result = callback(captures);\n\n if (!scan(tokens.endCall)) {\n error('Missing )');\n }\n\n return result;\n }\n }\n\n function matchLinearOrientation() {\n return matchSideOrCorner() || matchAngle();\n }\n function matchConicalOrientation() {\n return matchFromAngle();\n }\n\n function matchSideOrCorner() {\n return match('directional', tokens.sideOrCorner, 1);\n }\n\n function matchAngle() {\n return match('angular', tokens.angleValue, 1);\n }\n function matchFromAngle() {\n return match('angular', tokens.fromAngleValue, 1);\n }\n\n function matchListRadialOrientations() {\n let radialOrientations;\n let radialOrientation = matchRadialOrientation();\n let lookaheadCache;\n\n if (radialOrientation) {\n radialOrientations = [];\n radialOrientations.push(radialOrientation);\n\n lookaheadCache = input;\n if (scan(tokens.comma)) {\n radialOrientation = matchRadialOrientation();\n if (radialOrientation) {\n radialOrientations.push(radialOrientation);\n } else {\n input = lookaheadCache;\n }\n }\n }\n\n return radialOrientations;\n }\n\n function matchRadialOrientation() {\n let radialType: any = matchCircle() || matchEllipse();\n\n if (radialType) {\n radialType.at = matchAtPosition();\n } else {\n const extent = matchExtentKeyword();\n if (extent) {\n radialType = extent;\n const positionAt = matchAtPosition();\n if (positionAt) {\n radialType.at = positionAt;\n }\n } else {\n const defaultPosition = matchPositioning();\n if (defaultPosition) {\n radialType = {\n type: 'default-radial',\n at: defaultPosition\n };\n }\n }\n }\n\n return radialType;\n }\n\n function matchCircle() {\n const circle: any = match('shape', /^(circle)/i, 0);\n\n if (circle) {\n circle.style = matchLength() || matchExtentKeyword();\n }\n\n return circle;\n }\n\n function matchEllipse() {\n const ellipse: any = match('shape', /^(ellipse)/i, 0);\n\n if (ellipse) {\n ellipse.style = matchDistance() || matchExtentKeyword();\n }\n\n return ellipse;\n }\n\n function matchExtentKeyword() {\n return match('extent-keyword', tokens.extentKeywords, 1);\n }\n\n function matchAtPosition() {\n if (match('position', /^at/, 0)) {\n const positioning = matchPositioning();\n\n if (!positioning) {\n error('Missing positioning value');\n }\n\n return positioning;\n }\n }\n\n function matchPositioning() {\n const location = matchCoordinates();\n\n if (location.x || location.y) {\n return {\n type: 'position',\n value: location\n };\n }\n }\n\n function matchCoordinates() {\n return {\n x: matchDistance(),\n y: matchDistance()\n };\n }\n\n function matchListing(matcher: any) {\n let captures = matcher();\n const result = [];\n\n if (captures) {\n result.push(captures);\n while (scan(tokens.comma)) {\n captures = matcher();\n if (captures) {\n result.push(captures);\n } else {\n error('One extra comma');\n }\n }\n }\n\n return result;\n }\n\n function matchColorStop() {\n const color: any = matchColor();\n\n if (!color) {\n error('Expected color definition');\n }\n\n color.length = matchDistance();\n return color;\n }\n\n function matchColor() {\n return matchHexColor() || matchRGBAColor() || matchRGBColor() || matchLiteralColor();\n }\n\n function matchLiteralColor() {\n return match('literal', tokens.literalColor, 0);\n }\n\n function matchHexColor() {\n return match('hex', tokens.hexColor, 1);\n }\n\n function matchRGBColor() {\n return match('rgb', tokens.rgbColor, 1);\n }\n\n function matchRGBAColor() {\n return match('rgba', tokens.rgbaColor, 1);\n }\n\n function matchNumber() {\n return scan(tokens.number)[1];\n }\n\n function matchDistance() {\n return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();\n }\n\n function matchPositionKeyword() {\n return match('position-keyword', tokens.positionKeywords, 1);\n }\n\n function matchLength() {\n return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);\n }\n\n function match(type: string, pattern: RegExp, captureIndex: number) {\n const captures = scan(pattern);\n if (captures) {\n return {\n type: type,\n value: captures[captureIndex]\n };\n }\n }\n\n function scan(regexp: RegExp) {\n const blankCaptures = /^[\\n\\r\\t\\s]+/.exec(input);\n if (blankCaptures) {\n consume(blankCaptures[0].length);\n }\n\n const captures = regexp.exec(input);\n if (captures) {\n consume(captures[0].length);\n }\n\n return captures;\n }\n\n function consume(size: number) {\n input = input.substr(size);\n }\n\n return function (code: string) {\n input = code.toString();\n return getAST();\n };\n})();\n\nexport class GradientParser {\n static IsGradient(c: IColor) {\n return !(typeof c === 'string' && !c.includes('gradient'));\n }\n\n static IsGradientStr(c: IColor) {\n return typeof c === 'string' && c.includes('gradient');\n }\n\n static Parse(c: IColor): IColor {\n if (GradientParser.IsGradientStr(c)) {\n try {\n const data = parse(c as string);\n const datum = data[0];\n if (datum) {\n if (datum.type === 'linear') {\n return GradientParser.ParseLinear(datum);\n } else if (datum.type === 'radial') {\n return GradientParser.ParseRadial(datum);\n } else if (datum.type === 'conic') {\n return GradientParser.ParseConic(datum);\n }\n }\n } catch (err) {\n return c;\n }\n }\n return c;\n }\n private static ParseConic(datum: any): IConicalGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n const sa = (parseFloat(orientation.value) / 180) * pi - halfPi;\n return {\n gradient: 'conical',\n x: 0.5,\n y: 0.5,\n startAngle: sa,\n endAngle: sa + pi2,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n private static ParseRadial(datum: any): IRadialGradient {\n const { colorStops = [] } = datum;\n return {\n gradient: 'radial',\n x0: 0.5,\n y0: 0.5,\n x1: 0.5,\n y1: 0.5,\n r0: 0,\n r1: 1,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n private static ParseLinear(datum: any): ILinearGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n let angle = orientation.type === 'angular' ? (parseFloat(orientation.value) / 180) * pi : 0;\n while (angle < 0) {\n angle += pi2;\n }\n while (angle >= pi2) {\n angle -= pi2;\n }\n let x0 = 0;\n let y0 = 0;\n let x1 = 0;\n let y1 = 0;\n if (angle < halfPi) {\n x0 = 0;\n y0 = 1;\n x1 = Math.sin(angle);\n y1 = y0 - Math.cos(angle);\n } else if (angle < pi) {\n x0 = 0;\n y0 = 0;\n x1 = Math.cos(angle - halfPi);\n y1 = Math.sin(angle - halfPi);\n } else if (angle < pi + halfPi) {\n x0 = 1;\n y0 = 0;\n x1 = x0 - Math.sin(angle - pi);\n y1 = Math.cos(angle - pi);\n } else {\n x0 = 1;\n y0 - 1;\n x1 = x0 - Math.cos(angle - halfPi - pi);\n y1 = y1 - Math.sin(angle - halfPi - pi);\n }\n return {\n gradient: 'linear',\n x0,\n y0,\n x1,\n y1,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/common/color-utils.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAK3C,MAAM,KAAK,GAAG,CAAC;IACb,MAAM,MAAM,GAAG;QACb,cAAc,EAAE,sBAAsB;QACtC,cAAc,EAAE,sBAAsB;QACtC,aAAa,EAAE,qBAAqB;QACpC,YAAY,EACV,wGAAwG;QAC1G,cAAc,EAAE,gFAAgF;QAChG,gB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AG,CAAC,CAAC;YACP,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;YAC9B,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;SAC/B;aAAM,IAAI,KAAK,GAAG,EAAE,GAAG,MAAM,EAAE;YAC9B,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YAC/B,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;SAC3B;aAAM;YACL,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,CAAC,CAAC;YACP,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;YACxC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;SACzC;QACD,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,EAAE;YACF,EAAE;YACF,EAAE;YACF,EAAE;YACF,KAAK,EAAE,cAAc,CAAC,iBAAiB,CAAC,UAAU,CAAC;SACpD,CAAC;IACJ,CAAC;CACF","file":"color-utils.js","sourcesContent":["// 解析字符串gradient-color\n/**\n * The MIT License (MIT)\n\n Copyright (c) 2014 Rafael Carício\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n// Copyright (c) 2014 Rafael Caricio. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport { pi, pi2 } from '@visactor/vutils';\nimport type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface';\n\n// @ts-ignore\n\nconst parse = (function () {\n const tokens = {\n linearGradient: /^(linear\\-gradient)/i,\n radialGradient: /^(radial\\-gradient)/i,\n conicGradient: /^(conic\\-gradient)/i,\n sideOrCorner:\n /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,\n extentKeywords: /^(closest\\-side|closest\\-corner|farthest\\-side|farthest\\-corner|contain|cover)/,\n positionKeywords: /^(left|center|right|top|bottom)/i,\n pixelValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))px/,\n percentageValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))\\%/,\n emValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))em/,\n angleValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n fromAngleValue: /^from\\s*(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n startCall: /^\\(/,\n endCall: /^\\)/,\n comma: /^,/,\n hexColor: /(^\\#[0-9a-fA-F]+)/,\n literalColor: /^([a-zA-Z]+)/,\n rgbColor: /^(rgb\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3}\\))/i,\n rgbaColor: /^(rgba\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3},\\s*((\\d\\.\\d+)|\\d{1,3})\\))/i,\n number: /^(([0-9]*\\.[0-9]+)|([0-9]+\\.?))/\n };\n\n let input = '';\n\n function error(msg: any) {\n const err: any = new Error(input + ': ' + msg);\n err.source = input;\n throw err;\n }\n\n function getAST() {\n const ast = matchListDefinitions();\n\n if (input.length > 0) {\n error('Invalid input not EOF');\n }\n\n return ast;\n }\n\n function matchListDefinitions() {\n return matchListing(matchDefinition);\n }\n\n function matchDefinition() {\n return (\n matchGradient('linear', tokens.linearGradient, matchLinearOrientation) ||\n matchGradient('radial', tokens.radialGradient, matchListRadialOrientations) ||\n matchGradient('conic', tokens.conicGradient, matchConicalOrientation)\n );\n }\n\n function matchGradient(gradientType: string, pattern: RegExp, orientationMatcher: any) {\n return matchCall(pattern, function (captures: any) {\n const orientation = orientationMatcher();\n if (orientation) {\n if (!scan(tokens.comma)) {\n error('Missing comma before color stops');\n }\n }\n\n return {\n type: gradientType,\n orientation: orientation,\n colorStops: matchListing(matchColorStop)\n };\n });\n }\n\n function matchCall(pattern: RegExp, callback: any) {\n const captures = scan(pattern);\n\n if (captures) {\n if (!scan(tokens.startCall)) {\n error('Missing (');\n }\n\n const result = callback(captures);\n\n if (!scan(tokens.endCall)) {\n error('Missing )');\n }\n\n return result;\n }\n }\n\n function matchLinearOrientation() {\n return matchSideOrCorner() || matchAngle();\n }\n function matchConicalOrientation() {\n return matchFromAngle();\n }\n\n function matchSideOrCorner() {\n return match('directional', tokens.sideOrCorner, 1);\n }\n\n function matchAngle() {\n return match('angular', tokens.angleValue, 1);\n }\n function matchFromAngle() {\n return match('angular', tokens.fromAngleValue, 1);\n }\n\n function matchListRadialOrientations() {\n let radialOrientations;\n let radialOrientation = matchRadialOrientation();\n let lookaheadCache;\n\n if (radialOrientation) {\n radialOrientations = [];\n radialOrientations.push(radialOrientation);\n\n lookaheadCache = input;\n if (scan(tokens.comma)) {\n radialOrientation = matchRadialOrientation();\n if (radialOrientation) {\n radialOrientations.push(radialOrientation);\n } else {\n input = lookaheadCache;\n }\n }\n }\n\n return radialOrientations;\n }\n\n function matchRadialOrientation() {\n let radialType: any = matchCircle() || matchEllipse();\n\n if (radialType) {\n radialType.at = matchAtPosition();\n } else {\n const extent = matchExtentKeyword();\n if (extent) {\n radialType = extent;\n const positionAt = matchAtPosition();\n if (positionAt) {\n radialType.at = positionAt;\n }\n } else {\n const defaultPosition = matchPositioning();\n if (defaultPosition) {\n radialType = {\n type: 'default-radial',\n at: defaultPosition\n };\n }\n }\n }\n\n return radialType;\n }\n\n function matchCircle() {\n const circle: any = match('shape', /^(circle)/i, 0);\n\n if (circle) {\n circle.style = matchLength() || matchExtentKeyword();\n }\n\n return circle;\n }\n\n function matchEllipse() {\n const ellipse: any = match('shape', /^(ellipse)/i, 0);\n\n if (ellipse) {\n ellipse.style = matchDistance() || matchExtentKeyword();\n }\n\n return ellipse;\n }\n\n function matchExtentKeyword() {\n return match('extent-keyword', tokens.extentKeywords, 1);\n }\n\n function matchAtPosition() {\n if (match('position', /^at/, 0)) {\n const positioning = matchPositioning();\n\n if (!positioning) {\n error('Missing positioning value');\n }\n\n return positioning;\n }\n }\n\n function matchPositioning() {\n const location = matchCoordinates();\n\n if (location.x || location.y) {\n return {\n type: 'position',\n value: location\n };\n }\n }\n\n function matchCoordinates() {\n return {\n x: matchDistance(),\n y: matchDistance()\n };\n }\n\n function matchListing(matcher: any) {\n let captures = matcher();\n const result = [];\n\n if (captures) {\n result.push(captures);\n while (scan(tokens.comma)) {\n captures = matcher();\n if (captures) {\n result.push(captures);\n } else {\n error('One extra comma');\n }\n }\n }\n\n return result;\n }\n\n function matchColorStop() {\n const color: any = matchColor();\n\n if (!color) {\n error('Expected color definition');\n }\n\n color.length = matchDistance();\n return color;\n }\n\n function matchColor() {\n return matchHexColor() || matchRGBAColor() || matchRGBColor() || matchLiteralColor();\n }\n\n function matchLiteralColor() {\n return match('literal', tokens.literalColor, 0);\n }\n\n function matchHexColor() {\n return match('hex', tokens.hexColor, 1);\n }\n\n function matchRGBColor() {\n return match('rgb', tokens.rgbColor, 1);\n }\n\n function matchRGBAColor() {\n return match('rgba', tokens.rgbaColor, 1);\n }\n\n function matchNumber() {\n return scan(tokens.number)[1];\n }\n\n function matchDistance() {\n return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();\n }\n\n function matchPositionKeyword() {\n return match('position-keyword', tokens.positionKeywords, 1);\n }\n\n function matchLength() {\n return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);\n }\n\n function match(type: string, pattern: RegExp, captureIndex: number) {\n const captures = scan(pattern);\n if (captures) {\n return {\n type: type,\n value: captures[captureIndex]\n };\n }\n }\n\n function scan(regexp: RegExp) {\n const blankCaptures = /^[\\n\\r\\t\\s]+/.exec(input);\n if (blankCaptures) {\n consume(blankCaptures[0].length);\n }\n\n const captures = regexp.exec(input);\n if (captures) {\n consume(captures[0].length);\n }\n\n return captures;\n }\n\n function consume(size: number) {\n input = input.substr(size);\n }\n\n return function (code: string) {\n input = code.toString();\n return getAST();\n };\n})();\n\nexport class GradientParser {\n static IsGradient(c: IColor) {\n return !(typeof c === 'string' && !c.includes('gradient'));\n }\n\n static IsGradientStr(c: IColor) {\n return typeof c === 'string' && c.includes('gradient');\n }\n\n static Parse(c: IColor): IColor {\n if (GradientParser.IsGradientStr(c)) {\n try {\n const data = parse(c as string);\n const datum = data[0];\n if (datum) {\n if (datum.type === 'linear') {\n return GradientParser.ParseLinear(datum);\n } else if (datum.type === 'radial') {\n return GradientParser.ParseRadial(datum);\n } else if (datum.type === 'conic') {\n return GradientParser.ParseConic(datum);\n }\n }\n } catch (err) {\n return c;\n }\n }\n return c;\n }\n static processColorStops(\n colorStops: Array<{ value: string; length?: { value: string } }>\n ): { color: string; offset: number }[] {\n if (!colorStops || colorStops.length === 0) {\n return [];\n }\n\n const anyStopHasLength = colorStops.some((item: any) => item.length);\n\n if (anyStopHasLength) {\n const stops = colorStops.map((item: any) => ({\n color: item.value,\n offset: item.length ? parseFloat(item.length.value) / 100 : -1\n }));\n\n // If first color stop has no position, it defaults to 0%\n if (stops[0].offset < 0) {\n stops[0].offset = 0;\n }\n\n // If last color stop has no position, it defaults to 100%\n if (stops[stops.length - 1].offset < 0) {\n stops[stops.length - 1].offset = 1;\n }\n\n // If a color stop in between has no position, its position is the average of the preceding and succeeding color stops with positions.\n for (let i = 1; i < stops.length - 1; i++) {\n if (stops[i].offset < 0) {\n const prevWithOffsetIdx = i - 1;\n let nextWithOffsetIdx = i + 1;\n while (nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0) {\n nextWithOffsetIdx++;\n }\n\n const startOffset = stops[prevWithOffsetIdx].offset;\n const endOffset = stops[nextWithOffsetIdx].offset;\n const unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;\n\n for (let j = 1; j < unspecCount; j++) {\n stops[prevWithOffsetIdx + j].offset = startOffset + ((endOffset - startOffset) * j) / unspecCount;\n }\n i = nextWithOffsetIdx - 1;\n }\n }\n return stops;\n }\n return colorStops.map((item: any, index: number) => {\n const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;\n return {\n color: item.value,\n offset\n };\n });\n }\n private static ParseConic(datum: any): IConicalGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n const sa = (parseFloat(orientation.value) / 180) * pi - halfPi;\n return {\n gradient: 'conical',\n x: 0.5,\n y: 0.5,\n startAngle: sa,\n endAngle: sa + pi2,\n stops: GradientParser.processColorStops(colorStops)\n };\n }\n private static ParseRadial(datum: any): IRadialGradient {\n const { colorStops = [] } = datum;\n return {\n gradient: 'radial',\n x0: 0.5,\n y0: 0.5,\n x1: 0.5,\n y1: 0.5,\n r0: 0,\n r1: 1,\n stops: GradientParser.processColorStops(colorStops)\n };\n }\n private static ParseLinear(datum: any): ILinearGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n let angle = orientation.type === 'angular' ? (parseFloat(orientation.value) / 180) * pi : 0;\n while (angle < 0) {\n angle += pi2;\n }\n while (angle >= pi2) {\n angle -= pi2;\n }\n let x0 = 0;\n let y0 = 0;\n let x1 = 0;\n let y1 = 0;\n if (angle < halfPi) {\n x0 = 0;\n y0 = 1;\n x1 = Math.sin(angle);\n y1 = y0 - Math.cos(angle);\n } else if (angle < pi) {\n x0 = 0;\n y0 = 0;\n x1 = Math.cos(angle - halfPi);\n y1 = Math.sin(angle - halfPi);\n } else if (angle < pi + halfPi) {\n x0 = 1;\n y0 = 0;\n x1 = x0 - Math.sin(angle - pi);\n y1 = Math.cos(angle - pi);\n } else {\n x0 = 1;\n y0 - 1;\n x1 = x0 - Math.cos(angle - halfPi - pi);\n y1 = y1 - Math.sin(angle - halfPi - pi);\n }\n return {\n gradient: 'linear',\n x0,\n y0,\n x1,\n y1,\n stops: GradientParser.processColorStops(colorStops)\n };\n }\n}\n"]}
@@ -3,6 +3,7 @@ import type { ICanvas, IContext2d, EnvType } from '../../../interface';
3
3
  import { MeasureModeEnum } from '../../../interface';
4
4
  import type { TextOptionsType, ITextMeasure } from '../../../interface/text';
5
5
  export declare class ATextMeasure implements ITextMeasure {
6
+ id: string;
6
7
  release: (...params: any) => void;
7
8
  protected canvas?: ICanvas;
8
9
  protected context?: IContext2d | null;
@@ -15,6 +15,9 @@ import { testLetter } from "../../../graphic/richtext/utils";
15
15
  import { Logger } from "@visactor/vutils";
16
16
 
17
17
  let ATextMeasure = class {
18
+ constructor() {
19
+ this.id = "ATextMeasure";
20
+ }
18
21
  configure(service, env) {
19
22
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
20
23
  }