@visactor/vrender-core 0.20.3 → 0.20.5

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 (42) hide show
  1. package/cjs/common/bounds-context.js +1 -1
  2. package/cjs/common/bounds-context.js.map +1 -1
  3. package/cjs/common/shape/arc.js +5 -2
  4. package/cjs/common/shape/arc.js.map +1 -1
  5. package/cjs/core/stage.d.ts +3 -2
  6. package/cjs/core/stage.js +7 -4
  7. package/cjs/core/stage.js.map +1 -1
  8. package/cjs/graphic/graphic-service/graphic-service.js +1 -0
  9. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  10. package/cjs/graphic/richtext/line.js +13 -2
  11. package/cjs/graphic/richtext/line.js.map +1 -1
  12. package/cjs/graphic/richtext.d.ts +2 -0
  13. package/cjs/graphic/richtext.js +35 -12
  14. package/cjs/graphic/richtext.js.map +1 -1
  15. package/cjs/graphic/text.js +11 -4
  16. package/cjs/graphic/text.js.map +1 -1
  17. package/cjs/interface/graphic/richText.d.ts +1 -0
  18. package/cjs/interface/graphic/richText.js.map +1 -1
  19. package/cjs/interface/stage.d.ts +2 -2
  20. package/cjs/interface/stage.js.map +1 -1
  21. package/dist/index.es.js +137 -65
  22. package/es/common/bounds-context.js +1 -1
  23. package/es/common/bounds-context.js.map +1 -1
  24. package/es/common/shape/arc.js +5 -2
  25. package/es/common/shape/arc.js.map +1 -1
  26. package/es/core/stage.d.ts +3 -2
  27. package/es/core/stage.js +7 -4
  28. package/es/core/stage.js.map +1 -1
  29. package/es/graphic/graphic-service/graphic-service.js +1 -0
  30. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  31. package/es/graphic/richtext/line.js +13 -2
  32. package/es/graphic/richtext/line.js.map +1 -1
  33. package/es/graphic/richtext.d.ts +2 -0
  34. package/es/graphic/richtext.js +35 -12
  35. package/es/graphic/richtext.js.map +1 -1
  36. package/es/graphic/text.js +11 -4
  37. package/es/graphic/text.js.map +1 -1
  38. package/es/interface/graphic/richText.d.ts +1 -0
  39. package/es/interface/graphic/richText.js.map +1 -1
  40. package/es/interface/stage.d.ts +2 -2
  41. package/es/interface/stage.js.map +1 -1
  42. package/package.json +2 -2
package/dist/index.es.js CHANGED
@@ -1229,7 +1229,7 @@ class BoundsContext {
1229
1229
  this.bounds.add(cx + xmax, cy + ymax);
1230
1230
  }
1231
1231
  arcTo(x1, y1, x2, y2, radius) {
1232
- throw new Error('不支持arcTo');
1232
+ this.bounds.add(x1, y1);
1233
1233
  }
1234
1234
  bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
1235
1235
  this.bounds.add(cp1x, cp1y);
@@ -1541,19 +1541,25 @@ function drawArc(context, x, y, coords) {
1541
1541
  }
1542
1542
  const addArcToBezierPath = (bezierPath, startAngle, endAngle, cx, cy, rx, ry) => {
1543
1543
  const delta = Math.abs(endAngle - startAngle);
1544
- const len = (Math.tan(delta / 4) * 4) / 3;
1545
- const dir = endAngle < startAngle ? -1 : 1;
1546
- const c1 = Math.cos(startAngle);
1547
- const s1 = Math.sin(startAngle);
1548
- const c2 = Math.cos(endAngle);
1549
- const s2 = Math.sin(endAngle);
1550
- const x1 = c1 * rx + cx;
1551
- const y1 = s1 * ry + cy;
1552
- const x4 = c2 * rx + cx;
1553
- const y4 = s2 * ry + cy;
1554
- const hx = rx * len * dir;
1555
- const hy = ry * len * dir;
1556
- bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
1544
+ const count = delta > 0.5 * Math.PI ? Math.ceil((2 * delta) / Math.PI) : 1;
1545
+ const stepAngle = (endAngle - startAngle) / count;
1546
+ for (let i = 0; i < count; i++) {
1547
+ const sa = startAngle + stepAngle * i;
1548
+ const ea = startAngle + stepAngle * (i + 1);
1549
+ const len = (Math.tan(Math.abs(stepAngle) / 4) * 4) / 3;
1550
+ const dir = ea < sa ? -1 : 1;
1551
+ const c1 = Math.cos(sa);
1552
+ const s1 = Math.sin(sa);
1553
+ const c2 = Math.cos(ea);
1554
+ const s2 = Math.sin(ea);
1555
+ const x1 = c1 * rx + cx;
1556
+ const y1 = s1 * ry + cy;
1557
+ const x4 = c2 * rx + cx;
1558
+ const y4 = s2 * ry + cy;
1559
+ const hx = rx * len * dir;
1560
+ const hy = ry * len * dir;
1561
+ bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
1562
+ }
1557
1563
  };
1558
1564
 
1559
1565
  const commandFuncs = [
@@ -14376,6 +14382,9 @@ let DefaultGraphicService = class DefaultGraphicService {
14376
14382
  if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {
14377
14383
  return true;
14378
14384
  }
14385
+ if (graphic.shadowRoot) {
14386
+ return true;
14387
+ }
14379
14388
  if (!graphic.valid) {
14380
14389
  aabbBounds.clear();
14381
14390
  return false;
@@ -18985,16 +18994,22 @@ class Text extends Graphic {
18985
18994
  return this.cache.clipedWidth;
18986
18995
  }
18987
18996
  get cliped() {
18997
+ var _a, _b;
18988
18998
  const textTheme = this.getGraphicTheme();
18989
18999
  const attribute = this.attribute;
18990
- if (this.isMultiLine) {
18991
- return undefined;
18992
- }
18993
- const { maxLineWidth = textTheme.maxLineWidth } = attribute;
19000
+ const { maxLineWidth = textTheme.maxLineWidth, text, whiteSpace = textTheme.whiteSpace } = attribute;
18994
19001
  if (!Number.isFinite(maxLineWidth)) {
18995
19002
  return false;
18996
19003
  }
18997
19004
  this.tryUpdateAABBBounds();
19005
+ if ((_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData) === null || _b === void 0 ? void 0 : _b.lines) {
19006
+ let mergedText = '';
19007
+ this.cache.layoutData.lines.forEach(item => {
19008
+ mergedText += item.str;
19009
+ });
19010
+ const originText = Array.isArray(text) ? text.join('') : text;
19011
+ return originText !== mergedText;
19012
+ }
18998
19013
  if (attribute.direction === 'vertical' && this.cache.verticalList && this.cache.verticalList[0]) {
18999
19014
  return this.cache.verticalList[0].map(item => item.text).join('') !== attribute.text.toString();
19000
19015
  }
@@ -21599,36 +21614,55 @@ class Line {
21599
21614
  }
21600
21615
  draw(ctx, lastLine, x, y, drawEllipsis, drawIcon) {
21601
21616
  if (drawEllipsis && (lastLine || this.paragraphs.some(p => p.overflow))) {
21602
- let otherParagraphWidth = 0;
21617
+ let emptyOverflow = true;
21618
+ let skipEllipsis = false;
21603
21619
  for (let i = this.paragraphs.length - 1; i >= 0; i--) {
21604
21620
  const paragraph = this.paragraphs[i];
21605
21621
  if (paragraph.overflow) {
21606
- continue;
21607
- }
21608
- if (paragraph instanceof RichTextIcon) {
21609
- break;
21610
- }
21611
- if (this.direction === 'vertical' && paragraph.direction !== 'vertical') {
21612
- paragraph.verticalEllipsis = true;
21613
- break;
21614
- }
21615
- const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || '';
21616
- paragraph.ellipsisStr = ellipsis;
21617
- const { width } = measureTextCanvas(ellipsis, paragraph.character);
21618
- const ellipsisWidth = width || 0;
21619
- if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
21620
- lastLine && (paragraph.ellipsis = 'add');
21621
- break;
21622
- }
21623
- else if (ellipsisWidth <= this.blankWidth + otherParagraphWidth + paragraph.width) {
21624
- paragraph.ellipsis = 'replace';
21625
- paragraph.ellipsisWidth = ellipsisWidth;
21626
- paragraph.ellipsisOtherParagraphWidth = this.blankWidth + otherParagraphWidth;
21627
- break;
21622
+ emptyOverflow = emptyOverflow && paragraph.text === '';
21628
21623
  }
21629
21624
  else {
21630
- paragraph.ellipsis = 'hide';
21631
- otherParagraphWidth += paragraph.width;
21625
+ if (emptyOverflow) {
21626
+ skipEllipsis = true;
21627
+ break;
21628
+ }
21629
+ }
21630
+ }
21631
+ let otherParagraphWidth = 0;
21632
+ if (!skipEllipsis) {
21633
+ for (let i = this.paragraphs.length - 1; i >= 0; i--) {
21634
+ const paragraph = this.paragraphs[i];
21635
+ if (paragraph.overflow) {
21636
+ if (paragraph.text === '') {
21637
+ break;
21638
+ }
21639
+ continue;
21640
+ }
21641
+ if (paragraph instanceof RichTextIcon) {
21642
+ break;
21643
+ }
21644
+ if (this.direction === 'vertical' && paragraph.direction !== 'vertical') {
21645
+ paragraph.verticalEllipsis = true;
21646
+ break;
21647
+ }
21648
+ const ellipsis = drawEllipsis === true ? '...' : drawEllipsis || '';
21649
+ paragraph.ellipsisStr = ellipsis;
21650
+ const { width } = measureTextCanvas(ellipsis, paragraph.character);
21651
+ const ellipsisWidth = width || 0;
21652
+ if (ellipsisWidth <= this.blankWidth + otherParagraphWidth) {
21653
+ lastLine && (paragraph.ellipsis = 'add');
21654
+ break;
21655
+ }
21656
+ else if (ellipsisWidth <= this.blankWidth + otherParagraphWidth + paragraph.width) {
21657
+ paragraph.ellipsis = 'replace';
21658
+ paragraph.ellipsisWidth = ellipsisWidth;
21659
+ paragraph.ellipsisOtherParagraphWidth = this.blankWidth + otherParagraphWidth;
21660
+ break;
21661
+ }
21662
+ else {
21663
+ paragraph.ellipsis = 'hide';
21664
+ otherParagraphWidth += paragraph.width;
21665
+ }
21632
21666
  }
21633
21667
  }
21634
21668
  }
@@ -21835,6 +21869,17 @@ class RichText extends Graphic {
21835
21869
  this.type = 'richtext';
21836
21870
  this._currentHoverIcon = null;
21837
21871
  this.numberType = RICHTEXT_NUMBER_TYPE;
21872
+ this.onBeforeAttributeUpdate = ((val, attributes, key) => {
21873
+ for (const key in val) {
21874
+ if (key === 'hoverIconId') {
21875
+ if (val[key] === attributes[key]) {
21876
+ continue;
21877
+ }
21878
+ const icon = this._frameCache.icons.get(val[key]);
21879
+ this.updateHoverIconState(icon);
21880
+ }
21881
+ }
21882
+ });
21838
21883
  }
21839
21884
  get width() {
21840
21885
  var _a;
@@ -22003,6 +22048,25 @@ class RichText extends Graphic {
22003
22048
  }
22004
22049
  return this._frameCache;
22005
22050
  }
22051
+ get cliped() {
22052
+ const frameCache = this.getFrameCache();
22053
+ if (frameCache.actualHeight > frameCache.height) {
22054
+ return true;
22055
+ }
22056
+ const { disableAutoWrapLine } = this.attribute;
22057
+ if (disableAutoWrapLine) {
22058
+ for (let i = 0; i < frameCache.lines.length; i++) {
22059
+ const l = frameCache.lines[i];
22060
+ for (let j = 0; j < l.paragraphs.length; j++) {
22061
+ const p = l.paragraphs[j];
22062
+ if (p.overflow && p.text !== '') {
22063
+ return true;
22064
+ }
22065
+ }
22066
+ }
22067
+ }
22068
+ return false;
22069
+ }
22006
22070
  combinedStyleToCharacter(config) {
22007
22071
  const { fill, stroke, fontSize, fontFamily, fontStyle, fontWeight, lineWidth, opacity, fillOpacity, strokeOpacity } = this.attribute;
22008
22072
  return Object.assign({ fill,
@@ -22024,6 +22088,7 @@ class RichText extends Graphic {
22024
22088
  for (let i = 0; i < textConfig.length; i++) {
22025
22089
  if ('image' in textConfig[i]) {
22026
22090
  const config = this.combinedStyleToCharacter(textConfig[i]);
22091
+ config.lineWidth = undefined;
22027
22092
  const iconCache = config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);
22028
22093
  if (iconCache) {
22029
22094
  paragraphs.push(iconCache);
@@ -22130,38 +22195,42 @@ class RichText extends Graphic {
22130
22195
  }
22131
22196
  bindIconEvent() {
22132
22197
  this.addEventListener('pointermove', (e) => {
22133
- var _a, _b, _c, _d, _e;
22134
22198
  const pickedIcon = this.pickIcon(e.global);
22135
22199
  if (pickedIcon && pickedIcon === this._currentHoverIcon) ;
22136
22200
  else if (pickedIcon) {
22137
- (_a = this._currentHoverIcon) === null || _a === void 0 ? void 0 : _a.setHoverState(false);
22138
- this._currentHoverIcon = pickedIcon;
22139
- this._currentHoverIcon.setHoverState(true);
22140
- (_b = this.stage) === null || _b === void 0 ? void 0 : _b.setCursor(pickedIcon.attribute.cursor);
22141
- (_c = this.stage) === null || _c === void 0 ? void 0 : _c.renderNextFrame();
22201
+ this.setAttribute('hoverIconId', pickedIcon.richtextId);
22142
22202
  }
22143
22203
  else if (!pickedIcon && this._currentHoverIcon) {
22144
- this._currentHoverIcon.setHoverState(false);
22145
- this._currentHoverIcon = null;
22146
- (_d = this.stage) === null || _d === void 0 ? void 0 : _d.setCursor();
22147
- (_e = this.stage) === null || _e === void 0 ? void 0 : _e.renderNextFrame();
22204
+ this.setAttribute('hoverIconId', undefined);
22148
22205
  }
22149
22206
  });
22150
22207
  this.addEventListener('pointerleave', (e) => {
22151
- var _a, _b;
22152
22208
  if (this._currentHoverIcon) {
22153
- this._currentHoverIcon.setHoverState(false);
22154
- this._currentHoverIcon = null;
22155
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.setCursor();
22156
- (_b = this.stage) === null || _b === void 0 ? void 0 : _b.renderNextFrame();
22209
+ this.setAttribute('hoverIconId', undefined);
22157
22210
  }
22158
22211
  });
22159
22212
  }
22213
+ updateHoverIconState(pickedIcon) {
22214
+ var _a, _b, _c, _d, _e;
22215
+ if (pickedIcon) {
22216
+ (_a = this._currentHoverIcon) === null || _a === void 0 ? void 0 : _a.setHoverState(false);
22217
+ this._currentHoverIcon = pickedIcon;
22218
+ this._currentHoverIcon.setHoverState(true);
22219
+ (_b = this.stage) === null || _b === void 0 ? void 0 : _b.setCursor(pickedIcon.attribute.cursor);
22220
+ (_c = this.stage) === null || _c === void 0 ? void 0 : _c.renderNextFrame();
22221
+ }
22222
+ else {
22223
+ this._currentHoverIcon.setHoverState(false);
22224
+ this._currentHoverIcon = null;
22225
+ (_d = this.stage) === null || _d === void 0 ? void 0 : _d.setCursor();
22226
+ (_e = this.stage) === null || _e === void 0 ? void 0 : _e.renderNextFrame();
22227
+ }
22228
+ }
22160
22229
  pickIcon(point) {
22161
22230
  const frameCache = this.getFrameCache();
22162
22231
  const { e: x, f: y } = this.globalTransMatrix;
22163
22232
  let pickIcon;
22164
- frameCache.icons.forEach(icon => {
22233
+ frameCache.icons.forEach((icon, key) => {
22165
22234
  var _a, _b;
22166
22235
  const bounds = icon.AABBBounds.clone();
22167
22236
  bounds.translate(icon._marginArray[3], icon._marginArray[0]);
@@ -24415,8 +24484,8 @@ class Stage extends Group {
24415
24484
  this.setAttributes({ background: this._background });
24416
24485
  }
24417
24486
  }
24418
- pauseRender() {
24419
- this._skipRender = -1;
24487
+ pauseRender(sr = -1) {
24488
+ this._skipRender = sr;
24420
24489
  }
24421
24490
  resumeRender() {
24422
24491
  this._skipRender = 0;
@@ -24875,10 +24944,7 @@ class Stage extends Group {
24875
24944
  if (this.releaseStatus === 'released') {
24876
24945
  return;
24877
24946
  }
24878
- if (!this.pickerService) {
24879
- this.pickerService = container.get(PickerService);
24880
- }
24881
- const result = this.pickerService.pick(this.children, new Point(x, y), {
24947
+ const result = this.getPickerService().pick(this.children, new Point(x, y), {
24882
24948
  bounds: this.AABBBounds
24883
24949
  });
24884
24950
  if ((result === null || result === void 0 ? void 0 : result.graphic) || (result === null || result === void 0 ? void 0 : result.group)) {
@@ -25011,6 +25077,12 @@ class Stage extends Group {
25011
25077
  resumeTriggerEvent() {
25012
25078
  this._eventSystem && this._eventSystem.resumeTriggerEvent();
25013
25079
  }
25080
+ getPickerService() {
25081
+ if (!this.pickerService) {
25082
+ this.pickerService = container.get(PickerService);
25083
+ }
25084
+ return this.pickerService;
25085
+ }
25014
25086
  }
25015
25087
 
25016
25088
  function createStage(params) {
@@ -24,7 +24,7 @@ export class BoundsContext {
24
24
  this.bounds.add(cx + xmin, cy + ymin), this.bounds.add(cx + xmax, cy + ymax);
25
25
  }
26
26
  arcTo(x1, y1, x2, y2, radius) {
27
- throw new Error("不支持arcTo");
27
+ this.bounds.add(x1, y1);
28
28
  }
29
29
  bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
30
30
  this.bounds.add(cp1x, cp1y), this.bounds.add(cp2x, cp2y), this.bounds.add(x, y);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/bounds-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC;AAgCnC,MAA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AAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,GAAG,MAAW;QAEpB,OAAO;IACT,CAAC;CACF","file":"bounds-context.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport { halfPi, tau } from '@visactor/vutils';\nimport type { IPath2D } from '../interface';\n\nconst circleThreshold = tau - 1e-8;\n\n/**\n * 借鉴 https://github.com/vega/vega/blob/b45cf431cd6c0d0c0e1567f087f9b3b55bc236fa/packages/vega-scenegraph/src/bound/boundContext.js\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nexport class BoundsContext implements IPath2D {\n bounds: IBounds;\n constructor(bounds: IBounds) {\n this.init(bounds);\n }\n\n init(bounds: IBounds) {\n this.bounds = bounds;\n }\n\n // @ts-ignore\n arc(cx: number, cy: number, r: number, sa: number, ea: number, ccw: boolean) {\n if (Math.abs(ea - sa) > circleThreshold) {\n this.bounds.add(cx - r, cy - r);\n this.bounds.add(cx + r, cy + r);\n return;\n }\n\n let xmin = Infinity;\n let xmax = -Infinity;\n let ymin = Infinity;\n let ymax = -Infinity;\n let s;\n let i;\n let x;\n let y;\n\n function update(a: number) {\n x = r * Math.cos(a);\n y = r * Math.sin(a);\n if (x < xmin) {\n xmin = x;\n }\n if (x > xmax) {\n xmax = x;\n }\n if (y < ymin) {\n ymin = y;\n }\n if (y > ymax) {\n ymax = y;\n }\n }\n\n // Sample end points and interior points aligned with 90 degrees\n update(sa);\n update(ea);\n\n if (ea !== sa) {\n sa = sa % tau;\n if (sa < 0) {\n sa += tau;\n }\n ea = ea % tau;\n if (ea < 0) {\n ea += tau;\n }\n\n if (ea < sa) {\n ccw = !ccw; // flip direction\n s = sa;\n sa = ea;\n ea = s; // swap end-points\n }\n\n if (ccw) {\n ea -= tau;\n s = sa - (sa % halfPi);\n for (i = 0; i < 4 && s > ea; ++i, s -= halfPi) {\n update(s);\n }\n } else {\n s = sa - (sa % halfPi) + halfPi;\n for (i = 0; i < 4 && s < ea; ++i, s = s + halfPi) {\n update(s);\n }\n }\n }\n\n this.bounds.add(cx + xmin, cy + ymin);\n this.bounds.add(cx + xmax, cy + ymax);\n }\n // @ts-ignore\n arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void {\n throw new Error('不支持arcTo');\n }\n // @ts-ignore\n bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void {\n this.bounds.add(cp1x, cp1y);\n this.bounds.add(cp2x, cp2y);\n this.bounds.add(x, y);\n }\n // @ts-ignore\n closePath(): void {\n // do nothing\n }\n // @ts-ignore\n ellipse(): void {\n throw new Error('不支持ellipse');\n }\n // @ts-ignore\n lineTo(x: number, y: number): void {\n this.bounds.add(x, y);\n }\n // @ts-ignore\n moveTo(x: number, y: number): void {\n this.bounds.add(x, y);\n }\n // @ts-ignore\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void {\n this.bounds.add(cpx, cpy);\n this.bounds.add(x, y);\n }\n // @ts-ignore\n rect(x: number, y: number, w: number, h: number): void {\n this.bounds.add(x, y);\n this.bounds.add(x + w, y + h);\n }\n\n clear() {\n this.bounds.clear();\n }\n\n release(...params: any): void {\n // 不需要dispose\n return;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/common/bounds-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC;AAgCnC,MAAM,OAAO,aAAa;IAExB,YAAY,MAAe;QACzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,MAAe;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAGD,GAAG,CAAC,EAAU,EAAE,EAAU,EAAE,CAAS,EAAE,EAAU,EAAE,EAAU,EAAE,GAAY;QACzE,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,EAAE;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAA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C,CAAC;IACxB,CAAC;IAED,SAAS;IAET,CAAC;IAED,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,CAAS,EAAE,CAAS;QACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,gBAAgB,CAAC,GAAW,EAAE,GAAW,EAAE,CAAS,EAAE,CAAS;QAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,GAAG,MAAW;QAEpB,OAAO;IACT,CAAC;CACF","file":"bounds-context.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport { halfPi, tau } from '@visactor/vutils';\nimport type { IPath2D } from '../interface';\n\nconst circleThreshold = tau - 1e-8;\n\n/**\n * 借鉴 https://github.com/vega/vega/blob/b45cf431cd6c0d0c0e1567f087f9b3b55bc236fa/packages/vega-scenegraph/src/bound/boundContext.js\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\nexport class BoundsContext implements IPath2D {\n bounds: IBounds;\n constructor(bounds: IBounds) {\n this.init(bounds);\n }\n\n init(bounds: IBounds) {\n this.bounds = bounds;\n }\n\n // @ts-ignore\n arc(cx: number, cy: number, r: number, sa: number, ea: number, ccw: boolean) {\n if (Math.abs(ea - sa) > circleThreshold) {\n this.bounds.add(cx - r, cy - r);\n this.bounds.add(cx + r, cy + r);\n return;\n }\n\n let xmin = Infinity;\n let xmax = -Infinity;\n let ymin = Infinity;\n let ymax = -Infinity;\n let s;\n let i;\n let x;\n let y;\n\n function update(a: number) {\n x = r * Math.cos(a);\n y = r * Math.sin(a);\n if (x < xmin) {\n xmin = x;\n }\n if (x > xmax) {\n xmax = x;\n }\n if (y < ymin) {\n ymin = y;\n }\n if (y > ymax) {\n ymax = y;\n }\n }\n\n // Sample end points and interior points aligned with 90 degrees\n update(sa);\n update(ea);\n\n if (ea !== sa) {\n sa = sa % tau;\n if (sa < 0) {\n sa += tau;\n }\n ea = ea % tau;\n if (ea < 0) {\n ea += tau;\n }\n\n if (ea < sa) {\n ccw = !ccw; // flip direction\n s = sa;\n sa = ea;\n ea = s; // swap end-points\n }\n\n if (ccw) {\n ea -= tau;\n s = sa - (sa % halfPi);\n for (i = 0; i < 4 && s > ea; ++i, s -= halfPi) {\n update(s);\n }\n } else {\n s = sa - (sa % halfPi) + halfPi;\n for (i = 0; i < 4 && s < ea; ++i, s = s + halfPi) {\n update(s);\n }\n }\n }\n\n this.bounds.add(cx + xmin, cy + ymin);\n this.bounds.add(cx + xmax, cy + ymax);\n }\n // @ts-ignore\n arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void {\n // 主要用于绘制圆角的场景,暂时只算第一个控制点\n this.bounds.add(x1, y1);\n // this.bounds.add(x2, y2);\n }\n // @ts-ignore\n bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void {\n this.bounds.add(cp1x, cp1y);\n this.bounds.add(cp2x, cp2y);\n this.bounds.add(x, y);\n }\n // @ts-ignore\n closePath(): void {\n // do nothing\n }\n // @ts-ignore\n ellipse(): void {\n throw new Error('不支持ellipse');\n }\n // @ts-ignore\n lineTo(x: number, y: number): void {\n this.bounds.add(x, y);\n }\n // @ts-ignore\n moveTo(x: number, y: number): void {\n this.bounds.add(x, y);\n }\n // @ts-ignore\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void {\n this.bounds.add(cpx, cpy);\n this.bounds.add(x, y);\n }\n // @ts-ignore\n rect(x: number, y: number, w: number, h: number): void {\n this.bounds.add(x, y);\n this.bounds.add(x + w, y + h);\n }\n\n clear() {\n this.bounds.clear();\n }\n\n release(...params: any): void {\n // 不需要dispose\n return;\n }\n}\n"]}
@@ -34,7 +34,10 @@ export function drawArc(context, x, y, coords) {
34
34
  }
35
35
 
36
36
  export const addArcToBezierPath = (bezierPath, startAngle, endAngle, cx, cy, rx, ry) => {
37
- const delta = Math.abs(endAngle - startAngle), len = 4 * Math.tan(delta / 4) / 3, dir = endAngle < startAngle ? -1 : 1, c1 = Math.cos(startAngle), s1 = Math.sin(startAngle), c2 = Math.cos(endAngle), s2 = Math.sin(endAngle), x1 = c1 * rx + cx, y1 = s1 * ry + cy, x4 = c2 * rx + cx, y4 = s2 * ry + cy, hx = rx * len * dir, hy = ry * len * dir;
38
- bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
37
+ const delta = Math.abs(endAngle - startAngle), count = delta > .5 * Math.PI ? Math.ceil(2 * delta / Math.PI) : 1, stepAngle = (endAngle - startAngle) / count;
38
+ for (let i = 0; i < count; i++) {
39
+ const sa = startAngle + stepAngle * i, ea = startAngle + stepAngle * (i + 1), len = 4 * Math.tan(Math.abs(stepAngle) / 4) / 3, dir = ea < sa ? -1 : 1, c1 = Math.cos(sa), s1 = Math.sin(sa), c2 = Math.cos(ea), s2 = Math.sin(ea), x1 = c1 * rx + cx, y1 = s1 * ry + cy, x4 = c2 * rx + cx, y4 = s2 * ry + cy, hx = rx * len * dir, hy = ry * len * dir;
40
+ bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
41
+ }
39
42
  };
40
43
  //# sourceMappingURL=arc.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/shape/arc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AA0B/D,MAAM,UAAU,QAAQ,CACtB,CAAS,EACT,CAAS,EACT,EAAU,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,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3C,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE9B,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACxB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAExB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IACxB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAExB,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;IAC1B,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;IAE1B,UAAU,CAAC,IAAI,CAEb,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,EACF,EAAE,CACH,CAAC;AACJ,CAAC,CAAC","file":"arc.js","sourcesContent":["import { degreeToRadian, halfPi, tau } from '@visactor/vutils';\nimport type { ICustomPath2D } from '../../interface';\n\n// const segmentCache: Record<string, number[][]> = {};\n// const bezierCache: Record<string, [number, number, number, number, number, number]> = {};\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// 基于d3-shape重构\n// const join = [].join;\n\n// Copied from Inkscape svgtopdf, thanks!\nexport function segments(\n x: number,\n y: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: number,\n ox: number,\n oy: number\n) {\n // const key = join.call([x, y, rx, ry, large, sweep, rotateX, ox, oy]);\n // if (segmentCache[key]) {\n // return segmentCache[key];\n // }\n\n const th = degreeToRadian(rotateX);\n const sin_th = Math.sin(th);\n const cos_th = Math.cos(th);\n rx = Math.abs(rx);\n ry = Math.abs(ry);\n const px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5;\n const py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5;\n let pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);\n if (pl > 1) {\n pl = Math.sqrt(pl);\n rx *= pl;\n ry *= pl;\n }\n\n const a00 = cos_th / rx;\n const a01 = sin_th / rx;\n const a10 = -sin_th / ry;\n const a11 = cos_th / ry;\n const x0 = a00 * ox + a01 * oy;\n const y0 = a10 * ox + a11 * oy;\n const x1 = a00 * x + a01 * y;\n const y1 = a10 * x + a11 * y;\n\n const d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);\n let sfactor_sq = 1 / d - 0.25;\n if (sfactor_sq < 0) {\n sfactor_sq = 0;\n }\n let sfactor = Math.sqrt(sfactor_sq);\n if (sweep === large) {\n sfactor = -sfactor;\n }\n const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);\n const yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);\n\n const th0 = Math.atan2(y0 - yc, x0 - xc);\n const th1 = Math.atan2(y1 - yc, x1 - xc);\n\n let th_arc = th1 - th0;\n if (th_arc < 0 && sweep === 1) {\n th_arc += tau;\n } else if (th_arc > 0 && sweep === 0) {\n th_arc -= tau;\n }\n\n const segs = Math.ceil(Math.abs(th_arc / (halfPi + 0.001)));\n const result = [];\n for (let i = 0; i < segs; ++i) {\n const th2 = th0 + (i * th_arc) / segs;\n const th3 = th0 + ((i + 1) * th_arc) / segs;\n result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th];\n }\n\n return result;\n}\n\nexport function bezier(params: number[]) {\n // const key = join.call(params);\n // if (bezierCache[key]) {\n // return bezierCache[key];\n // }\n\n const cx = params[0];\n const cy = params[1];\n const th0 = params[2];\n const th1 = params[3];\n const rx = params[4];\n const ry = params[5];\n const sin_th = params[6];\n const cos_th = params[7];\n\n const a00 = cos_th * rx;\n const a01 = -sin_th * ry;\n const a10 = sin_th * rx;\n const a11 = cos_th * ry;\n\n const cos_th0 = Math.cos(th0);\n const sin_th0 = Math.sin(th0);\n const cos_th1 = Math.cos(th1);\n const sin_th1 = Math.sin(th1);\n\n const th_half = 0.5 * (th1 - th0);\n const sin_th_h2 = Math.sin(th_half * 0.5);\n const t = ((8 / 3) * sin_th_h2 * sin_th_h2) / Math.sin(th_half);\n const x1 = cx + cos_th0 - t * sin_th0;\n const y1 = cy + sin_th0 + t * cos_th0;\n const x3 = cx + cos_th1;\n const y3 = cy + sin_th1;\n const x2 = x3 + t * sin_th1;\n const y2 = y3 - t * cos_th1;\n\n return [\n a00 * x1 + a01 * y1,\n a10 * x1 + a11 * y1,\n a00 * x2 + a01 * y2,\n a10 * x2 + a11 * y2,\n a00 * x3 + a01 * y3,\n a10 * x3 + a11 * y3\n ];\n}\n\nexport function drawArc(\n context: ICustomPath2D,\n x: number,\n y: number,\n coords: [number, number, number, number, number, number, number]\n) {\n const seg = segments(\n coords[5], // end x\n coords[6], // end y\n coords[0], // radius x\n coords[1], // radius y\n coords[3], // large flag\n coords[4], // sweep flag\n coords[2], // rotation\n x,\n y\n );\n for (let i = 0; i < seg.length; ++i) {\n const bez = bezier(seg[i]);\n context.bezierCurveTo(bez[0], bez[1], bez[2], bez[3], bez[4], bez[5]);\n }\n}\n\n/* Adapted from zrender by ecomfe\n * https://github.com/ecomfe/zrender\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/ecomfe/zrender/blob/master/src/tool/morphPath.ts\n * License: https://github.com/ecomfe/zrender/blob/master/LICENSE\n * @license\n */\n\nexport const addArcToBezierPath = (\n bezierPath: number[],\n startAngle: number,\n endAngle: number,\n cx: number,\n cy: number,\n rx: number,\n ry: number\n) => {\n // https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves\n const delta = Math.abs(endAngle - startAngle);\n const len = (Math.tan(delta / 4) * 4) / 3;\n const dir = endAngle < startAngle ? -1 : 1;\n\n const c1 = Math.cos(startAngle);\n const s1 = Math.sin(startAngle);\n const c2 = Math.cos(endAngle);\n const s2 = Math.sin(endAngle);\n\n const x1 = c1 * rx + cx;\n const y1 = s1 * ry + cy;\n\n const x4 = c2 * rx + cx;\n const y4 = s2 * ry + cy;\n\n const hx = rx * len * dir;\n const hy = ry * len * dir;\n\n bezierPath.push(\n // Move control points on tangent.\n x1 - hx * s1,\n y1 + hy * c1,\n x4 + hx * s2,\n y4 - hy * c2,\n x4,\n y4\n );\n};\n"]}
1
+ {"version":3,"sources":["../src/common/shape/arc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE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,CAAC;QACxB,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAExB,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;QAE1B,UAAU,CAAC,IAAI,CAEb,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,GAAG,EAAE,GAAG,EAAE,EACZ,EAAE,EACF,EAAE,CACH,CAAC;KACH;AACH,CAAC,CAAC","file":"arc.js","sourcesContent":["import { degreeToRadian, halfPi, tau } from '@visactor/vutils';\nimport type { ICustomPath2D } from '../../interface';\n\n// const segmentCache: Record<string, number[][]> = {};\n// const bezierCache: Record<string, [number, number, number, number, number, number]> = {};\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// 基于d3-shape重构\n// const join = [].join;\n\n// Copied from Inkscape svgtopdf, thanks!\nexport function segments(\n x: number,\n y: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: number,\n ox: number,\n oy: number\n) {\n // const key = join.call([x, y, rx, ry, large, sweep, rotateX, ox, oy]);\n // if (segmentCache[key]) {\n // return segmentCache[key];\n // }\n\n const th = degreeToRadian(rotateX);\n const sin_th = Math.sin(th);\n const cos_th = Math.cos(th);\n rx = Math.abs(rx);\n ry = Math.abs(ry);\n const px = cos_th * (ox - x) * 0.5 + sin_th * (oy - y) * 0.5;\n const py = cos_th * (oy - y) * 0.5 - sin_th * (ox - x) * 0.5;\n let pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);\n if (pl > 1) {\n pl = Math.sqrt(pl);\n rx *= pl;\n ry *= pl;\n }\n\n const a00 = cos_th / rx;\n const a01 = sin_th / rx;\n const a10 = -sin_th / ry;\n const a11 = cos_th / ry;\n const x0 = a00 * ox + a01 * oy;\n const y0 = a10 * ox + a11 * oy;\n const x1 = a00 * x + a01 * y;\n const y1 = a10 * x + a11 * y;\n\n const d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);\n let sfactor_sq = 1 / d - 0.25;\n if (sfactor_sq < 0) {\n sfactor_sq = 0;\n }\n let sfactor = Math.sqrt(sfactor_sq);\n if (sweep === large) {\n sfactor = -sfactor;\n }\n const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);\n const yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);\n\n const th0 = Math.atan2(y0 - yc, x0 - xc);\n const th1 = Math.atan2(y1 - yc, x1 - xc);\n\n let th_arc = th1 - th0;\n if (th_arc < 0 && sweep === 1) {\n th_arc += tau;\n } else if (th_arc > 0 && sweep === 0) {\n th_arc -= tau;\n }\n\n const segs = Math.ceil(Math.abs(th_arc / (halfPi + 0.001)));\n const result = [];\n for (let i = 0; i < segs; ++i) {\n const th2 = th0 + (i * th_arc) / segs;\n const th3 = th0 + ((i + 1) * th_arc) / segs;\n result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th];\n }\n\n return result;\n}\n\nexport function bezier(params: number[]) {\n // const key = join.call(params);\n // if (bezierCache[key]) {\n // return bezierCache[key];\n // }\n\n const cx = params[0];\n const cy = params[1];\n const th0 = params[2];\n const th1 = params[3];\n const rx = params[4];\n const ry = params[5];\n const sin_th = params[6];\n const cos_th = params[7];\n\n const a00 = cos_th * rx;\n const a01 = -sin_th * ry;\n const a10 = sin_th * rx;\n const a11 = cos_th * ry;\n\n const cos_th0 = Math.cos(th0);\n const sin_th0 = Math.sin(th0);\n const cos_th1 = Math.cos(th1);\n const sin_th1 = Math.sin(th1);\n\n const th_half = 0.5 * (th1 - th0);\n const sin_th_h2 = Math.sin(th_half * 0.5);\n const t = ((8 / 3) * sin_th_h2 * sin_th_h2) / Math.sin(th_half);\n const x1 = cx + cos_th0 - t * sin_th0;\n const y1 = cy + sin_th0 + t * cos_th0;\n const x3 = cx + cos_th1;\n const y3 = cy + sin_th1;\n const x2 = x3 + t * sin_th1;\n const y2 = y3 - t * cos_th1;\n\n return [\n a00 * x1 + a01 * y1,\n a10 * x1 + a11 * y1,\n a00 * x2 + a01 * y2,\n a10 * x2 + a11 * y2,\n a00 * x3 + a01 * y3,\n a10 * x3 + a11 * y3\n ];\n}\n\nexport function drawArc(\n context: ICustomPath2D,\n x: number,\n y: number,\n coords: [number, number, number, number, number, number, number]\n) {\n const seg = segments(\n coords[5], // end x\n coords[6], // end y\n coords[0], // radius x\n coords[1], // radius y\n coords[3], // large flag\n coords[4], // sweep flag\n coords[2], // rotation\n x,\n y\n );\n for (let i = 0; i < seg.length; ++i) {\n const bez = bezier(seg[i]);\n context.bezierCurveTo(bez[0], bez[1], bez[2], bez[3], bez[4], bez[5]);\n }\n}\n\n/* Adapted from zrender by ecomfe\n * https://github.com/ecomfe/zrender\n * Licensed under the BSD-3-Clause\n\n * url: https://github.com/ecomfe/zrender/blob/master/src/tool/morphPath.ts\n * License: https://github.com/ecomfe/zrender/blob/master/LICENSE\n * @license\n */\n\nexport const addArcToBezierPath = (\n bezierPath: number[],\n startAngle: number,\n endAngle: number,\n cx: number,\n cy: number,\n rx: number,\n ry: number\n) => {\n // https://stackoverflow.com/questions/1734745/how-to-create-circle-with-b%C3%A9zier-curves\n const delta = Math.abs(endAngle - startAngle);\n const count = delta > 0.5 * Math.PI ? Math.ceil((2 * delta) / Math.PI) : 1;\n const stepAngle = (endAngle - startAngle) / count;\n\n for (let i = 0; i < count; i++) {\n const sa = startAngle + stepAngle * i;\n const ea = startAngle + stepAngle * (i + 1);\n const len = (Math.tan(Math.abs(stepAngle) / 4) * 4) / 3;\n const dir = ea < sa ? -1 : 1;\n\n const c1 = Math.cos(sa);\n const s1 = Math.sin(sa);\n const c2 = Math.cos(ea);\n const s2 = Math.sin(ea);\n\n const x1 = c1 * rx + cx;\n const y1 = s1 * ry + cy;\n\n const x4 = c2 * rx + cx;\n const y4 = s2 * ry + cy;\n\n const hx = rx * len * dir;\n const hy = ry * len * dir;\n\n bezierPath.push(\n // Move control points on tangent.\n x1 - hx * s1,\n y1 + hy * c1,\n x4 + hx * s2,\n y4 - hy * c2,\n x4,\n y4\n );\n }\n};\n"]}
@@ -49,7 +49,7 @@ export declare class Stage extends Group implements IStage {
49
49
  readonly window: IWindow;
50
50
  private readonly global;
51
51
  readonly renderService: IRenderService;
52
- pickerService?: IPickerService;
52
+ protected pickerService?: IPickerService;
53
53
  readonly pluginService: IPluginService;
54
54
  readonly layerService: ILayerService;
55
55
  private _eventSystem?;
@@ -64,7 +64,7 @@ export declare class Stage extends Group implements IStage {
64
64
  protected timeline: ITimeline;
65
65
  params: Partial<IStageParams>;
66
66
  constructor(params?: Partial<IStageParams>);
67
- pauseRender(): void;
67
+ pauseRender(sr?: number): void;
68
68
  resumeRender(): void;
69
69
  protected tryInitEventSystem(): void;
70
70
  preventRender(prevent: boolean): void;
@@ -153,5 +153,6 @@ export declare class Stage extends Group implements IStage {
153
153
  };
154
154
  pauseTriggerEvent(): void;
155
155
  resumeTriggerEvent(): void;
156
+ getPickerService(): IPickerService;
156
157
  }
157
158
  export {};
package/es/core/stage.js CHANGED
@@ -153,8 +153,8 @@ export class Stage extends Group {
153
153
  background: this._background
154
154
  });
155
155
  }
156
- pauseRender() {
157
- this._skipRender = -1;
156
+ pauseRender(sr = -1) {
157
+ this._skipRender = sr;
158
158
  }
159
159
  resumeRender() {
160
160
  this._skipRender = 0;
@@ -447,8 +447,7 @@ export class Stage extends Group {
447
447
  }
448
448
  pick(x, y) {
449
449
  if ("released" === this.releaseStatus) return;
450
- this.pickerService || (this.pickerService = container.get(PickerService));
451
- const result = this.pickerService.pick(this.children, new Point(x, y), {
450
+ const result = this.getPickerService().pick(this.children, new Point(x, y), {
452
451
  bounds: this.AABBBounds
453
452
  });
454
453
  return !(!(null == result ? void 0 : result.graphic) && !(null == result ? void 0 : result.group)) && result;
@@ -528,5 +527,9 @@ export class Stage extends Group {
528
527
  resumeTriggerEvent() {
529
528
  this._eventSystem && this._eventSystem.resumeTriggerEvent();
530
529
  }
530
+ getPickerService() {
531
+ return this.pickerService || (this.pickerService = container.get(PickerService)),
532
+ this.pickerService;
533
+ }
531
534
  }
532
535
  //# sourceMappingURL=stage.js.map