@antv/g-canvas 1.7.3 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -415,19 +415,19 @@
415
415
  return _setPrototypeOf$1(o, p);
416
416
  }
417
417
 
418
- var PathGeneratorFactory = g.Syringe.defineToken('PathGeneratorFactory');
419
- var PathGenerator = g.Syringe.defineToken('PathGenerator');
418
+ var PathGeneratorFactory = g.Syringe.defineToken('');
419
+ var PathGenerator = g.Syringe.defineToken('');
420
420
 
421
421
  function generatePath(context, parsedStyle) {
422
422
  var r = parsedStyle.r;
423
- context.arc(r.value, r.value, r.value, 0, Math.PI * 2, false);
423
+ context.arc(r, r, r, 0, Math.PI * 2, false);
424
424
  }
425
425
 
426
426
  function generatePath$1(context, parsedStyle) {
427
427
  var rxInPixels = parsedStyle.rx,
428
428
  ryInPixels = parsedStyle.ry;
429
- var rx = rxInPixels.value;
430
- var ry = ryInPixels.value; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
429
+ var rx = rxInPixels;
430
+ var ry = ryInPixels; // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/ellipse
431
431
 
432
432
  if (context.ellipse) {
433
433
  context.ellipse(rx, ry, rx, ry, 0, 0, Math.PI * 2, false);
@@ -464,23 +464,23 @@
464
464
  var y;
465
465
 
466
466
  if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
467
- x = x2.value - x1.value;
468
- y = y2.value - y1.value;
467
+ x = x2 - x1;
468
+ y = y2 - y1;
469
469
  rad = Math.atan2(y, x);
470
- startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
471
- startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
470
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
471
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
472
472
  }
473
473
 
474
474
  if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
475
- x = x1.value - x2.value;
476
- y = y1.value - y2.value;
475
+ x = x1 - x2;
476
+ y = y1 - y2;
477
477
  rad = Math.atan2(y, x);
478
- endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
479
- endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
478
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
479
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
480
480
  }
481
481
 
482
- context.moveTo(x1.value - defX + startOffsetX, y1.value - defY + startOffsetY);
483
- context.lineTo(x2.value - defX + endOffsetX, y2.value - defY + endOffsetY);
482
+ context.moveTo(x1 - defX + startOffsetX, y1 - defY + startOffsetY);
483
+ context.lineTo(x2 - defX + endOffsetX, y2 - defY + endOffsetY);
484
484
  }
485
485
 
486
486
  function generatePath$3(context, parsedStyle) {
@@ -501,7 +501,7 @@
501
501
  path.splice(zIndex + index, 1, ['Z']);
502
502
  }); // @ts-ignore
503
503
 
504
- var isClosed = path[path.length - 1][0] === 'Z';
504
+ var isClosed = path.length && path[path.length - 1][0] === 'Z';
505
505
  var startOffsetX = 0;
506
506
  var startOffsetY = 0;
507
507
  var endOffsetX = 0;
@@ -518,8 +518,8 @@
518
518
  x = p1[0] - p2[0];
519
519
  y = p1[1] - p2[1];
520
520
  rad = Math.atan2(y, x);
521
- startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
522
- startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
521
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
522
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
523
523
  }
524
524
 
525
525
  if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
@@ -530,8 +530,8 @@
530
530
  x = _p[0] - _p2[0];
531
531
  y = _p[1] - _p2[1];
532
532
  rad = Math.atan2(y, x);
533
- endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
534
- endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
533
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
534
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
535
535
  }
536
536
 
537
537
  for (var i = 0; i < path.length; i++) {
@@ -585,16 +585,16 @@
585
585
  x = points[1][0] - points[0][0];
586
586
  y = points[1][1] - points[0][1];
587
587
  rad = Math.atan2(y, x);
588
- startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
589
- startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
588
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
589
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
590
590
  }
591
591
 
592
592
  if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
593
593
  x = points[length - 1][0] - points[0][0];
594
594
  y = points[length - 1][1] - points[0][1];
595
595
  rad = Math.atan2(y, x);
596
- endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
597
- endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
596
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
597
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
598
598
  }
599
599
 
600
600
  context.moveTo(x1 + (startOffsetX || endOffsetX), y1 + (startOffsetY || endOffsetY));
@@ -634,16 +634,16 @@
634
634
  x = points[1][0] - points[0][0];
635
635
  y = points[1][1] - points[0][1];
636
636
  rad = Math.atan2(y, x);
637
- startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
638
- startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
637
+ startOffsetX = Math.cos(rad) * (markerStartOffset || 0);
638
+ startOffsetY = Math.sin(rad) * (markerStartOffset || 0);
639
639
  }
640
640
 
641
641
  if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
642
642
  x = points[length - 2][0] - points[length - 1][0];
643
643
  y = points[length - 2][1] - points[length - 1][1];
644
644
  rad = Math.atan2(y, x);
645
- endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
646
- endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
645
+ endOffsetX = Math.cos(rad) * (markerEndOffset || 0);
646
+ endOffsetY = Math.sin(rad) * (markerEndOffset || 0);
647
647
  }
648
648
 
649
649
  context.moveTo(x1 + startOffsetX, y1 + startOffsetY);
@@ -660,22 +660,22 @@
660
660
  var radius = parsedStyle.radius,
661
661
  width = parsedStyle.width,
662
662
  height = parsedStyle.height;
663
- var w = width.value;
664
- var h = height.value;
663
+ var w = width;
664
+ var h = height;
665
665
  var hasRadius = radius && radius.some(function (r) {
666
- return r.value !== 0;
666
+ return r !== 0;
667
667
  });
668
668
 
669
669
  if (!hasRadius) {
670
670
  // Canvas support negative width/height of rect
671
671
  context.rect(0, 0, w, h);
672
672
  } else {
673
- var signX = width.value > 0 ? 1 : -1;
674
- var signY = height.value > 0 ? 1 : -1;
673
+ var signX = width > 0 ? 1 : -1;
674
+ var signY = height > 0 ? 1 : -1;
675
675
  var sweepFlag = signX + signY === 0;
676
676
 
677
677
  var _radius$map = radius.map(function (r) {
678
- return g.clamp(r.value, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
678
+ return g.clamp(r, 0, Math.min(Math.abs(w) / 2, Math.abs(h) / 2));
679
679
  }),
680
680
  tlr = _radius$map[0],
681
681
  trr = _radius$map[1],
@@ -1439,17 +1439,17 @@
1439
1439
  return out;
1440
1440
  }
1441
1441
  /**
1442
- * Creates a new vec3 initialized with the given values
1442
+ * Set the components of a vec3 to the given values
1443
1443
  *
1444
+ * @param {vec3} out the receiving vector
1444
1445
  * @param {Number} x X component
1445
1446
  * @param {Number} y Y component
1446
1447
  * @param {Number} z Z component
1447
- * @returns {vec3} a new 3D vector
1448
+ * @returns {vec3} out
1448
1449
  */
1449
1450
 
1450
1451
 
1451
- function fromValues(x, y, z) {
1452
- var out = new ARRAY_TYPE(3);
1452
+ function set(out, x, y, z) {
1453
1453
  out[0] = x;
1454
1454
  out[1] = y;
1455
1455
  out[2] = z;
@@ -1640,7 +1640,7 @@
1640
1640
  var _class;
1641
1641
 
1642
1642
  var CanvasPickerPlugin_1;
1643
- var PointInPathPickerFactory = g.Syringe.defineToken('PointInPathPicker');
1643
+ var PointInPathPickerFactory = g.Syringe.defineToken('');
1644
1644
  /**
1645
1645
  * pick shape(s) with Mouse/Touch event
1646
1646
  *
@@ -1659,6 +1659,9 @@
1659
1659
  this.pathGeneratorFactory = void 0;
1660
1660
  this.pathGeneratorFactoryCache = {};
1661
1661
  this.pointInPathPickerFactory = void 0;
1662
+ this.tmpVec3a = create$1();
1663
+ this.tmpVec3b = create$1();
1664
+ this.tmpVec3c = create$1();
1662
1665
 
1663
1666
  this.isHit = function (displayObject, position, worldTransform) {
1664
1667
  // use picker for current shape's type
@@ -1668,14 +1671,14 @@
1668
1671
  // invert with world matrix
1669
1672
  var invertWorldMat = invert(create(), worldTransform); // transform client position to local space, do picking in local space
1670
1673
 
1671
- var localPosition = transformMat4(create$1(), fromValues(position[0], position[1], 0), invertWorldMat); // account for anchor
1674
+ var localPosition = transformMat4(_this.tmpVec3b, set(_this.tmpVec3c, position[0], position[1], 0), invertWorldMat); // account for anchor
1672
1675
 
1673
1676
  var _displayObject$getGeo = displayObject.getGeometryBounds(),
1674
1677
  halfExtents = _displayObject$getGeo.halfExtents;
1675
1678
 
1676
1679
  var anchor = displayObject.parsedStyle.anchor;
1677
- localPosition[0] += (anchor && anchor[0].value || 0) * halfExtents[0] * 2;
1678
- localPosition[1] += (anchor && anchor[1].value || 0) * halfExtents[1] * 2;
1680
+ localPosition[0] += (anchor && anchor[0] || 0) * halfExtents[0] * 2;
1681
+ localPosition[1] += (anchor && anchor[1] || 0) * halfExtents[1] * 2;
1679
1682
 
1680
1683
  if (pick(displayObject, new g.Point(localPosition[0], localPosition[1]), _this.isPointInPath)) {
1681
1684
  return true;
@@ -1719,7 +1722,7 @@
1719
1722
  case 0:
1720
1723
  topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
1721
1724
 
1722
- position = fromValues(x, y, 0); // query by AABB first with spatial index(r-tree)
1725
+ position = set(_this2.tmpVec3a, x, y, 0); // query by AABB first with spatial index(r-tree)
1723
1726
 
1724
1727
  rBushNodes = _this2.rBush.search({
1725
1728
  minX: position[0],
@@ -2379,14 +2382,13 @@
2379
2382
 
2380
2383
  function isPointInPath(displayObject, position) {
2381
2384
  var _displayObject$parsed = displayObject.parsedStyle,
2382
- rInPixels = _displayObject$parsed.r,
2385
+ r = _displayObject$parsed.r,
2383
2386
  fill = _displayObject$parsed.fill,
2384
2387
  stroke = _displayObject$parsed.stroke,
2385
2388
  lineWidth = _displayObject$parsed.lineWidth,
2386
2389
  increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
2387
2390
  clipPathTargets = _displayObject$parsed.clipPathTargets;
2388
- var r = rInPixels.value;
2389
- var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2;
2391
+ var halfLineWidth = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) / 2;
2390
2392
  var absDistance = distance$1(r, r, position.x, position.y);
2391
2393
  var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
2392
2394
  var hasFill = fill && !fill.isNone;
@@ -2415,8 +2417,8 @@
2415
2417
  var x = _ref.x,
2416
2418
  y = _ref.y;
2417
2419
  var _displayObject$parsed = displayObject.parsedStyle,
2418
- rxInPixels = _displayObject$parsed.rx,
2419
- ryInPixels = _displayObject$parsed.ry,
2420
+ rx = _displayObject$parsed.rx,
2421
+ ry = _displayObject$parsed.ry,
2420
2422
  fill = _displayObject$parsed.fill,
2421
2423
  stroke = _displayObject$parsed.stroke,
2422
2424
  lineWidth = _displayObject$parsed.lineWidth,
@@ -2425,9 +2427,7 @@
2425
2427
  var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
2426
2428
  var hasFill = fill && !fill.isNone;
2427
2429
  var hasStroke = stroke && !stroke.isNone;
2428
- var rx = rxInPixels.value;
2429
- var ry = ryInPixels.value;
2430
- var halfLineWith = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2;
2430
+ var halfLineWith = ((lineWidth || 0) + (increasedLineWidthForHitTesting || 0)) / 2;
2431
2431
  var squareX = (x - rx) * (x - rx);
2432
2432
  var squareY = (y - ry) * (y - ry); // 使用椭圆的公式: x*x/rx*rx + y*y/ry*ry = 1;
2433
2433
 
@@ -2458,7 +2458,7 @@
2458
2458
  x = _displayObject$parsed2 === void 0 ? 0 : _displayObject$parsed2,
2459
2459
  _displayObject$parsed3 = _displayObject$parsed.defY,
2460
2460
  y = _displayObject$parsed3 === void 0 ? 0 : _displayObject$parsed3;
2461
- return inLine(x1.value, y1.value, x2.value, y2.value, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y);
2461
+ return inLine(x1, y1, x2, y2, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y);
2462
2462
  }
2463
2463
 
2464
2464
  function isPointInStroke(segments, lineWidth, px, py, length) {
@@ -2526,7 +2526,7 @@
2526
2526
 
2527
2527
  return isHit;
2528
2528
  } else if (hasStroke || isClipPath) {
2529
- isHit = isPointInStroke(segments, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, totalLength);
2529
+ isHit = isPointInStroke(segments, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y, totalLength);
2530
2530
  } // if (hasStroke || isClipPath) {
2531
2531
  // isHit = isPointInStroke(
2532
2532
  // segments,
@@ -2572,7 +2572,7 @@
2572
2572
  var isHit = false;
2573
2573
 
2574
2574
  if (hasStroke || isClipPath) {
2575
- isHit = inPolyline(points.points, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, true);
2575
+ isHit = inPolyline(points.points, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y, true);
2576
2576
  }
2577
2577
 
2578
2578
  if (!isHit && (hasFill || isClipPath)) {
@@ -2600,7 +2600,7 @@
2600
2600
  return false;
2601
2601
  }
2602
2602
 
2603
- return inPolyline(points.points, ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0), position.x + x, position.y + y, false);
2603
+ return inPolyline(points.points, (lineWidth || 0) + (increasedLineWidthForHitTesting || 0), position.x + x, position.y + y, false);
2604
2604
  }
2605
2605
 
2606
2606
  function isPointInPath$6(displayObject, position, isPointInPath) {
@@ -2610,31 +2610,16 @@
2610
2610
  stroke = _displayObject$parsed.stroke,
2611
2611
  lineWidth = _displayObject$parsed.lineWidth,
2612
2612
  increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
2613
- parsedWidth = _displayObject$parsed.width,
2614
- parsedHeight = _displayObject$parsed.height,
2613
+ width = _displayObject$parsed.width,
2614
+ height = _displayObject$parsed.height,
2615
2615
  clipPathTargets = _displayObject$parsed.clipPathTargets;
2616
2616
  var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
2617
2617
  var hasFill = fill && !fill.isNone;
2618
2618
  var hasStroke = stroke && !stroke.isNone;
2619
2619
  var hasRadius = radius && radius.some(function (r) {
2620
- return r.value !== 0;
2620
+ return r !== 0;
2621
2621
  });
2622
- var widthUnit = parsedWidth.unit,
2623
- widthValue = parsedWidth.value;
2624
- var heightUnit = parsedHeight.unit,
2625
- heightValue = parsedHeight.value;
2626
- var width = 0;
2627
- var height = 0;
2628
-
2629
- if (widthUnit === g.UnitType.kNumber || widthUnit === g.UnitType.kPixels) {
2630
- width = widthValue;
2631
- }
2632
-
2633
- if (heightUnit === g.UnitType.kNumber || heightUnit === g.UnitType.kPixels) {
2634
- height = heightValue;
2635
- }
2636
-
2637
- var lineWidthForHitTesting = ((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0); // 无圆角时的策略
2622
+ var lineWidthForHitTesting = (lineWidth || 0) + (increasedLineWidthForHitTesting || 0); // 无圆角时的策略
2638
2623
 
2639
2624
  if (!hasRadius) {
2640
2625
  var halfWidth = lineWidthForHitTesting / 2; // 同时填充和带有边框
@@ -2656,7 +2641,7 @@
2656
2641
 
2657
2642
  if (hasStroke || isClipPath) {
2658
2643
  isHit = inRectWithRadius(0, 0, width, height, radius.map(function (r) {
2659
- return g.clamp(r.value, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2644
+ return g.clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2660
2645
  }), lineWidthForHitTesting, position.x, position.y);
2661
2646
  } // 仅填充时带有圆角的矩形直接通过图形拾取
2662
2647
  // 以后可以改成纯数学的近似拾取,将圆弧切割成多边形
@@ -4116,7 +4101,7 @@
4116
4101
  */
4117
4102
 
4118
4103
 
4119
- function fromValues$1(x, y, z) {
4104
+ function fromValues(x, y, z) {
4120
4105
  var out = new ARRAY_TYPE$1(3);
4121
4106
  out[0] = x;
4122
4107
  out[1] = y;
@@ -4192,32 +4177,32 @@
4192
4177
  };
4193
4178
  }();
4194
4179
 
4195
- var StyleRendererFactory = g.Syringe.defineToken('StyleRendererFactory');
4196
- var CircleRendererContribution = g.Syringe.defineToken('CircleRenderer', {
4180
+ var StyleRendererFactory = g.Syringe.defineToken('');
4181
+ var CircleRendererContribution = g.Syringe.defineToken('', {
4197
4182
  multiple: false
4198
4183
  });
4199
- var EllipseRendererContribution = g.Syringe.defineToken('EllipseRenderer', {
4184
+ var EllipseRendererContribution = g.Syringe.defineToken('', {
4200
4185
  multiple: false
4201
4186
  });
4202
- var RectRendererContribution = g.Syringe.defineToken('RectRenderer', {
4187
+ var RectRendererContribution = g.Syringe.defineToken('', {
4203
4188
  multiple: false
4204
4189
  });
4205
- var LineRendererContribution = g.Syringe.defineToken('LineRenderer', {
4190
+ var LineRendererContribution = g.Syringe.defineToken('', {
4206
4191
  multiple: false
4207
4192
  });
4208
- var PolylineRendererContribution = g.Syringe.defineToken('PolylineRenderer', {
4193
+ var PolylineRendererContribution = g.Syringe.defineToken('', {
4209
4194
  multiple: false
4210
4195
  });
4211
- var PolygonRendererContribution = g.Syringe.defineToken('PolygonRenderer', {
4196
+ var PolygonRendererContribution = g.Syringe.defineToken('', {
4212
4197
  multiple: false
4213
4198
  });
4214
- var PathRendererContribution = g.Syringe.defineToken('PathRenderer', {
4199
+ var PathRendererContribution = g.Syringe.defineToken('', {
4215
4200
  multiple: false
4216
4201
  });
4217
- var TextRendererContribution = g.Syringe.defineToken('TextRenderer', {
4202
+ var TextRendererContribution = g.Syringe.defineToken('', {
4218
4203
  multiple: false
4219
4204
  });
4220
- var ImageRendererContribution = g.Syringe.defineToken('ImageRenderer', {
4205
+ var ImageRendererContribution = g.Syringe.defineToken('', {
4221
4206
  multiple: false
4222
4207
  });
4223
4208
 
@@ -4243,16 +4228,16 @@
4243
4228
  filter = parsedStyle.filter,
4244
4229
  miterLimit = parsedStyle.miterLimit;
4245
4230
  var hasFill = !g.isNil(fill) && !fill.isNone;
4246
- var hasStroke = !g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value > 0;
4231
+ var hasStroke = !g.isNil(stroke) && !stroke.isNone && lineWidth > 0;
4247
4232
  var isFillTransparent = fill.alpha === 0;
4248
- var hasFilter = !g.isNil(filter);
4249
- var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4233
+ var hasFilter = !!(filter && filter.length);
4234
+ var hasShadow = !g.isNil(shadowColor) && shadowBlur > 0;
4250
4235
  var nodeName = object.nodeName;
4251
- var isInnerShadow = (shadowType === null || shadowType === void 0 ? void 0 : shadowType.value) === 'inner';
4236
+ var isInnerShadow = shadowType === 'inner';
4252
4237
  var shouldDrawShadowWithStroke = hasStroke && hasShadow && (nodeName === g.Shape.PATH || nodeName === g.Shape.LINE || nodeName === g.Shape.POLYLINE || isFillTransparent || isInnerShadow);
4253
4238
 
4254
4239
  if (hasFill) {
4255
- context.globalAlpha = opacity.value * fillOpacity.value;
4240
+ context.globalAlpha = opacity * fillOpacity;
4256
4241
 
4257
4242
  if (!shouldDrawShadowWithStroke) {
4258
4243
  setShadowAndFilter(object, context, hasShadow);
@@ -4266,19 +4251,19 @@
4266
4251
  }
4267
4252
 
4268
4253
  if (hasStroke) {
4269
- context.globalAlpha = opacity.value * strokeOpacity.value;
4270
- context.lineWidth = lineWidth.value;
4254
+ context.globalAlpha = opacity * strokeOpacity;
4255
+ context.lineWidth = lineWidth;
4271
4256
 
4272
4257
  if (!g.isNil(miterLimit)) {
4273
- context.miterLimit = miterLimit.value;
4258
+ context.miterLimit = miterLimit;
4274
4259
  }
4275
4260
 
4276
4261
  if (!g.isNil(lineCap)) {
4277
- context.lineCap = lineCap.value;
4262
+ context.lineCap = lineCap;
4278
4263
  }
4279
4264
 
4280
4265
  if (!g.isNil(lineJoin)) {
4281
- context.lineJoin = lineJoin.value;
4266
+ context.lineJoin = lineJoin;
4282
4267
  }
4283
4268
 
4284
4269
  if (shouldDrawShadowWithStroke) {
@@ -4394,16 +4379,16 @@
4394
4379
  shadowOffsetX = _object$parsedStyle.shadowOffsetX,
4395
4380
  shadowOffsetY = _object$parsedStyle.shadowOffsetY;
4396
4381
 
4397
- if (!g.isNil(filter)) {
4382
+ if (filter && filter.length) {
4398
4383
  // use raw filter string
4399
4384
  context.filter = object.style.filter;
4400
4385
  }
4401
4386
 
4402
4387
  if (hasShadow) {
4403
4388
  context.shadowColor = shadowColor.toString();
4404
- context.shadowBlur = shadowBlur && shadowBlur.value || 0;
4405
- context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
4406
- context.shadowOffsetY = shadowOffsetY && shadowOffsetY.value || 0;
4389
+ context.shadowBlur = shadowBlur || 0;
4390
+ context.shadowOffsetX = shadowOffsetX || 0;
4391
+ context.shadowOffsetY = shadowOffsetY || 0;
4407
4392
  }
4408
4393
  }
4409
4394
 
@@ -4421,8 +4406,8 @@
4421
4406
  shadowColor = parsedStyle.shadowColor,
4422
4407
  shadowBlur = parsedStyle.shadowBlur;
4423
4408
  var image;
4424
- var iw = width.value;
4425
- var ih = height.value;
4409
+ var iw = width;
4410
+ var ih = height;
4426
4411
 
4427
4412
  if (g.isString(img)) {
4428
4413
  // image has been loaded in `mounted` hook
@@ -4434,7 +4419,7 @@
4434
4419
  }
4435
4420
 
4436
4421
  if (image) {
4437
- var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4422
+ var hasShadow = !g.isNil(shadowColor) && shadowBlur > 0;
4438
4423
  setShadowAndFilter(object, context, hasShadow); // node-canvas will throw the following err:
4439
4424
  // Error: Image given has not completed loading
4440
4425
 
@@ -4481,50 +4466,42 @@
4481
4466
  lineHeight = metrics.lineHeight,
4482
4467
  lineMetrics = metrics.lineMetrics;
4483
4468
  context.font = font;
4484
- context.lineWidth = lineWidth.value;
4485
- context.textAlign = textAlign.value;
4486
- context.textBaseline = textBaseline.value;
4487
- context.lineJoin = lineJoin.value;
4469
+ context.lineWidth = lineWidth;
4470
+ context.textAlign = textAlign;
4471
+ context.textBaseline = textBaseline;
4472
+ context.lineJoin = lineJoin;
4488
4473
 
4489
4474
  if (!g.isNil(miterLimit)) {
4490
- context.miterLimit = miterLimit.value;
4475
+ context.miterLimit = miterLimit;
4491
4476
  }
4492
4477
 
4493
4478
  var linePositionY = 0; // handle vertical text baseline
4494
4479
 
4495
- if (textBaseline.value === 'middle') {
4480
+ if (textBaseline === 'middle') {
4496
4481
  linePositionY = -height / 2 - lineHeight / 2;
4497
- } else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
4482
+ } else if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
4498
4483
  linePositionY = -height;
4499
- } else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
4484
+ } else if (textBaseline === 'top' || textBaseline === 'hanging') {
4500
4485
  linePositionY = -lineHeight;
4501
4486
  } // account for dx & dy
4502
4487
 
4503
4488
 
4504
- var offsetX = 0;
4505
-
4506
- if (dx && dx.unit === g.UnitType.kPixels) {
4507
- offsetX += dx.value;
4508
- }
4509
-
4510
- if (dy && dy.unit === g.UnitType.kPixels) {
4511
- linePositionY += dy.value;
4512
- }
4513
-
4514
- var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
4489
+ var offsetX = dx || 0;
4490
+ linePositionY += dy || 0;
4491
+ var hasShadow = !g.isNil(shadowColor) && shadowBlur > 0;
4515
4492
  setShadowAndFilter(object, context, hasShadow); // draw lines line by line
4516
4493
 
4517
4494
  for (var i = 0; i < lines.length; i++) {
4518
- var linePositionX = lineWidth.value / 2 + offsetX;
4495
+ var linePositionX = lineWidth / 2 + offsetX;
4519
4496
  linePositionY += lineHeight; // no need to re-position X, cause we already set text align
4520
4497
  // @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
4521
4498
 
4522
- if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
4523
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value, true);
4499
+ if (!g.isNil(stroke) && !stroke.isNone && lineWidth) {
4500
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity, true);
4524
4501
  }
4525
4502
 
4526
4503
  if (!g.isNil(fill)) {
4527
- this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing.value, fillOpacity.value, strokeOpacity.value, opacity.value);
4504
+ this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign, linePositionX, linePositionY, letterSpacing, fillOpacity, strokeOpacity, opacity);
4528
4505
  }
4529
4506
  }
4530
4507
  };
@@ -4713,7 +4690,7 @@
4713
4690
  PathRenderer = __decorate([g.singleton({
4714
4691
  token: PathRendererContribution
4715
4692
  })], PathRenderer);
4716
- var CanvasRendererPluginOptions = g.Syringe.defineToken('CanvasRendererPluginOptions');
4693
+ var CanvasRendererPluginOptions = g.Syringe.defineToken('');
4717
4694
 
4718
4695
  var _class$2;
4719
4696
 
@@ -4744,7 +4721,10 @@
4744
4721
  this.vpMatrix = create$3();
4745
4722
  this.dprMatrix = create$3();
4746
4723
  this.tmpMat4 = create$3();
4747
- this.tmpVec3 = create$1$1();
4724
+ this.vec3a = create$1$1();
4725
+ this.vec3b = create$1$1();
4726
+ this.vec3c = create$1$1();
4727
+ this.vec3d = create$1$1();
4748
4728
  }
4749
4729
 
4750
4730
  var _proto = CanvasRendererPlugin.prototype;
@@ -4795,7 +4775,7 @@
4795
4775
 
4796
4776
  _this.clearRect(context, 0, 0, width * dpr, height * dpr);
4797
4777
 
4798
- fromScaling(_this.dprMatrix, fromValues$1(dpr, dpr, 1));
4778
+ fromScaling(_this.dprMatrix, fromValues(dpr, dpr, 1));
4799
4779
 
4800
4780
  case 7:
4801
4781
  case "end":
@@ -4843,14 +4823,13 @@
4843
4823
 
4844
4824
 
4845
4825
  _this.saveDirtyAABB(object);
4846
- } // should account for z-index
4826
+ }
4847
4827
 
4828
+ var sorted = object.sortable.sorted || object.childNodes; // should account for z-index
4848
4829
 
4849
- if (object.sortable.sorted && object.sortable.sorted.length) {
4850
- object.sortable.sorted.forEach(function (child) {
4851
- renderByZIndex(child);
4852
- });
4853
- }
4830
+ sorted.forEach(function (child) {
4831
+ renderByZIndex(child);
4832
+ });
4854
4833
  }; // render at the end of frame
4855
4834
 
4856
4835
 
@@ -4870,7 +4849,7 @@
4870
4849
  maxX = _ref2.maxX,
4871
4850
  maxY = _ref2.maxY;
4872
4851
  var aabb = new g.AABB();
4873
- aabb.setMinMax(fromValues$1(minX, minY, 0), fromValues$1(maxX, maxY, 0));
4852
+ aabb.setMinMax(fromValues(minX, minY, 0), fromValues(maxX, maxY, 0));
4874
4853
  return aabb;
4875
4854
  })));
4876
4855
 
@@ -4887,12 +4866,18 @@
4887
4866
  y = dirtyRect.y,
4888
4867
  width = dirtyRect.width,
4889
4868
  height = dirtyRect.height;
4890
- var tl = transformMat4$1(_this.tmpVec3, fromValues$1(x, y, 0), _this.vpMatrix);
4891
- var br = transformMat4$1(create$1$1(), fromValues$1(x + width, y + height, 0), _this.vpMatrix);
4892
- var ix = Math.floor(tl[0]);
4893
- var iy = Math.floor(tl[1]);
4894
- var iwidth = Math.ceil(br[0] - tl[0]);
4895
- var iheight = Math.ceil(br[1] - tl[1]);
4869
+ var tl = transformMat4$1(_this.vec3a, fromValues(x, y, 0), _this.vpMatrix);
4870
+ var tr = transformMat4$1(_this.vec3b, fromValues(x + width, y, 0), _this.vpMatrix);
4871
+ var bl = transformMat4$1(_this.vec3c, fromValues(x, y + height, 0), _this.vpMatrix);
4872
+ var br = transformMat4$1(_this.vec3d, fromValues(x + width, y + height, 0), _this.vpMatrix);
4873
+ var minx = Math.min(tl[0], tr[0], br[0], bl[0]);
4874
+ var miny = Math.min(tl[1], tr[1], br[1], bl[1]);
4875
+ var maxx = Math.max(tl[0], tr[0], br[0], bl[0]);
4876
+ var maxy = Math.max(tl[1], tr[1], br[1], bl[1]);
4877
+ var ix = Math.floor(minx);
4878
+ var iy = Math.floor(miny);
4879
+ var iwidth = Math.ceil(maxx - minx);
4880
+ var iheight = Math.ceil(maxy - miny);
4896
4881
  context.save();
4897
4882
 
4898
4883
  _this.clearRect(context, ix, iy, iwidth, iheight);
@@ -4908,7 +4893,12 @@
4908
4893
 
4909
4894
  if (enableDirtyRectangleRenderingDebug) {
4910
4895
  canvas.dispatchEvent(new g.CustomEvent(g.CanvasEvent.DIRTY_RECTANGLE, {
4911
- dirtyRect: dirtyRect
4896
+ dirtyRect: {
4897
+ x: ix,
4898
+ y: iy,
4899
+ width: iwidth,
4900
+ height: iheight
4901
+ }
4912
4902
  }));
4913
4903
  } // search objects intersect with dirty rectangle
4914
4904
 
@@ -5134,19 +5124,17 @@
5134
5124
  lineDash = _object$parsedStyle.lineDash,
5135
5125
  lineDashOffset = _object$parsedStyle.lineDashOffset; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/setLineDash
5136
5126
 
5137
- if (lineDash && Array.isArray(lineDash)) {
5138
- context.setLineDash(lineDash.map(function (segment) {
5139
- return segment.value;
5140
- }));
5127
+ if (lineDash) {
5128
+ context.setLineDash(lineDash);
5141
5129
  } // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
5142
5130
 
5143
5131
 
5144
5132
  if (!g.isNil(lineDashOffset)) {
5145
- context.lineDashOffset = lineDashOffset.value;
5133
+ context.lineDashOffset = lineDashOffset;
5146
5134
  }
5147
5135
 
5148
5136
  if (!g.isNil(opacity)) {
5149
- context.globalAlpha *= opacity.value;
5137
+ context.globalAlpha *= opacity;
5150
5138
  }
5151
5139
 
5152
5140
  if (!g.isNil(stroke) && !Array.isArray(stroke) && !stroke.isNone) {
@@ -5165,8 +5153,8 @@
5165
5153
  var _ref4 = object.parsedStyle || {},
5166
5154
  anchor = _ref4.anchor;
5167
5155
 
5168
- var anchorX = anchor && anchor[0].value || 0;
5169
- var anchorY = anchor && anchor[1].value || 0;
5156
+ var anchorX = anchor && anchor[0] || 0;
5157
+ var anchorY = anchor && anchor[1] || 0;
5170
5158
 
5171
5159
  if (anchorX !== 0 || anchorY !== 0) {
5172
5160
  var bounds = object.getGeometryBounds();
@@ -5179,19 +5167,19 @@
5179
5167
 
5180
5168
  if (matrix) {
5181
5169
  copy(this.tmpMat4, object.getLocalTransform());
5182
- this.tmpVec3[0] = tx;
5183
- this.tmpVec3[1] = ty;
5184
- this.tmpVec3[2] = 0;
5185
- translate(this.tmpMat4, this.tmpMat4, this.tmpVec3);
5170
+ this.vec3a[0] = tx;
5171
+ this.vec3a[1] = ty;
5172
+ this.vec3a[2] = 0;
5173
+ translate(this.tmpMat4, this.tmpMat4, this.vec3a);
5186
5174
  multiply$1(this.tmpMat4, matrix, this.tmpMat4);
5187
5175
  multiply$1(this.tmpMat4, this.vpMatrix, this.tmpMat4);
5188
5176
  } else {
5189
5177
  // apply RTS transformation in world space
5190
5178
  copy(this.tmpMat4, object.getWorldTransform());
5191
- this.tmpVec3[0] = tx;
5192
- this.tmpVec3[1] = ty;
5193
- this.tmpVec3[2] = 0;
5194
- translate(this.tmpMat4, this.tmpMat4, this.tmpVec3);
5179
+ this.vec3a[0] = tx;
5180
+ this.vec3a[1] = ty;
5181
+ this.vec3a[2] = 0;
5182
+ translate(this.tmpMat4, this.tmpMat4, this.vec3a);
5195
5183
  multiply$1(this.tmpMat4, this.vpMatrix, this.tmpMat4);
5196
5184
  } // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
5197
5185
 
@@ -6521,22 +6509,22 @@
6521
6509
 
6522
6510
  case 'zIndex':
6523
6511
  var zIndex = object.parsedStyle.zIndex;
6524
- $el.style['z-index'] = "" + zIndex.value;
6512
+ $el.style['z-index'] = "" + zIndex;
6525
6513
  break;
6526
6514
 
6527
6515
  case 'visibility':
6528
6516
  var visibility = object.parsedStyle.visibility;
6529
- $el.style.visibility = visibility.value;
6517
+ $el.style.visibility = visibility;
6530
6518
  break;
6531
6519
 
6532
6520
  case 'pointerEvents':
6533
6521
  var pointerEvents = object.parsedStyle.pointerEvents;
6534
- $el.style.pointerEvents = pointerEvents.value;
6522
+ $el.style.pointerEvents = pointerEvents;
6535
6523
  break;
6536
6524
 
6537
6525
  case 'opacity':
6538
6526
  var opacity = object.parsedStyle.opacity;
6539
- $el.style.opacity = "" + opacity.value;
6527
+ $el.style.opacity = "" + opacity;
6540
6528
  break;
6541
6529
 
6542
6530
  case 'fill':
@@ -6576,7 +6564,7 @@
6576
6564
 
6577
6565
  case 'lineWidth':
6578
6566
  var lineWidth = object.parsedStyle.lineWidth;
6579
- $el.style['border-width'] = (lineWidth.value || 0) + "px";
6567
+ $el.style['border-width'] = (lineWidth || 0) + "px";
6580
6568
  break;
6581
6569
 
6582
6570
  case 'lineDash':
@@ -6584,7 +6572,7 @@
6584
6572
  break;
6585
6573
 
6586
6574
  case 'filter':
6587
- var filter = object.parsedStyle.filter;
6575
+ var filter = object.style.filter;
6588
6576
  $el.style.filter = filter;
6589
6577
  break;
6590
6578
  }