@visactor/vrender 0.17.20-alpha.6 → 0.17.20-alpha.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
@@ -5293,7 +5293,7 @@
5293
5293
  strokeBoundsBuffer: 0,
5294
5294
  keepDirIn3d: !0
5295
5295
  });
5296
- var DefaultRichTextAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
5296
+ var DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
5297
5297
  width: 300,
5298
5298
  height: 300,
5299
5299
  ellipsis: !0,
@@ -6283,9 +6283,20 @@
6283
6283
  }, {
6284
6284
  key: "create",
6285
6285
  value: function create(params) {
6286
+ var _a, _b;
6286
6287
  this._handler.createWindow(params);
6287
6288
  var windowWH = this._handler.getWH();
6288
- this._width = windowWH.width, this._height = windowWH.height, this.title = this._handler.getTitle(), this.resizable = !0;
6289
+ this._width = windowWH.width, this._height = windowWH.height, params.viewBox ? this.setViewBox(params.viewBox) : !1 !== params.canvasControled ? this.setViewBox({
6290
+ x1: 0,
6291
+ y1: 0,
6292
+ x2: this._width,
6293
+ y2: this._height
6294
+ }) : this.setViewBox({
6295
+ x1: 0,
6296
+ y1: 0,
6297
+ x2: null !== (_a = params.width) && void 0 !== _a ? _a : this._width,
6298
+ y2: null !== (_b = params.height) && void 0 !== _b ? _b : this._height
6299
+ }), this.title = this._handler.getTitle(), this.resizable = !0;
6289
6300
  }
6290
6301
  }, {
6291
6302
  key: "setWindowHandler",
@@ -6354,8 +6365,47 @@
6354
6365
  }
6355
6366
  }, {
6356
6367
  key: "clearViewBox",
6357
- value: function clearViewBox(viewBox, color) {
6358
- this._handler.clearViewBox(viewBox, color);
6368
+ value: function clearViewBox(color) {
6369
+ this._handler.clearViewBox(color);
6370
+ }
6371
+ }, {
6372
+ key: "setViewBox",
6373
+ value: function setViewBox(viewBox) {
6374
+ this._handler.setViewBox(viewBox);
6375
+ }
6376
+ }, {
6377
+ key: "setViewBoxTransform",
6378
+ value: function setViewBoxTransform(a, b, c, d, e, f) {
6379
+ this._handler.setViewBoxTransform(a, b, c, d, e, f);
6380
+ }
6381
+ }, {
6382
+ key: "getViewBox",
6383
+ value: function getViewBox() {
6384
+ return this._handler.getViewBox();
6385
+ }
6386
+ }, {
6387
+ key: "getViewBoxTransform",
6388
+ value: function getViewBoxTransform() {
6389
+ return this._handler.getViewBoxTransform();
6390
+ }
6391
+ }, {
6392
+ key: "pointTransform",
6393
+ value: function pointTransform(x, y) {
6394
+ var vb = this._handler.getViewBox(),
6395
+ nextP = {
6396
+ x: x,
6397
+ y: y
6398
+ };
6399
+ return this._handler.getViewBoxTransform().transformPoint({
6400
+ x: x,
6401
+ y: y
6402
+ }, nextP), nextP.x -= vb.x1, nextP.y -= vb.y1, nextP;
6403
+ }
6404
+ }, {
6405
+ key: "hasSubView",
6406
+ value: function hasSubView() {
6407
+ var viewBox = this._handler.getViewBox();
6408
+ return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width === viewBox.width() && this.height === viewBox.height());
6359
6409
  }
6360
6410
  }, {
6361
6411
  key: "isVisible",
@@ -6473,8 +6523,16 @@
6473
6523
  var window = container.get(VWindow),
6474
6524
  bounds = graphic.AABBBounds,
6475
6525
  width = bounds.width(),
6476
- height = bounds.height();
6526
+ height = bounds.height(),
6527
+ x1 = -bounds.x1,
6528
+ y1 = -bounds.y1;
6477
6529
  window.create({
6530
+ viewBox: {
6531
+ x1: x1,
6532
+ y1: y1,
6533
+ x2: bounds.x2,
6534
+ y2: bounds.y2
6535
+ },
6478
6536
  width: width,
6479
6537
  height: height,
6480
6538
  canvas: canvas,
@@ -6483,14 +6541,10 @@
6483
6541
  offscreen: !0,
6484
6542
  title: ""
6485
6543
  });
6486
- var x = -bounds.x1,
6487
- y = -bounds.y1,
6488
- disableCheckGraphicWidthOutRange = stage.params.optimize.disableCheckGraphicWidthOutRange;
6544
+ var disableCheckGraphicWidthOutRange = stage.params.optimize.disableCheckGraphicWidthOutRange;
6489
6545
  stage.params.optimize.disableCheckGraphicWidthOutRange = !0, stage.defaultLayer.getNativeHandler().drawTo(window, [graphic], {
6490
- x: x,
6491
- y: y,
6492
- width: width,
6493
- height: height,
6546
+ transMatrix: window.getViewBoxTransform(),
6547
+ viewBox: window.getViewBox(),
6494
6548
  stage: stage,
6495
6549
  layer: stage.defaultLayer,
6496
6550
  renderService: stage.renderService,
@@ -7655,7 +7709,7 @@
7655
7709
  var mappers = this.mappingTable[e.type];
7656
7710
  var target;
7657
7711
  var cacheKey = "".concat(e.canvasX, "-").concat(e.canvasY);
7658
- if ((null === (_a = this._prePointTargetCache) || void 0 === _a ? void 0 : _a[cacheKey]) && (null === (_c = null === (_b = this._prePointTargetCache) || void 0 === _b ? void 0 : _b[cacheKey]) || void 0 === _c ? void 0 : _c.stage) && (null === (_e = null === (_d = this._prePointTargetCache) || void 0 === _d ? void 0 : _d[cacheKey]) || void 0 === _e ? void 0 : _e.stage.renderCount) === (null === (_f = this._prePointTargetCache) || void 0 === _f ? void 0 : _f.stageRenderCount) ? target = this._prePointTargetCache[cacheKey] : (target = this.pickTarget(e.canvasX, e.canvasY, e), e.pickParams || (this._prePointTargetCache = _defineProperty(_defineProperty({}, cacheKey, target), "stageRenderCount", null !== (_g = null == target ? void 0 : target.stage.renderCount) && void 0 !== _g ? _g : -1))), mappers) for (var i = 0, j = mappers.length; i < j; i++) mappers[i].fn(e, target);else Logger.getInstance().warn("[EventManager]: Event mapping not defined for ".concat(e.type));
7712
+ if ((null === (_a = this._prePointTargetCache) || void 0 === _a ? void 0 : _a[cacheKey]) && (null === (_c = null === (_b = this._prePointTargetCache) || void 0 === _b ? void 0 : _b[cacheKey]) || void 0 === _c ? void 0 : _c.stage) && (null === (_e = null === (_d = this._prePointTargetCache) || void 0 === _d ? void 0 : _d[cacheKey]) || void 0 === _e ? void 0 : _e.stage.renderCount) === (null === (_f = this._prePointTargetCache) || void 0 === _f ? void 0 : _f.stageRenderCount) ? target = this._prePointTargetCache[cacheKey] : (target = this.pickTarget(e.viewX, e.viewY, e), e.pickParams || (this._prePointTargetCache = _defineProperty(_defineProperty({}, cacheKey, target), "stageRenderCount", null !== (_g = null == target ? void 0 : target.stage.renderCount) && void 0 !== _g ? _g : -1))), mappers) for (var i = 0, j = mappers.length; i < j; i++) mappers[i].fn(e, target);else Logger.getInstance().warn("[EventManager]: Event mapping not defined for ".concat(e.type));
7659
7713
  }
7660
7714
  }, {
7661
7715
  key: "propagate",
@@ -7834,7 +7888,7 @@
7834
7888
  _this.setCursor(_this.manager.cursor, _this.manager.cursorTarget);
7835
7889
  }, this.onPointerUp = function (nativeEvent) {
7836
7890
  if (_this.supportsTouchEvents && "touch" === nativeEvent.pointerType) return;
7837
- var outside = _this.isEventOutsideOfTargetElement(nativeEvent) ? "outside" : "",
7891
+ var outside = _this.isEventOutsideOfTargetViewPort(nativeEvent) ? "outside" : "",
7838
7892
  normalizedEvents = _this.normalizeToPointerData(nativeEvent);
7839
7893
  for (var i = 0, j = normalizedEvents.length; i < j; i++) {
7840
7894
  var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvents[i]);
@@ -7857,7 +7911,6 @@
7857
7911
  resolution = params.resolution,
7858
7912
  rootNode = params.rootNode,
7859
7913
  global = params.global,
7860
- viewport = params.viewport,
7861
7914
  _params$autoPreventDe = params.autoPreventDefault,
7862
7915
  autoPreventDefault = _params$autoPreventDe === void 0 ? !1 : _params$autoPreventDe,
7863
7916
  clickInterval = params.clickInterval,
@@ -7867,7 +7920,7 @@
7867
7920
  supportsPointerEvents = _params$supportsPoint === void 0 ? global.supportsPointerEvents : _params$supportsPoint;
7868
7921
  this.manager = new EventManager(rootNode, {
7869
7922
  clickInterval: clickInterval
7870
- }), this.globalObj = global, this.supportsPointerEvents = supportsPointerEvents, this.supportsTouchEvents = supportsTouchEvents, this.supportsMouseEvents = global.supportsMouseEvents, this.applyStyles = global.applyStyles, this.autoPreventDefault = autoPreventDefault, this.eventsAdded = !1, this.viewport = viewport, this.rootPointerEvent = new FederatedPointerEvent(), this.rootWheelEvent = new FederatedWheelEvent(), this.cursorStyles = {
7923
+ }), this.globalObj = global, this.supportsPointerEvents = supportsPointerEvents, this.supportsTouchEvents = supportsTouchEvents, this.supportsMouseEvents = global.supportsMouseEvents, this.applyStyles = global.applyStyles, this.autoPreventDefault = autoPreventDefault, this.eventsAdded = !1, this.rootPointerEvent = new FederatedPointerEvent(), this.rootWheelEvent = new FederatedWheelEvent(), this.cursorStyles = {
7871
7924
  "default": "inherit",
7872
7925
  pointer: "pointer"
7873
7926
  }, this.resolution = resolution, this.setTargetElement(targetElement);
@@ -7915,13 +7968,7 @@
7915
7968
  }, {
7916
7969
  key: "mapToViewportPoint",
7917
7970
  value: function mapToViewportPoint(event) {
7918
- var viewport = this.viewport,
7919
- x = event.x,
7920
- y = event.y;
7921
- return {
7922
- x: x - viewport.x,
7923
- y: y - viewport.y
7924
- };
7971
+ return this.domElement.pointTransform ? this.domElement.pointTransform(event.x, event.y) : event;
7925
7972
  }
7926
7973
  }, {
7927
7974
  key: "mapToCanvasPoint",
@@ -7982,6 +8029,19 @@
7982
8029
  value: function transferMouseData(event, nativeEvent) {
7983
8030
  event.isTrusted = nativeEvent.isTrusted, event.srcElement = nativeEvent.srcElement, event.timeStamp = clock.now(), event.type = nativeEvent.type, event.altKey = nativeEvent.altKey, event.button = nativeEvent.button, event.buttons = nativeEvent.buttons, event.client.x = nativeEvent.clientX, event.client.y = nativeEvent.clientY, event.ctrlKey = nativeEvent.ctrlKey, event.shiftKey = nativeEvent.shiftKey, event.metaKey = nativeEvent.metaKey, event.movement.x = nativeEvent.movementX, event.movement.y = nativeEvent.movementY, event.page.x = nativeEvent.pageX, event.page.y = nativeEvent.pageY, event.relatedTarget = null;
7984
8031
  }
8032
+ }, {
8033
+ key: "isEventOutsideOfTargetViewPort",
8034
+ value: function isEventOutsideOfTargetViewPort(nativeEvent) {
8035
+ if (this.isEventOutsideOfTargetElement(nativeEvent)) return !0;
8036
+ if (this.domElement.getViewBox) {
8037
+ var p = this.mapToViewportPoint(this.mapToCanvasPoint(nativeEvent)),
8038
+ b = this.domElement.getViewBox(),
8039
+ w = b.width(),
8040
+ h = b.height();
8041
+ return !(p.x < w && p.y < h && p.x > 0 && p.y > 0);
8042
+ }
8043
+ return !1;
8044
+ }
7985
8045
  }, {
7986
8046
  key: "isEventOutsideOfTargetElement",
7987
8047
  value: function isEventOutsideOfTargetElement(nativeEvent) {
@@ -13072,15 +13132,12 @@
13072
13132
  value: function render(params, userParams) {
13073
13133
  var _this4 = this;
13074
13134
  var _a;
13075
- var stage = this.stage;
13076
13135
  this.layerHandler.render([this], {
13077
13136
  renderService: params.renderService,
13078
- x: stage.x,
13079
- y: stage.y,
13080
- width: this.viewWidth,
13081
- height: this.viewHeight,
13082
13137
  stage: this.stage,
13083
13138
  layer: this,
13139
+ viewBox: params.viewBox,
13140
+ transMatrix: params.transMatrix,
13084
13141
  background: null !== (_a = params.background) && void 0 !== _a ? _a : this.background,
13085
13142
  updateBounds: params.updateBounds
13086
13143
  }, userParams), this.afterDrawCbs.forEach(function (c) {
@@ -13120,48 +13177,28 @@
13120
13177
  }, {
13121
13178
  key: "prepare",
13122
13179
  value: function prepare(dirtyBounds, params) {}
13123
- }, {
13124
- key: "combineTo",
13125
- value: function combineTo(target, params) {
13126
- var _this5 = this;
13127
- var _a, _b, _c;
13128
- this.offscreen && (this.layerHandler.drawTo(target, [this], Object.assign({
13129
- background: null !== (_a = params.background) && void 0 !== _a ? _a : this.background,
13130
- renderService: params.renderService,
13131
- x: null !== (_b = params.x) && void 0 !== _b ? _b : this.stage.x,
13132
- y: null !== (_c = params.y) && void 0 !== _c ? _c : this.stage.y,
13133
- width: this.viewWidth,
13134
- height: this.viewHeight,
13135
- stage: this.stage,
13136
- layer: this
13137
- }, params)), this.afterDrawCbs.forEach(function (c) {
13138
- return c(_this5);
13139
- }));
13140
- }
13141
13180
  }, {
13142
13181
  key: "release",
13143
13182
  value: function release() {
13144
- var _this6 = this;
13183
+ var _this5 = this;
13145
13184
  _get(_getPrototypeOf(Layer.prototype), "release", this).call(this), this.layerHandler.release(), this.subLayers && this.subLayers.forEach(function (l) {
13146
- application.layerService.releaseLayer(_this6.stage, l.layer);
13185
+ application.layerService.releaseLayer(_this5.stage, l.layer);
13147
13186
  });
13148
13187
  }
13149
13188
  }, {
13150
13189
  key: "drawTo",
13151
13190
  value: function drawTo(target, params) {
13152
- var _this7 = this;
13153
- var _a, _b, _c;
13191
+ var _this6 = this;
13192
+ var _a;
13154
13193
  this.layerHandler.drawTo(target, [this], Object.assign({
13155
13194
  background: null !== (_a = params.background) && void 0 !== _a ? _a : this.background,
13156
13195
  renderService: params.renderService,
13157
- x: null !== (_b = params.x) && void 0 !== _b ? _b : this.stage.x,
13158
- y: null !== (_c = params.y) && void 0 !== _c ? _c : this.stage.y,
13159
- width: this.viewWidth,
13160
- height: this.viewHeight,
13196
+ viewBox: params.viewBox,
13197
+ transMatrix: params.transMatrix,
13161
13198
  stage: this.stage,
13162
13199
  layer: this
13163
13200
  }, params)), this.afterDrawCbs.forEach(function (c) {
13164
- return c(_this7);
13201
+ return c(_this6);
13165
13202
  });
13166
13203
  }
13167
13204
  }]);
@@ -16555,28 +16592,47 @@
16555
16592
  value: function getFrameCache() {
16556
16593
  return this.shouldUpdateShape() && (this.doUpdateFrameCache(), this.clearUpdateShapeTag()), this._frameCache;
16557
16594
  }
16595
+ }, {
16596
+ key: "combinedStyleToCharacter",
16597
+ value: function combinedStyleToCharacter(config) {
16598
+ var _this$attribute = this.attribute,
16599
+ fill = _this$attribute.fill,
16600
+ stroke = _this$attribute.stroke,
16601
+ fontSize = _this$attribute.fontSize,
16602
+ fontFamily = _this$attribute.fontFamily,
16603
+ fontStyle = _this$attribute.fontStyle,
16604
+ fontWeight = _this$attribute.fontWeight;
16605
+ return Object.assign({
16606
+ fill: fill,
16607
+ stroke: stroke,
16608
+ fontSize: fontSize,
16609
+ fontFamily: fontFamily,
16610
+ fontStyle: fontStyle,
16611
+ fontWeight: fontWeight
16612
+ }, config);
16613
+ }
16558
16614
  }, {
16559
16615
  key: "doUpdateFrameCache",
16560
16616
  value: function doUpdateFrameCache() {
16561
16617
  var _this2 = this;
16562
16618
  var _a;
16563
- var _this$attribute = this.attribute,
16564
- _this$attribute$textC = _this$attribute.textConfig,
16565
- textConfig = _this$attribute$textC === void 0 ? [] : _this$attribute$textC,
16566
- maxWidth = _this$attribute.maxWidth,
16567
- maxHeight = _this$attribute.maxHeight,
16568
- width = _this$attribute.width,
16569
- height = _this$attribute.height,
16570
- ellipsis = _this$attribute.ellipsis,
16571
- wordBreak = _this$attribute.wordBreak,
16572
- verticalDirection = _this$attribute.verticalDirection,
16573
- textAlign = _this$attribute.textAlign,
16574
- textBaseline = _this$attribute.textBaseline,
16575
- layoutDirection = _this$attribute.layoutDirection,
16576
- singleLine = _this$attribute.singleLine,
16619
+ var _this$attribute2 = this.attribute,
16620
+ _this$attribute2$text = _this$attribute2.textConfig,
16621
+ textConfig = _this$attribute2$text === void 0 ? [] : _this$attribute2$text,
16622
+ maxWidth = _this$attribute2.maxWidth,
16623
+ maxHeight = _this$attribute2.maxHeight,
16624
+ width = _this$attribute2.width,
16625
+ height = _this$attribute2.height,
16626
+ ellipsis = _this$attribute2.ellipsis,
16627
+ wordBreak = _this$attribute2.wordBreak,
16628
+ verticalDirection = _this$attribute2.verticalDirection,
16629
+ textAlign = _this$attribute2.textAlign,
16630
+ textBaseline = _this$attribute2.textBaseline,
16631
+ layoutDirection = _this$attribute2.layoutDirection,
16632
+ singleLine = _this$attribute2.singleLine,
16577
16633
  paragraphs = [];
16578
16634
  for (var i = 0; i < textConfig.length; i++) if ("image" in textConfig[i]) {
16579
- var config = textConfig[i],
16635
+ var config = this.combinedStyleToCharacter(textConfig[i]),
16580
16636
  iconCache = config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);
16581
16637
  if (iconCache) paragraphs.push(iconCache);else {
16582
16638
  var icon = new RichTextIcon(config);
@@ -16586,7 +16642,7 @@
16586
16642
  }, icon.richtextId = config.id, paragraphs.push(icon);
16587
16643
  }
16588
16644
  } else {
16589
- var richTextConfig = textConfig[i];
16645
+ var richTextConfig = this.combinedStyleToCharacter(textConfig[i]);
16590
16646
  if (isNumber$1(richTextConfig.text) && (richTextConfig.text = "".concat(richTextConfig.text)), richTextConfig.text && richTextConfig.text.includes("\n")) {
16591
16647
  var textParts = richTextConfig.text.split("\n");
16592
16648
  for (var j = 0; j < textParts.length; j++) paragraphs.push(new Paragraph(textParts[j], 0 !== j, richTextConfig));
@@ -20250,10 +20306,9 @@
20250
20306
  key: "drawLinearAreaHighPerformance",
20251
20307
  value: function drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
20252
20308
  var _a, _b, _c, _d, _e;
20253
- var points = area.attribute.points;
20254
- if (points.length < 2) return;
20255
20309
  context.beginPath();
20256
20310
  var z = null !== (_a = this.z) && void 0 !== _a ? _a : 0,
20311
+ points = area.attribute.points,
20257
20312
  startP = points[0];
20258
20313
  context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
20259
20314
  for (var i = 1; i < points.length; i++) {
@@ -20430,7 +20485,6 @@
20430
20485
  key: "_drawSegmentItem",
20431
20486
  value: function _drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, connect, fillCb, strokeCb) {
20432
20487
  var _a, _b, _c, _d;
20433
- if (!(cache && cache.top && cache.bottom && cache.top.curves && cache.top.curves.length && cache.bottom.curves && cache.bottom.curves.length)) return;
20434
20488
  var connectedType = attribute.connectedType,
20435
20489
  connectedX = attribute.connectedX,
20436
20490
  connectedY = attribute.connectedY,
@@ -20439,6 +20493,7 @@
20439
20493
  if (connect && (isArray$1(defaultAttribute) ? (connectedType = null !== (_a = null != connectedType ? connectedType : defaultAttribute[0].connectedType) && void 0 !== _a ? _a : defaultAttribute[1].connectedType, connectedX = null !== (_b = null != connectedX ? connectedX : defaultAttribute[0].connectedX) && void 0 !== _b ? _b : defaultAttribute[1].connectedX, connectedY = null !== (_c = null != connectedY ? connectedY : defaultAttribute[0].connectedY) && void 0 !== _c ? _c : defaultAttribute[1].connectedY, connectedStyle = null !== (_d = null != connectedStyle ? connectedStyle : defaultAttribute[0].connectedStyle) && void 0 !== _d ? _d : defaultAttribute[1].connectedStyle) : (connectedType = null != connectedType ? connectedType : defaultAttribute.connectedType, connectedX = null != connectedX ? connectedX : defaultAttribute.connectedX, connectedY = null != connectedY ? connectedY : defaultAttribute.connectedY, connectedStyle = null != connectedStyle ? connectedStyle : defaultAttribute.connectedStyle), "connect" !== connectedType && "zero" !== connectedType && (connectedType = "none"), isArray$1(defaultAttribute) ? defaultAttribute.forEach(function (i) {
20440
20494
  return da.push(i);
20441
20495
  }) : da.push(defaultAttribute), da.push(attribute)), connect && "none" === connectedType) return !1;
20496
+ if (!cache) return;
20442
20497
  context.beginPath();
20443
20498
  var _area$attribute4 = area.attribute,
20444
20499
  points = _area$attribute4.points,
@@ -22035,10 +22090,10 @@
22035
22090
  value: function render(group, params) {
22036
22091
  var _a;
22037
22092
  params.renderService.render(group, Object.assign(Object.assign({
22038
- context: this.context
22093
+ context: this.context,
22094
+ viewBox: params.stage.window.getViewBox(),
22095
+ transMatrix: params.stage.window.getViewBoxTransform()
22039
22096
  }, params), {
22040
- x: 0,
22041
- y: 0,
22042
22097
  clear: null !== (_a = params.background) && void 0 !== _a ? _a : "#ffffff"
22043
22098
  }));
22044
22099
  }
@@ -22060,14 +22115,11 @@
22060
22115
  value: function drawTo(target, group, params) {
22061
22116
  var context = target.getContext(),
22062
22117
  targetDpr = target.dpr,
22063
- _params$x = params.x,
22064
- x = _params$x === void 0 ? 0 : _params$x,
22065
- _params$y = params.y,
22066
- y = _params$y === void 0 ? 0 : _params$y,
22067
- _params$width = params.width,
22068
- width = _params$width === void 0 ? this.layer.viewWidth : _params$width,
22069
- _params$height = params.height,
22070
- height = _params$height === void 0 ? this.layer.viewHeight : _params$height;
22118
+ viewBox = params.viewBox,
22119
+ x = viewBox.x1,
22120
+ y = viewBox.y1,
22121
+ width = viewBox.width(),
22122
+ height = viewBox.height();
22071
22123
  context.nativeContext.save(), context.nativeContext.setTransform(targetDpr, 0, 0, targetDpr, 0, 0), params.clear && context.clearRect(x, y, width, height), context.drawImage(this.canvas.nativeCanvas, 0, 0, this.canvas.width, this.canvas.height, x, y, width, height), context.nativeContext.restore();
22072
22124
  }
22073
22125
  }, {
@@ -22248,33 +22300,21 @@
22248
22300
  this.prepareForDraw(renderService, drawContext), drawContext.drawContribution = this, this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap, this.currentRenderService = renderService;
22249
22301
  var context = drawContext.context,
22250
22302
  stage = drawContext.stage,
22251
- _drawContext$x = drawContext.x,
22252
- x = _drawContext$x === void 0 ? 0 : _drawContext$x,
22253
- _drawContext$y = drawContext.y,
22254
- y = _drawContext$y === void 0 ? 0 : _drawContext$y,
22255
- width = drawContext.width,
22256
- height = drawContext.height;
22303
+ viewBox = drawContext.viewBox,
22304
+ transMatrix = drawContext.transMatrix;
22257
22305
  if (!context) return;
22258
- if (drawContext.keepMatrix) {
22259
- if (context.nativeContext && context.nativeContext.getTransform) {
22260
- var t = context.nativeContext.getTransform();
22261
- context.setTransformFromMatrix(t, !0, 1);
22262
- }
22263
- } else context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
22264
- var dirtyBounds = this.dirtyBounds.setValue(0, 0, width, height);
22306
+ var dirtyBounds = this.dirtyBounds.setValue(0, 0, viewBox.width(), viewBox.height());
22265
22307
  if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {
22266
22308
  var b = getRectIntersect(dirtyBounds, stage.dirtyBounds, !1);
22267
22309
  dirtyBounds.x1 = Math.floor(b.x1), dirtyBounds.y1 = Math.floor(b.y1), dirtyBounds.x2 = Math.ceil(b.x2), dirtyBounds.y2 = Math.ceil(b.y2);
22268
22310
  }
22269
22311
  var d = context.dpr % 1;
22270
- (d || .5 !== d) && (dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr, dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr, dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr, dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds);
22271
- var drawInArea = dirtyBounds.width() * context.dpr < context.canvas.width || dirtyBounds.height() * context.dpr < context.canvas.height;
22272
- context.save(), context.translate(x, y, !0), drawInArea && (context.beginPath(), context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()), context.clip()), stage.camera && (this.dirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0), this.backupDirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0)), this.clearScreen(renderService, context, drawContext), context.save(), renderService.renderTreeRoots.sort(function (a, b) {
22312
+ (d || .5 !== d) && (dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr, dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr, dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr, dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds), context.inuse = !0, context.setClearMatrix(transMatrix.a, transMatrix.b, transMatrix.c, transMatrix.d, transMatrix.e, transMatrix.f), context.clearMatrix(), context.setTransformForCurrent(!0), context.translate(viewBox.x1, viewBox.y1, !0), context.beginPath(), context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()), context.clip(), stage.camera && (this.dirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0), this.backupDirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0)), this.clearScreen(renderService, context, drawContext), context.save(), renderService.renderTreeRoots.sort(function (a, b) {
22273
22313
  var _a, _b;
22274
22314
  return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
22275
22315
  }).forEach(function (group) {
22276
22316
  group.isContainer ? _this2.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : _this2.renderItem(group, drawContext);
22277
- }), context.restore(), context.restore(), context.draw(), drawContext.keepMatrix || (context.inuse = !1);
22317
+ }), context.restore(), context.draw(), context.setClearMatrix(1, 0, 0, 1, 0, 0), context.inuse = !1;
22278
22318
  }
22279
22319
  }, {
22280
22320
  key: "doRegister",
@@ -22408,28 +22448,24 @@
22408
22448
  key: "clearScreen",
22409
22449
  value: function clearScreen(renderService, context, drawContext) {
22410
22450
  var _a, _b;
22411
- var clear = drawContext.clear;
22451
+ var clear = drawContext.clear,
22452
+ viewBox = drawContext.viewBox,
22453
+ width = viewBox.width(),
22454
+ height = viewBox.height();
22412
22455
  if (clear) {
22413
- var canvas = context.getCanvas(),
22414
- _drawContext$width = drawContext.width,
22415
- width = _drawContext$width === void 0 ? canvas.width : _drawContext$width,
22416
- _drawContext$height = drawContext.height,
22417
- height = _drawContext$height === void 0 ? canvas.height : _drawContext$height,
22418
- x = 0,
22419
- y = 0;
22420
- context.clearRect(x, y, width, height);
22456
+ context.clearRect(0, 0, width, height);
22421
22457
  var stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
22422
22458
  if (stage && (context.globalAlpha = null !== (_b = stage.attribute.opacity) && void 0 !== _b ? _b : 1), stage && stage.backgroundImg && stage.resources) {
22423
22459
  var res = stage.resources.get(clear);
22424
- res && "success" === res.state && res.data && context.drawImage(res.data, x, y, width, height);
22460
+ res && "success" === res.state && res.data && context.drawImage(res.data, 0, 0, width, height);
22425
22461
  } else context.fillStyle = createColor(context, clear, {
22426
22462
  AABBBounds: {
22427
- x1: x,
22428
- y1: y,
22429
- x2: x + width,
22430
- y2: y + height
22463
+ x1: 0,
22464
+ y1: 0,
22465
+ x2: 0 + width,
22466
+ y2: 0 + height
22431
22467
  }
22432
- }, 0, 0), context.fillRect(x, y, width, height);
22468
+ }, 0, 0), context.fillRect(0, 0, width, height);
22433
22469
  }
22434
22470
  }
22435
22471
  }, {
@@ -22737,7 +22773,7 @@
22737
22773
  value: function draw(renderService, drawContext) {
22738
22774
  return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
22739
22775
  var _this2 = this;
22740
- var skipDraw, context, _drawContext$x, x, _drawContext$y, y, t;
22776
+ var skipDraw, context, viewBox;
22741
22777
  return _regeneratorRuntime().wrap(function _callee$(_context) {
22742
22778
  while (1) switch (_context.prev = _context.next) {
22743
22779
  case 0:
@@ -22759,23 +22795,15 @@
22759
22795
  return _context.abrupt("return");
22760
22796
  case 8:
22761
22797
  this.currentRenderService = renderService;
22762
- context = drawContext.context, _drawContext$x = drawContext.x, x = _drawContext$x === void 0 ? 0 : _drawContext$x, _drawContext$y = drawContext.y, y = _drawContext$y === void 0 ? 0 : _drawContext$y;
22763
- if (context) {
22764
- if (drawContext.keepMatrix) {
22765
- if (context.nativeContext && context.nativeContext.getTransform) {
22766
- t = context.nativeContext.getTransform();
22767
- context.setTransformFromMatrix(t, !0, 1);
22768
- }
22769
- } else context.inuse = !0, context.clearMatrix();
22770
- context.setTransformForCurrent(!0), context.save(), drawContext.restartIncremental && this.clearScreen(this.currentRenderService, context, drawContext), context.translate(x, y, !0), context.save(), renderService.renderTreeRoots.sort(function (a, b) {
22771
- var _a, _b;
22772
- return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
22773
- }).forEach(function (group) {
22774
- _this2.renderGroup(group, drawContext);
22775
- }), this.hooks.completeDraw.tap("top-draw", function () {
22776
- context.restore(), context.restore(), context.draw(), drawContext.keepMatrix || (context.inuse = !1), _this2.rendering = !1;
22777
- });
22778
- }
22798
+ context = drawContext.context, viewBox = drawContext.viewBox;
22799
+ context && (context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0), context.save(), drawContext.restartIncremental && this.clearScreen(this.currentRenderService, context, drawContext), context.translate(viewBox.x1, viewBox.y1, !0), context.save(), renderService.renderTreeRoots.sort(function (a, b) {
22800
+ var _a, _b;
22801
+ return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
22802
+ }).forEach(function (group) {
22803
+ _this2.renderGroup(group, drawContext);
22804
+ }), this.hooks.completeDraw.tap("top-draw", function () {
22805
+ context.restore(), context.restore(), context.draw(), context.inuse = !1, _this2.rendering = !1;
22806
+ }));
22779
22807
  case 11:
22780
22808
  case "end":
22781
22809
  return _context.stop();
@@ -23181,12 +23209,10 @@
23181
23209
  if (!layer || !group.layer.subLayers) return;
23182
23210
  var subLayer = group.layer.subLayers.get(group._uid);
23183
23211
  subLayer && subLayer.drawContribution && subLayer.drawContribution.draw(stage.renderService, Object.assign({
23184
- x: stage.x,
23185
- y: stage.y,
23186
- width: layer.viewWidth,
23187
- height: layer.viewHeight,
23188
23212
  stage: stage,
23189
23213
  layer: layer,
23214
+ viewBox: stage.window.getViewBox(),
23215
+ transMatrix: stage.window.getViewBoxTransform(),
23190
23216
  clear: "transparent",
23191
23217
  renderService: stage.renderService,
23192
23218
  updateBounds: !1,
@@ -23838,7 +23864,13 @@
23838
23864
  _classCallCheck(this, Stage);
23839
23865
  var _a;
23840
23866
  _this = _super.call(this, {}), _this._onVisibleChange = function (visible) {
23841
- _this._skipRender < 0 || (visible ? (_this.dirtyBounds && _this.dirtyBounds.setValue(0, 0, _this._viewBox.width(), _this._viewBox.height()), _this._skipRender > 1 && _this.renderNextFrame(), _this._skipRender = 0) : _this._skipRender = 1);
23867
+ if (!(_this._skipRender < 0)) if (visible) {
23868
+ if (_this.dirtyBounds) {
23869
+ var b = _this.window.getViewBox();
23870
+ _this.dirtyBounds.setValue(b.x1, b.y1, b.width(), b.height());
23871
+ }
23872
+ _this._skipRender > 1 && _this.renderNextFrame(), _this._skipRender = 0;
23873
+ } else _this._skipRender = 1;
23842
23874
  }, _this.beforeRender = function (stage) {
23843
23875
  _this._beforeRender && _this._beforeRender(stage);
23844
23876
  }, _this.afterRender = function (stage) {
@@ -23851,12 +23883,13 @@
23851
23883
  }, _this.global = application.global, !_this.global.env && isBrowserEnv() && _this.global.setEnv("browser"), _this.window = container.get(VWindow), _this.renderService = container.get(RenderService), _this.pluginService = container.get(PluginService), _this.layerService = container.get(LayerService), _this.pluginService.active(_assertThisInitialized(_this), params), _this.window.create({
23852
23884
  width: params.width,
23853
23885
  height: params.height,
23886
+ viewBox: params.viewBox,
23854
23887
  container: params.container,
23855
23888
  dpr: params.dpr || _this.global.devicePixelRatio,
23856
23889
  canvasControled: !1 !== params.canvasControled,
23857
23890
  title: params.title || "",
23858
23891
  canvas: params.canvas
23859
- }), _this._viewBox = new AABBBounds(), params.viewBox ? _this._viewBox.setValue(params.viewBox.x1, params.viewBox.y1, params.viewBox.x2, params.viewBox.y2) : _this._viewBox.setValue(0, 0, _this.width, _this.height), _this.state = "normal", _this.renderCount = 0, _this.tryInitEventSystem(), _this._subView = !(_this._viewBox.width() === _this.width && _this._viewBox.height() === _this.height), _this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig$1.BACKGROUND, _this.appendChild(_this.layerService.createLayer(_assertThisInitialized(_this), {
23892
+ }), _this.state = "normal", _this.renderCount = 0, _this.tryInitEventSystem(), _this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig$1.BACKGROUND, _this.appendChild(_this.layerService.createLayer(_assertThisInitialized(_this), {
23860
23893
  main: !0
23861
23894
  })), _this.nextFrameRenderLayerSet = new Set(), _this.willNextFrameRender = !1, _this.stage = _assertThisInitialized(_this), _this.renderStyle = params.renderStyle, params.autoRender && _this.enableAutoRender(), !1 === params.disableDirtyBounds && _this.enableDirtyBounds(), params.enableHtmlAttribute && _this.enableHtmlAttribute(params.enableHtmlAttribute), params.enableLayout && _this.enableLayout(), _this.hooks.beforeRender.tap("constructor", _this.beforeRender), _this.hooks.afterRender.tap("constructor", _this.afterRender), _this._beforeRender = params.beforeRender, _this._afterRender = params.afterRender, _this.ticker = params.ticker || defaultTicker, _this.supportInteractiveLayer = !1 !== params.interactiveLayer, _this.timeline = new DefaultTimeline(), _this.ticker.addTimeline(_this.timeline), _this.timeline.pause(), params.optimize || (params.optimize = {}), _this.optmize(params.optimize), params.background && isString$1(_this._background) && _this._background.includes("/") && _this.setAttributes({
23862
23895
  background: _this._background
@@ -23866,26 +23899,28 @@
23866
23899
  _createClass(Stage, [{
23867
23900
  key: "viewBox",
23868
23901
  get: function get() {
23869
- return this._viewBox;
23902
+ return this.window.getViewBox();
23870
23903
  },
23871
23904
  set: function set(b) {
23872
- this._viewBox.setValue(b.x1, b.y1, b.x2, b.y2);
23905
+ this.window.setViewBox(b);
23873
23906
  }
23874
23907
  }, {
23875
23908
  key: "x",
23876
23909
  get: function get() {
23877
- return this._viewBox.x1;
23910
+ return this.window.getViewBox().x1;
23878
23911
  },
23879
23912
  set: function set(x) {
23880
- this._viewBox.translate(x - this._viewBox.x1, 0);
23913
+ var b = this.window.getViewBox();
23914
+ b.translate(x - b.x1, 0), this.window.setViewBox(b);
23881
23915
  }
23882
23916
  }, {
23883
23917
  key: "y",
23884
23918
  get: function get() {
23885
- return this._viewBox.y1;
23919
+ return this.window.getViewBox().y1;
23886
23920
  },
23887
23921
  set: function set(y) {
23888
- this._viewBox.translate(0, y - this._viewBox.y1);
23922
+ var b = this.window.getViewBox();
23923
+ b.translate(0, y - b.y1), this.window.setViewBox(b);
23889
23924
  }
23890
23925
  }, {
23891
23926
  key: "width",
@@ -23898,7 +23933,7 @@
23898
23933
  }, {
23899
23934
  key: "viewWidth",
23900
23935
  get: function get() {
23901
- return this._viewBox.width();
23936
+ return this.window.getViewBox().width();
23902
23937
  },
23903
23938
  set: function set(w) {
23904
23939
  this.resizeView(w, this.viewHeight);
@@ -23906,7 +23941,7 @@
23906
23941
  }, {
23907
23942
  key: "viewHeight",
23908
23943
  get: function get() {
23909
- return this._viewBox.height();
23944
+ return this.window.getViewBox().height();
23910
23945
  },
23911
23946
  set: function set(h) {
23912
23947
  this.resizeView(this.viewWidth, h);
@@ -23946,6 +23981,16 @@
23946
23981
  get: function get() {
23947
23982
  return this._eventSystem;
23948
23983
  }
23984
+ }, {
23985
+ key: "pauseRender",
23986
+ value: function pauseRender() {
23987
+ this._skipRender = -1;
23988
+ }
23989
+ }, {
23990
+ key: "resumeRender",
23991
+ value: function resumeRender() {
23992
+ this._skipRender = 0;
23993
+ }
23949
23994
  }, {
23950
23995
  key: "tryInitEventSystem",
23951
23996
  value: function tryInitEventSystem() {
@@ -23955,22 +24000,7 @@
23955
24000
  rootNode: this,
23956
24001
  global: this.global,
23957
24002
  supportsPointerEvents: this.params.supportsPointerEvents,
23958
- supportsTouchEvents: this.params.supportsTouchEvents,
23959
- viewport: {
23960
- viewBox: this._viewBox,
23961
- get x() {
23962
- return this.viewBox.x1;
23963
- },
23964
- get y() {
23965
- return this.viewBox.y1;
23966
- },
23967
- get width() {
23968
- return this.viewBox.width();
23969
- },
23970
- get height() {
23971
- return this.viewBox.height();
23972
- }
23973
- }
24003
+ supportsTouchEvents: this.params.supportsTouchEvents
23974
24004
  }, this.params.event)));
23975
24005
  }
23976
24006
  }, {
@@ -24170,7 +24200,7 @@
24170
24200
  }, {
24171
24201
  key: "tryUpdateAABBBounds",
24172
24202
  value: function tryUpdateAABBBounds() {
24173
- var viewBox = this._viewBox;
24203
+ var viewBox = this.window.getViewBox();
24174
24204
  return this._AABBBounds.setValue(viewBox.x1, viewBox.y1, viewBox.x2, viewBox.y2), this._AABBBounds;
24175
24205
  }
24176
24206
  }, {
@@ -24210,14 +24240,14 @@
24210
24240
  }, {
24211
24241
  key: "clearViewBox",
24212
24242
  value: function clearViewBox(color) {
24213
- this.window.clearViewBox(this._viewBox, color);
24243
+ this.window.clearViewBox(color);
24214
24244
  }
24215
24245
  }, {
24216
24246
  key: "render",
24217
24247
  value: function render(layers, params) {
24218
24248
  this.ticker.start(), this.timeline.resume();
24219
24249
  var state = this.state;
24220
- this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this.renderLayerList(this.children, params), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear(), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
24250
+ this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
24221
24251
  }
24222
24252
  }, {
24223
24253
  key: "combineLayersToWindow",
@@ -24237,7 +24267,7 @@
24237
24267
  value: function _doRenderInThisFrame() {
24238
24268
  this.timeline.resume(), this.ticker.start();
24239
24269
  var state = this.state;
24240
- this.state = "rendering", this.layerService.prepareStageLayer(this), this.nextFrameRenderLayerSet.size && !this._skipRender && (this.hooks.beforeRender.call(this), this.renderLayerList(Array.from(this.nextFrameRenderLayerSet.values()), this.lastRenderparams || {}), this.combineLayersToWindow(), this.hooks.afterRender.call(this), this.nextFrameRenderLayerSet.clear()), this.state = state, this._skipRender && this._skipRender++;
24270
+ this.state = "rendering", this.layerService.prepareStageLayer(this), this.nextFrameRenderLayerSet.size && !this._skipRender && (this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(Array.from(this.nextFrameRenderLayerSet.values()), this.lastRenderparams || {}), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
24241
24271
  }
24242
24272
  }, {
24243
24273
  key: "renderLayerList",
@@ -24252,14 +24282,17 @@
24252
24282
  layer.renderCount > _this10.renderCount || (layer.renderCount = _this10.renderCount + 1, layer.render({
24253
24283
  renderService: _this10.renderService,
24254
24284
  background: layer === _this10.defaultLayer ? _this10.background : void 0,
24255
- updateBounds: !(!_this10.dirtyBounds || _this10.dirtyBounds.empty())
24285
+ updateBounds: !(!_this10.dirtyBounds || _this10.dirtyBounds.empty()),
24286
+ viewBox: _this10.window.getViewBox(),
24287
+ transMatrix: _this10.window.getViewBoxTransform()
24256
24288
  }, Object.assign({
24257
- renderStyle: _this10.renderStyle,
24258
- keepMatrix: _this10.params.renderKeepMatrix
24289
+ renderStyle: _this10.renderStyle
24259
24290
  }, params)));
24260
24291
  }), this.interactiveLayer && !layerList.includes(this.interactiveLayer) && this.interactiveLayer.render({
24261
24292
  renderService: this.renderService,
24262
- updateBounds: !(!this.dirtyBounds || this.dirtyBounds.empty())
24293
+ updateBounds: !(!this.dirtyBounds || this.dirtyBounds.empty()),
24294
+ viewBox: this.window.getViewBox(),
24295
+ transMatrix: this.window.getViewBoxTransform()
24263
24296
  }, Object.assign({
24264
24297
  renderStyle: this.renderStyle
24265
24298
  }, params));
@@ -24274,9 +24307,9 @@
24274
24307
  key: "resize",
24275
24308
  value: function resize(w, h) {
24276
24309
  var rerender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
24277
- this.window.resize(w, h), this.forEachChildren(function (c) {
24310
+ this.window.hasSubView() || this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h), this.window.resize(w, h), this.forEachChildren(function (c) {
24278
24311
  c.resize(w, h);
24279
- }), this._subView || this.viewBox.setValue(this.viewBox.x1, this.viewBox.y1, this.viewBox.x1 + w, this.viewBox.y1 + h), this.camera && this.option3d && this.set3dOptions(this.option3d), rerender && this.render();
24312
+ }), this.camera && this.option3d && this.set3dOptions(this.option3d), rerender && this.render();
24280
24313
  }
24281
24314
  }, {
24282
24315
  key: "resizeView",
@@ -24359,50 +24392,44 @@
24359
24392
  }
24360
24393
  }, {
24361
24394
  key: "renderTo",
24362
- value: function renderTo(window, params) {
24395
+ value: function renderTo(window) {
24363
24396
  var _this12 = this;
24364
24397
  this.forEachChildren(function (layer, i) {
24365
- layer.drawTo(window, Object.assign(Object.assign({}, params), {
24398
+ layer.drawTo(window, {
24366
24399
  renderService: _this12.renderService,
24400
+ viewBox: window.getViewBox(),
24401
+ transMatrix: window.getViewBoxTransform(),
24367
24402
  background: layer === _this12.defaultLayer ? _this12.background : void 0,
24368
24403
  clear: 0 === i,
24369
24404
  updateBounds: !(!_this12.dirtyBounds || _this12.dirtyBounds.empty())
24370
- }));
24405
+ });
24371
24406
  });
24372
24407
  }
24373
24408
  }, {
24374
24409
  key: "renderToNewWindow",
24375
24410
  value: function renderToNewWindow() {
24376
- var fullImage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
24377
24411
  var viewBox = arguments.length > 1 ? arguments[1] : undefined;
24378
- var window = container.get(VWindow);
24379
- if (fullImage) window.create({
24380
- width: this.viewWidth,
24381
- height: this.viewHeight,
24412
+ var window = container.get(VWindow),
24413
+ x1 = viewBox ? -viewBox.x1 : 0,
24414
+ y1 = viewBox ? -viewBox.y1 : 0,
24415
+ x2 = viewBox ? viewBox.x2 : this.viewWidth,
24416
+ y2 = viewBox ? viewBox.y2 : this.viewHeight,
24417
+ width = viewBox ? viewBox.width() : this.viewWidth,
24418
+ height = viewBox ? viewBox.height() : this.viewHeight;
24419
+ return window.create({
24420
+ viewBox: {
24421
+ x1: x1,
24422
+ y1: y1,
24423
+ x2: x2,
24424
+ y2: y2
24425
+ },
24426
+ width: width,
24427
+ height: height,
24382
24428
  dpr: this.window.dpr,
24383
24429
  canvasControled: !0,
24384
24430
  offscreen: !0,
24385
24431
  title: ""
24386
- });else {
24387
- var width = viewBox ? viewBox.width() : Math.min(this.viewWidth, this.window.width - this.x),
24388
- height = viewBox ? viewBox.height() : Math.min(this.viewHeight, this.window.height - this.y);
24389
- window.create({
24390
- width: width,
24391
- height: height,
24392
- dpr: this.window.dpr,
24393
- canvasControled: !0,
24394
- offscreen: !0,
24395
- title: ""
24396
- });
24397
- }
24398
- var x = viewBox ? -viewBox.x1 : 0,
24399
- y = viewBox ? -viewBox.y1 : 0;
24400
- return this.renderTo(window, {
24401
- x: x,
24402
- y: y,
24403
- width: viewBox ? viewBox.x2 : window.width,
24404
- height: viewBox ? viewBox.y2 : window.height
24405
- }), window;
24432
+ }), this.renderTo(window), window;
24406
24433
  }
24407
24434
  }, {
24408
24435
  key: "toCanvas",
@@ -24442,7 +24469,7 @@
24442
24469
  __metadata$S = undefined && undefined.__metadata || function (k, v) {
24443
24470
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
24444
24471
  };
24445
- var initMatrix$1 = new Matrix(1, 0, 0, 1, 0, 0),
24472
+ var initMatrix = new Matrix(1, 0, 0, 1, 0, 0),
24446
24473
  globalPoint = {
24447
24474
  x: 0,
24448
24475
  y: 0
@@ -24450,7 +24477,7 @@
24450
24477
  exports.EmptyContext2d = /*#__PURE__*/function () {
24451
24478
  function EmptyContext2d(canvas, dpr) {
24452
24479
  _classCallCheck(this, EmptyContext2d);
24453
- this.matrix = new Matrix(1, 0, 0, 1, 0, 0), this.stack = [], this.dpr = dpr, this.applyedMatrix = new Matrix(1, 0, 0, 1, 0, 0), this.path = new CustomPath2D();
24480
+ this.matrix = new Matrix(1, 0, 0, 1, 0, 0), this.stack = [], this.dpr = dpr, this.applyedMatrix = new Matrix(1, 0, 0, 1, 0, 0), this.path = new CustomPath2D(), this._clearMatrix = new Matrix(1, 0, 0, 1, 0, 0);
24454
24481
  }
24455
24482
  _createClass(EmptyContext2d, [{
24456
24483
  key: "nativeContext",
@@ -24763,7 +24790,12 @@
24763
24790
  value: function clearMatrix() {
24764
24791
  var setTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
24765
24792
  var dpr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.dpr;
24766
- this.setTransformFromMatrix(initMatrix$1, setTransform, dpr);
24793
+ this.setTransformFromMatrix(initMatrix, setTransform, dpr);
24794
+ }
24795
+ }, {
24796
+ key: "setClearMatrix",
24797
+ value: function setClearMatrix(a, b, c, d, e, f) {
24798
+ this._clearMatrix.setValue(a, b, c, d, e, f);
24767
24799
  }
24768
24800
  }, {
24769
24801
  key: "onlyTranslate",
@@ -25078,7 +25110,7 @@
25078
25110
  exports.BaseWindowHandlerContribution = /*#__PURE__*/function () {
25079
25111
  function BaseWindowHandlerContribution() {
25080
25112
  _classCallCheck(this, BaseWindowHandlerContribution);
25081
- this._uid = Generator.GenAutoIncrementId();
25113
+ this._uid = Generator.GenAutoIncrementId(), this.viewBox = new AABBBounds(), this.modelMatrix = new Matrix(1, 0, 0, 1, 0, 0);
25082
25114
  }
25083
25115
  _createClass(BaseWindowHandlerContribution, [{
25084
25116
  key: "onChange",
@@ -25111,6 +25143,26 @@
25111
25143
  left: 0
25112
25144
  };
25113
25145
  }
25146
+ }, {
25147
+ key: "setViewBox",
25148
+ value: function setViewBox(vb) {
25149
+ this.viewBox.setValue(vb.x1, vb.y1, vb.x2, vb.y2);
25150
+ }
25151
+ }, {
25152
+ key: "getViewBox",
25153
+ value: function getViewBox() {
25154
+ return this.viewBox;
25155
+ }
25156
+ }, {
25157
+ key: "setViewBoxTransform",
25158
+ value: function setViewBoxTransform(a, b, c, d, e, f) {
25159
+ this.modelMatrix.setValue(a, b, c, d, e, f);
25160
+ }
25161
+ }, {
25162
+ key: "getViewBoxTransform",
25163
+ value: function getViewBoxTransform() {
25164
+ return this.modelMatrix;
25165
+ }
25114
25166
  }]);
25115
25167
  return BaseWindowHandlerContribution;
25116
25168
  }();
@@ -25151,23 +25203,14 @@
25151
25203
  group: null
25152
25204
  };
25153
25205
  params.pickerService = this;
25154
- var offsetX = 0,
25155
- offsetY = 0;
25156
- if (params && params.bounds) {
25157
- if (!params.bounds.contains(point.x, point.y)) return result;
25158
- offsetX = params.bounds.x1, offsetY = params.bounds.y1;
25159
- }
25160
- if (this.pickContext) if (params.keepMatrix) {
25161
- if (this.pickContext.nativeContext && this.pickContext.nativeContext.getTransform) {
25162
- var t = this.pickContext.nativeContext.getTransform();
25163
- this.pickContext.setTransformFromMatrix(t, !0, 1);
25164
- }
25165
- } else this.pickContext.inuse = !0, this.pickContext.clearMatrix(!0, 1);
25166
- params.pickContext = this.pickContext;
25167
- var parentMatrix = new Matrix(1, 0, 0, 1, offsetX, offsetY);
25206
+ var w = params.bounds.width(),
25207
+ h = params.bounds.height();
25208
+ if (!new AABBBounds().setValue(0, 0, w, h).containsPoint(point)) return result;
25209
+ this.pickContext && (this.pickContext.inuse = !0), params.pickContext = this.pickContext, this.pickContext && this.pickContext.clearMatrix(!0, 1);
25210
+ var parentMatrix = new Matrix(1, 0, 0, 1, 0, 0);
25168
25211
  var group;
25169
25212
  for (var i = graphics.length - 1; i >= 0 && (result = graphics[i].isContainer ? this.pickGroup(graphics[i], point, parentMatrix, params) : this.pickItem(graphics[i], point, parentMatrix, params), !result.graphic); i--) group || (group = result.group);
25170
- if (result.graphic || (result.group = group), this.pickContext && !params.keepMatrix && (this.pickContext.inuse = !1), result.graphic) {
25213
+ if (result.graphic || (result.group = group), this.pickContext && (this.pickContext.inuse = !1), result.graphic) {
25171
25214
  var g = result.graphic;
25172
25215
  for (; g.parent;) g = g.parent;
25173
25216
  g.shadowHost && (result.params = {
@@ -29446,7 +29489,6 @@
29446
29489
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
29447
29490
  };
29448
29491
  var outP = [0, 0, 0],
29449
- initMatrix = new Matrix(1, 0, 0, 1, 0, 0),
29450
29492
  addArcToBezierPath = function addArcToBezierPath(bezierPath, startAngle, endAngle, cx, cy, rx, ry, clockwise) {
29451
29493
  if (clockwise) for (; endAngle > startAngle;) endAngle -= pi2;else for (; endAngle < startAngle;) endAngle += pi2;
29452
29494
  var step = pi / 3 * (endAngle > startAngle ? 1 : -1);
@@ -29482,7 +29524,7 @@
29482
29524
  }), this._clearShadowStyle = !1, this._clearFilterStyle = !1, this._clearGlobalCompositeOperationStyle = !1;
29483
29525
  var context = canvas.nativeCanvas.getContext("2d");
29484
29526
  if (!context) throw new Error("发生错误,获取2d上下文失败");
29485
- this.nativeContext = context, this.canvas = canvas, this.matrix = new Matrix(1, 0, 0, 1, 0, 0), this.stack = [], this.dpr = dpr, this.applyedMatrix = new Matrix(1, 0, 0, 1, 0, 0);
29527
+ this.nativeContext = context, this.canvas = canvas, this.matrix = new Matrix(1, 0, 0, 1, 0, 0), this.stack = [], this.dpr = dpr, this.applyedMatrix = new Matrix(1, 0, 0, 1, 0, 0), this._clearMatrix = new Matrix(1, 0, 0, 1, 0, 0);
29486
29528
  }
29487
29529
  _createClass(BrowserContext2d, [{
29488
29530
  key: "fillStyle",
@@ -30118,7 +30160,12 @@
30118
30160
  value: function clearMatrix() {
30119
30161
  var setTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
30120
30162
  var dpr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.dpr;
30121
- this.setTransformFromMatrix(initMatrix, setTransform, dpr);
30163
+ this.setTransformFromMatrix(this._clearMatrix, setTransform, dpr);
30164
+ }
30165
+ }, {
30166
+ key: "setClearMatrix",
30167
+ value: function setClearMatrix(a, b, c, d, e, f) {
30168
+ this._clearMatrix.setValue(a, b, c, d, e, f);
30122
30169
  }
30123
30170
  }, {
30124
30171
  key: "onlyTranslate",
@@ -30402,7 +30449,7 @@
30402
30449
  function BrowserWindowHandlerContribution_1() {
30403
30450
  var _this;
30404
30451
  _classCallCheck(this, BrowserWindowHandlerContribution_1);
30405
- _this = _super.call(this), _this.type = "browser", _this._canvasIsIntersecting = !0, _this.global = application.global;
30452
+ _this = _super.call(this), _this.type = "browser", _this._canvasIsIntersecting = !0, _this.global = application.global, _this.viewBox = new AABBBounds(), _this.modelMatrix = new Matrix(1, 0, 0, 1, 0, 0);
30406
30453
  return _this;
30407
30454
  }
30408
30455
  _createClass(BrowserWindowHandlerContribution_1, [{
@@ -30583,8 +30630,9 @@
30583
30630
  }
30584
30631
  }, {
30585
30632
  key: "clearViewBox",
30586
- value: function clearViewBox(vb, color) {
30587
- var context = this.getContext(),
30633
+ value: function clearViewBox(color) {
30634
+ var vb = this.viewBox,
30635
+ context = this.getContext(),
30588
30636
  dpr = this.getDpr();
30589
30637
  context.nativeContext.save(), context.nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0), context.clearRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1), color && (context.fillStyle = color, context.fillRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1)), context.nativeContext.restore();
30590
30638
  }
@@ -31188,8 +31236,9 @@
31188
31236
  }
31189
31237
  }, {
31190
31238
  key: "clearViewBox",
31191
- value: function clearViewBox(vb, color) {
31192
- var context = this.getContext(),
31239
+ value: function clearViewBox(color) {
31240
+ var vb = this.viewBox,
31241
+ context = this.getContext(),
31193
31242
  dpr = this.getDpr();
31194
31243
  context.nativeContext.save(), context.nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0), context.clearRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1), color && (context.fillStyle = color, context.fillRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1)), context.nativeContext.restore();
31195
31244
  }
@@ -31836,8 +31885,9 @@
31836
31885
  }
31837
31886
  }, {
31838
31887
  key: "clearViewBox",
31839
- value: function clearViewBox(vb, color) {
31840
- var context = this.getContext(),
31888
+ value: function clearViewBox(color) {
31889
+ var vb = this.viewBox,
31890
+ context = this.getContext(),
31841
31891
  dpr = this.getDpr();
31842
31892
  context.nativeContext.save(), context.nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0), context.clearRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1), color && (context.fillStyle = color, context.fillRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1)), context.nativeContext.restore();
31843
31893
  }
@@ -32237,7 +32287,7 @@
32237
32287
  }
32238
32288
  }, {
32239
32289
  key: "clearViewBox",
32240
- value: function clearViewBox(vb, color) {}
32290
+ value: function clearViewBox(color) {}
32241
32291
  }]);
32242
32292
  return NodeWindowHandlerContribution;
32243
32293
  }(exports.BaseWindowHandlerContribution);
@@ -32767,8 +32817,9 @@
32767
32817
  }
32768
32818
  }, {
32769
32819
  key: "clearViewBox",
32770
- value: function clearViewBox(vb, color) {
32771
- var context = this.getContext(),
32820
+ value: function clearViewBox(color) {
32821
+ var vb = this.viewBox,
32822
+ context = this.getContext(),
32772
32823
  dpr = this.getDpr();
32773
32824
  context.nativeContext.save(), context.nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0), context.clearRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1), color && (context.fillStyle = color, context.fillRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1)), context.nativeContext.restore();
32774
32825
  }
@@ -33199,8 +33250,9 @@
33199
33250
  }
33200
33251
  }, {
33201
33252
  key: "clearViewBox",
33202
- value: function clearViewBox(vb, color) {
33203
- var context = this.getContext(),
33253
+ value: function clearViewBox(color) {
33254
+ var vb = this.viewBox,
33255
+ context = this.getContext(),
33204
33256
  dpr = this.getDpr();
33205
33257
  context.nativeContext.save(), context.nativeContext.setTransform(dpr, 0, 0, dpr, 0, 0), context.clearRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1), color && (context.fillStyle = color, context.fillRect(vb.x1, vb.y1, vb.x2 - vb.x1, vb.y2 - vb.y1)), context.nativeContext.restore();
33206
33258
  }
@@ -35041,7 +35093,7 @@
35041
35093
 
35042
35094
  var roughModule = _roughModule;
35043
35095
 
35044
- const version = "0.17.20-alpha.6";
35096
+ const version = "0.17.20-alpha.8";
35045
35097
  preLoadAllModule();
35046
35098
  if (isBrowserEnv()) {
35047
35099
  loadBrowserEnv(container);