@visactor/vrender 0.14.7 → 0.14.8

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.js CHANGED
@@ -9210,6 +9210,7 @@
9210
9210
  angle: 0,
9211
9211
  alpha: 0,
9212
9212
  beta: 0,
9213
+ scaleCenter: [0, 0],
9213
9214
  anchor: [0, 0],
9214
9215
  anchor3d: [0, 0],
9215
9216
  postMatrix: new Matrix()
@@ -9274,7 +9275,7 @@
9274
9275
  const DefaultCircleAttribute = Object.assign(Object.assign({}, DefaultAttribute), { radius: 1, startAngle: 0, endAngle: pi2 });
9275
9276
  const DefaultGroupAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, cornerRadius: 0, path: [], clip: false, visibleAll: true, display: 'relative', flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-start', alignItems: 'flex-start', alignContent: 'flex-start' });
9276
9277
  const DefaultGlyphAttribute = Object.assign(Object.assign({}, DefaultAttribute), { path: '', width: 0, height: 0, cornerRadius: 0, clip: false });
9277
- const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultConnectAttribute), { points: [], segments: [], curveType: 'linear', clipRange: 1, clipRangeByDimension: 'default' });
9278
+ const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultConnectAttribute), { points: [], segments: [], curveType: 'linear', clipRange: 1, clipRangeByDimension: 'default', closePath: false });
9278
9279
  const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), { path: new CustomPath2D(), customPath: () => {
9279
9280
  console.warn('空函数');
9280
9281
  } });
@@ -17566,7 +17567,7 @@
17566
17567
  this._updateTag &= exports.UpdateTag.CLEAR_GLOBAL_MATRIX;
17567
17568
  }
17568
17569
  doUpdateLocalMatrix() {
17569
- const { x = DefaultTransform.x, y = DefaultTransform.y, scaleX = DefaultTransform.scaleX, scaleY = DefaultTransform.scaleY, angle = DefaultTransform.angle, anchor, postMatrix } = this.attribute;
17570
+ const { x = DefaultTransform.x, y = DefaultTransform.y, scaleX = DefaultTransform.scaleX, scaleY = DefaultTransform.scaleY, angle = DefaultTransform.angle, scaleCenter, anchor, postMatrix } = this.attribute;
17570
17571
  const _anchor = [0, 0];
17571
17572
  if (anchor) {
17572
17573
  if (typeof anchor[0] === 'string') {
@@ -17586,7 +17587,18 @@
17586
17587
  _anchor[1] = anchor[1];
17587
17588
  }
17588
17589
  }
17589
- normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);
17590
+ if (scaleCenter && (scaleX !== 1 || scaleY !== 1)) {
17591
+ const m = this._transMatrix;
17592
+ m.reset();
17593
+ m.translate(_anchor[0], _anchor[1]);
17594
+ m.rotate(angle);
17595
+ m.translate(-_anchor[0], -_anchor[1]);
17596
+ m.translate(x, y);
17597
+ application.transformUtil.fromMatrix(m, m).scale(scaleX, scaleY, { x: scaleCenter[0], y: scaleCenter[1] });
17598
+ }
17599
+ else {
17600
+ normalTransform(this._transMatrix, this._transMatrix.reset(), x, y, scaleX, scaleY, angle, anchor && _anchor);
17601
+ }
17590
17602
  const p = this.getOffsetXY(DefaultTransform);
17591
17603
  this._transMatrix.e += p.x;
17592
17604
  this._transMatrix.f += p.y;
@@ -24786,12 +24798,28 @@
24786
24798
  return;
24787
24799
  }
24788
24800
  if (line.shouldUpdateShape()) {
24789
- const { points, segments, curveType = lineAttribute.curveType } = line.attribute;
24801
+ const { points, segments, closePath } = line.attribute;
24802
+ let { curveType = lineAttribute.curveType } = line.attribute;
24803
+ if (closePath && curveType === 'linear') {
24804
+ curveType = 'linearClosed';
24805
+ }
24790
24806
  const _points = points;
24791
24807
  if (segments && segments.length) {
24792
24808
  let startPoint;
24793
24809
  let lastSeg;
24794
- line.cache = segments.map((seg, index) => {
24810
+ line.cache = segments
24811
+ .map((seg, index) => {
24812
+ if (seg.points.length <= 1) {
24813
+ if (index === 0) {
24814
+ seg.points[0] &&
24815
+ (lastSeg = {
24816
+ endX: seg.points[0].x,
24817
+ endY: seg.points[0].y,
24818
+ curves: [{ defined: seg.points[0].defined !== false }]
24819
+ });
24820
+ return null;
24821
+ }
24822
+ }
24795
24823
  if (index === 1) {
24796
24824
  startPoint = {
24797
24825
  x: lastSeg.endX,
@@ -24804,11 +24832,29 @@
24804
24832
  startPoint.y = lastSeg.endY;
24805
24833
  startPoint.defined = lastSeg.curves[lastSeg.curves.length - 1].defined;
24806
24834
  }
24807
- lastSeg = calcLineCache$1(seg.points, curveType, {
24835
+ const data = calcLineCache$1(seg.points, curveType, {
24808
24836
  startPoint
24809
24837
  });
24810
- return lastSeg;
24811
- });
24838
+ lastSeg = data;
24839
+ return data;
24840
+ })
24841
+ .filter(item => !!item);
24842
+ if (curveType === 'linearClosed') {
24843
+ let startP;
24844
+ for (let i = 0; i < line.cache.length; i++) {
24845
+ const cacheItem = line.cache[i];
24846
+ for (let i = 0; i < cacheItem.curves.length; i++) {
24847
+ if (cacheItem.curves[i].defined) {
24848
+ startP = cacheItem.curves[i].p0;
24849
+ break;
24850
+ }
24851
+ }
24852
+ if (startP) {
24853
+ break;
24854
+ }
24855
+ }
24856
+ line.cache[line.cache.length - 1] && line.cache[line.cache.length - 1].lineTo(startP.x, startP.y, true);
24857
+ }
24812
24858
  }
24813
24859
  else if (points && points.length) {
24814
24860
  line.cache = calcLineCache$1(_points, curveType);
@@ -24822,13 +24868,17 @@
24822
24868
  }
24823
24869
  const { clipRange = lineAttribute.clipRange, clipRangeByDimension = lineAttribute.clipRangeByDimension } = line.attribute;
24824
24870
  if (Array.isArray(line.cache)) {
24871
+ const segments = line.attribute.segments.filter(item => item.points.length);
24872
+ if (segments[0].points.length === 1) {
24873
+ segments.shift();
24874
+ }
24825
24875
  if (clipRange === 1) {
24826
24876
  let skip = false;
24827
24877
  line.cache.forEach((cache, index) => {
24828
24878
  if (skip) {
24829
24879
  return;
24830
24880
  }
24831
- skip = this.drawSegmentItem(context, cache, !!fill, !!stroke, fillOpacity, strokeOpacity, line.attribute.segments[index], [lineAttribute, line.attribute], clipRange, clipRangeByDimension, x, y, line, fillCb, strokeCb);
24881
+ skip = this.drawSegmentItem(context, cache, !!fill, !!stroke, fillOpacity, strokeOpacity, segments[index], [lineAttribute, line.attribute], clipRange, clipRangeByDimension, x, y, line, fillCb, strokeCb);
24832
24882
  });
24833
24883
  }
24834
24884
  else {
@@ -24844,7 +24894,7 @@
24844
24894
  const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;
24845
24895
  drawedLengthUntilLast += curSegLength;
24846
24896
  if (_cr > 0) {
24847
- skip = this.drawSegmentItem(context, cache, !!fill, !!stroke, fillOpacity, strokeOpacity, line.attribute.segments[index], [lineAttribute, line.attribute], min(_cr, 1), clipRangeByDimension, x, y, line, fillCb, strokeCb);
24897
+ skip = this.drawSegmentItem(context, cache, !!fill, !!stroke, fillOpacity, strokeOpacity, segments[index], [lineAttribute, line.attribute], min(_cr, 1), clipRangeByDimension, x, y, line, fillCb, strokeCb);
24848
24898
  }
24849
24899
  });
24850
24900
  }
@@ -25213,7 +25263,14 @@
25213
25263
  if (segments && segments.length) {
25214
25264
  let startPoint;
25215
25265
  let lastTopSeg;
25216
- const topCaches = segments.map((seg, index) => {
25266
+ const topCaches = segments
25267
+ .map((seg, index) => {
25268
+ if (seg.points.length <= 1) {
25269
+ if (index === 0) {
25270
+ seg.points[0] && (lastTopSeg = { endX: seg.points[0].x, endY: seg.points[0].y });
25271
+ return null;
25272
+ }
25273
+ }
25217
25274
  if (index === 1) {
25218
25275
  startPoint = { x: lastTopSeg.endX, y: lastTopSeg.endY };
25219
25276
  }
@@ -25221,11 +25278,13 @@
25221
25278
  startPoint.x = lastTopSeg.endX;
25222
25279
  startPoint.y = lastTopSeg.endY;
25223
25280
  }
25224
- lastTopSeg = calcLineCache(seg.points, curveType, {
25281
+ const data = calcLineCache(seg.points, curveType, {
25225
25282
  startPoint
25226
25283
  });
25227
- return lastTopSeg;
25228
- });
25284
+ lastTopSeg = data;
25285
+ return data;
25286
+ })
25287
+ .filter(item => !!item);
25229
25288
  let lastBottomSeg;
25230
25289
  const bottomCaches = [];
25231
25290
  for (let i = segments.length - 1; i >= 0; i--) {
@@ -25275,13 +25334,17 @@
25275
25334
  area.clearUpdateShapeTag();
25276
25335
  }
25277
25336
  if (Array.isArray(area.cacheArea)) {
25337
+ const segments = area.attribute.segments.filter(item => item.points.length);
25338
+ if (segments[0].points.length === 1) {
25339
+ segments.shift();
25340
+ }
25278
25341
  if (clipRange === 1) {
25279
25342
  let skip = false;
25280
25343
  area.cacheArea.forEach((cache, index) => {
25281
25344
  if (skip) {
25282
25345
  return;
25283
25346
  }
25284
- skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, area.attribute.segments[index], [areaAttribute, area.attribute], clipRange, x, y, z, area, drawContext, fillCb, strokeCb);
25347
+ skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[index], [areaAttribute, area.attribute], clipRange, x, y, z, area, drawContext, fillCb, strokeCb);
25285
25348
  });
25286
25349
  }
25287
25350
  else {
@@ -25297,7 +25360,7 @@
25297
25360
  const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;
25298
25361
  drawedLengthUntilLast += curSegLength;
25299
25362
  if (_cr > 0) {
25300
- skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, area.attribute.segments[index], [areaAttribute, area.attribute], min(_cr, 1), x, y, z, area, drawContext, fillCb, strokeCb);
25363
+ skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[index], [areaAttribute, area.attribute], min(_cr, 1), x, y, z, area, drawContext, fillCb, strokeCb);
25301
25364
  }
25302
25365
  });
25303
25366
  }
@@ -36975,7 +37038,7 @@
36975
37038
  'rect'
36976
37039
  ];
36977
37040
 
36978
- const version = "0.14.7";
37041
+ const version = "0.14.8";
36979
37042
 
36980
37043
  exports.ACustomAnimate = ACustomAnimate;
36981
37044
  exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;