@visactor/vrender 0.17.20-alpha.5 → 0.17.20-alpha.7

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));
@@ -22034,10 +22090,10 @@
22034
22090
  value: function render(group, params) {
22035
22091
  var _a;
22036
22092
  params.renderService.render(group, Object.assign(Object.assign({
22037
- context: this.context
22093
+ context: this.context,
22094
+ viewBox: params.stage.window.getViewBox(),
22095
+ transMatrix: params.stage.window.getViewBoxTransform()
22038
22096
  }, params), {
22039
- x: 0,
22040
- y: 0,
22041
22097
  clear: null !== (_a = params.background) && void 0 !== _a ? _a : "#ffffff"
22042
22098
  }));
22043
22099
  }
@@ -22059,14 +22115,11 @@
22059
22115
  value: function drawTo(target, group, params) {
22060
22116
  var context = target.getContext(),
22061
22117
  targetDpr = target.dpr,
22062
- _params$x = params.x,
22063
- x = _params$x === void 0 ? 0 : _params$x,
22064
- _params$y = params.y,
22065
- y = _params$y === void 0 ? 0 : _params$y,
22066
- _params$width = params.width,
22067
- width = _params$width === void 0 ? this.layer.viewWidth : _params$width,
22068
- _params$height = params.height,
22069
- 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();
22070
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();
22071
22124
  }
22072
22125
  }, {
@@ -22247,33 +22300,21 @@
22247
22300
  this.prepareForDraw(renderService, drawContext), drawContext.drawContribution = this, this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap, this.currentRenderService = renderService;
22248
22301
  var context = drawContext.context,
22249
22302
  stage = drawContext.stage,
22250
- _drawContext$x = drawContext.x,
22251
- x = _drawContext$x === void 0 ? 0 : _drawContext$x,
22252
- _drawContext$y = drawContext.y,
22253
- y = _drawContext$y === void 0 ? 0 : _drawContext$y,
22254
- width = drawContext.width,
22255
- height = drawContext.height;
22303
+ viewBox = drawContext.viewBox,
22304
+ transMatrix = drawContext.transMatrix;
22256
22305
  if (!context) return;
22257
- if (drawContext.keepMatrix) {
22258
- if (context.nativeContext && context.nativeContext.getTransform) {
22259
- var t = context.nativeContext.getTransform();
22260
- context.setTransformFromMatrix(t, !0, 1);
22261
- }
22262
- } else context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
22263
- var dirtyBounds = this.dirtyBounds.setValue(0, 0, width, height);
22306
+ var dirtyBounds = this.dirtyBounds.setValue(0, 0, viewBox.width(), viewBox.height());
22264
22307
  if (stage.dirtyBounds && !stage.dirtyBounds.empty()) {
22265
22308
  var b = getRectIntersect(dirtyBounds, stage.dirtyBounds, !1);
22266
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);
22267
22310
  }
22268
22311
  var d = context.dpr % 1;
22269
- (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);
22270
- var drawInArea = dirtyBounds.width() * context.dpr < context.canvas.width || dirtyBounds.height() * context.dpr < context.canvas.height;
22271
- 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) {
22272
22313
  var _a, _b;
22273
22314
  return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
22274
22315
  }).forEach(function (group) {
22275
22316
  group.isContainer ? _this2.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : _this2.renderItem(group, drawContext);
22276
- }), 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;
22277
22318
  }
22278
22319
  }, {
22279
22320
  key: "doRegister",
@@ -22407,28 +22448,24 @@
22407
22448
  key: "clearScreen",
22408
22449
  value: function clearScreen(renderService, context, drawContext) {
22409
22450
  var _a, _b;
22410
- var clear = drawContext.clear;
22451
+ var clear = drawContext.clear,
22452
+ viewBox = drawContext.viewBox,
22453
+ width = viewBox.width(),
22454
+ height = viewBox.height();
22411
22455
  if (clear) {
22412
- var canvas = context.getCanvas(),
22413
- _drawContext$width = drawContext.width,
22414
- width = _drawContext$width === void 0 ? canvas.width : _drawContext$width,
22415
- _drawContext$height = drawContext.height,
22416
- height = _drawContext$height === void 0 ? canvas.height : _drawContext$height,
22417
- x = 0,
22418
- y = 0;
22419
- context.clearRect(x, y, width, height);
22456
+ context.clearRect(0, 0, width, height);
22420
22457
  var stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
22421
22458
  if (stage && (context.globalAlpha = null !== (_b = stage.attribute.opacity) && void 0 !== _b ? _b : 1), stage && stage.backgroundImg && stage.resources) {
22422
22459
  var res = stage.resources.get(clear);
22423
- 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);
22424
22461
  } else context.fillStyle = createColor(context, clear, {
22425
22462
  AABBBounds: {
22426
- x1: x,
22427
- y1: y,
22428
- x2: x + width,
22429
- y2: y + height
22463
+ x1: 0,
22464
+ y1: 0,
22465
+ x2: 0 + width,
22466
+ y2: 0 + height
22430
22467
  }
22431
- }, 0, 0), context.fillRect(x, y, width, height);
22468
+ }, 0, 0), context.fillRect(0, 0, width, height);
22432
22469
  }
22433
22470
  }
22434
22471
  }, {
@@ -22736,7 +22773,7 @@
22736
22773
  value: function draw(renderService, drawContext) {
22737
22774
  return __awaiter$1(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
22738
22775
  var _this2 = this;
22739
- var skipDraw, context, _drawContext$x, x, _drawContext$y, y, t;
22776
+ var skipDraw, context, viewBox;
22740
22777
  return _regeneratorRuntime().wrap(function _callee$(_context) {
22741
22778
  while (1) switch (_context.prev = _context.next) {
22742
22779
  case 0:
@@ -22758,23 +22795,15 @@
22758
22795
  return _context.abrupt("return");
22759
22796
  case 8:
22760
22797
  this.currentRenderService = renderService;
22761
- 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;
22762
- if (context) {
22763
- if (drawContext.keepMatrix) {
22764
- if (context.nativeContext && context.nativeContext.getTransform) {
22765
- t = context.nativeContext.getTransform();
22766
- context.setTransformFromMatrix(t, !0, 1);
22767
- }
22768
- } else context.inuse = !0, context.clearMatrix();
22769
- 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) {
22770
- var _a, _b;
22771
- return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
22772
- }).forEach(function (group) {
22773
- _this2.renderGroup(group, drawContext);
22774
- }), this.hooks.completeDraw.tap("top-draw", function () {
22775
- context.restore(), context.restore(), context.draw(), drawContext.keepMatrix || (context.inuse = !1), _this2.rendering = !1;
22776
- });
22777
- }
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
+ }));
22778
22807
  case 11:
22779
22808
  case "end":
22780
22809
  return _context.stop();
@@ -23180,12 +23209,10 @@
23180
23209
  if (!layer || !group.layer.subLayers) return;
23181
23210
  var subLayer = group.layer.subLayers.get(group._uid);
23182
23211
  subLayer && subLayer.drawContribution && subLayer.drawContribution.draw(stage.renderService, Object.assign({
23183
- x: stage.x,
23184
- y: stage.y,
23185
- width: layer.viewWidth,
23186
- height: layer.viewHeight,
23187
23212
  stage: stage,
23188
23213
  layer: layer,
23214
+ viewBox: stage.window.getViewBox(),
23215
+ transMatrix: stage.window.getViewBoxTransform(),
23189
23216
  clear: "transparent",
23190
23217
  renderService: stage.renderService,
23191
23218
  updateBounds: !1,
@@ -23837,7 +23864,13 @@
23837
23864
  _classCallCheck(this, Stage);
23838
23865
  var _a;
23839
23866
  _this = _super.call(this, {}), _this._onVisibleChange = function (visible) {
23840
- _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;
23841
23874
  }, _this.beforeRender = function (stage) {
23842
23875
  _this._beforeRender && _this._beforeRender(stage);
23843
23876
  }, _this.afterRender = function (stage) {
@@ -23850,12 +23883,13 @@
23850
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({
23851
23884
  width: params.width,
23852
23885
  height: params.height,
23886
+ viewBox: params.viewBox,
23853
23887
  container: params.container,
23854
23888
  dpr: params.dpr || _this.global.devicePixelRatio,
23855
23889
  canvasControled: !1 !== params.canvasControled,
23856
23890
  title: params.title || "",
23857
23891
  canvas: params.canvas
23858
- }), _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), {
23859
23893
  main: !0
23860
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({
23861
23895
  background: _this._background
@@ -23865,26 +23899,28 @@
23865
23899
  _createClass(Stage, [{
23866
23900
  key: "viewBox",
23867
23901
  get: function get() {
23868
- return this._viewBox;
23902
+ return this.window.getViewBox();
23869
23903
  },
23870
23904
  set: function set(b) {
23871
- this._viewBox.setValue(b.x1, b.y1, b.x2, b.y2);
23905
+ this.window.setViewBox(b);
23872
23906
  }
23873
23907
  }, {
23874
23908
  key: "x",
23875
23909
  get: function get() {
23876
- return this._viewBox.x1;
23910
+ return this.window.getViewBox().x1;
23877
23911
  },
23878
23912
  set: function set(x) {
23879
- 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);
23880
23915
  }
23881
23916
  }, {
23882
23917
  key: "y",
23883
23918
  get: function get() {
23884
- return this._viewBox.y1;
23919
+ return this.window.getViewBox().y1;
23885
23920
  },
23886
23921
  set: function set(y) {
23887
- 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);
23888
23924
  }
23889
23925
  }, {
23890
23926
  key: "width",
@@ -23897,7 +23933,7 @@
23897
23933
  }, {
23898
23934
  key: "viewWidth",
23899
23935
  get: function get() {
23900
- return this._viewBox.width();
23936
+ return this.window.getViewBox().width();
23901
23937
  },
23902
23938
  set: function set(w) {
23903
23939
  this.resizeView(w, this.viewHeight);
@@ -23905,7 +23941,7 @@
23905
23941
  }, {
23906
23942
  key: "viewHeight",
23907
23943
  get: function get() {
23908
- return this._viewBox.height();
23944
+ return this.window.getViewBox().height();
23909
23945
  },
23910
23946
  set: function set(h) {
23911
23947
  this.resizeView(this.viewWidth, h);
@@ -23945,6 +23981,16 @@
23945
23981
  get: function get() {
23946
23982
  return this._eventSystem;
23947
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
+ }
23948
23994
  }, {
23949
23995
  key: "tryInitEventSystem",
23950
23996
  value: function tryInitEventSystem() {
@@ -23954,22 +24000,7 @@
23954
24000
  rootNode: this,
23955
24001
  global: this.global,
23956
24002
  supportsPointerEvents: this.params.supportsPointerEvents,
23957
- supportsTouchEvents: this.params.supportsTouchEvents,
23958
- viewport: {
23959
- viewBox: this._viewBox,
23960
- get x() {
23961
- return this.viewBox.x1;
23962
- },
23963
- get y() {
23964
- return this.viewBox.y1;
23965
- },
23966
- get width() {
23967
- return this.viewBox.width();
23968
- },
23969
- get height() {
23970
- return this.viewBox.height();
23971
- }
23972
- }
24003
+ supportsTouchEvents: this.params.supportsTouchEvents
23973
24004
  }, this.params.event)));
23974
24005
  }
23975
24006
  }, {
@@ -24169,7 +24200,7 @@
24169
24200
  }, {
24170
24201
  key: "tryUpdateAABBBounds",
24171
24202
  value: function tryUpdateAABBBounds() {
24172
- var viewBox = this._viewBox;
24203
+ var viewBox = this.window.getViewBox();
24173
24204
  return this._AABBBounds.setValue(viewBox.x1, viewBox.y1, viewBox.x2, viewBox.y2), this._AABBBounds;
24174
24205
  }
24175
24206
  }, {
@@ -24209,14 +24240,14 @@
24209
24240
  }, {
24210
24241
  key: "clearViewBox",
24211
24242
  value: function clearViewBox(color) {
24212
- this.window.clearViewBox(this._viewBox, color);
24243
+ this.window.clearViewBox(color);
24213
24244
  }
24214
24245
  }, {
24215
24246
  key: "render",
24216
24247
  value: function render(layers, params) {
24217
24248
  this.ticker.start(), this.timeline.resume();
24218
24249
  var state = this.state;
24219
- 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++;
24220
24251
  }
24221
24252
  }, {
24222
24253
  key: "combineLayersToWindow",
@@ -24236,7 +24267,7 @@
24236
24267
  value: function _doRenderInThisFrame() {
24237
24268
  this.timeline.resume(), this.ticker.start();
24238
24269
  var state = this.state;
24239
- 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++;
24240
24271
  }
24241
24272
  }, {
24242
24273
  key: "renderLayerList",
@@ -24251,14 +24282,17 @@
24251
24282
  layer.renderCount > _this10.renderCount || (layer.renderCount = _this10.renderCount + 1, layer.render({
24252
24283
  renderService: _this10.renderService,
24253
24284
  background: layer === _this10.defaultLayer ? _this10.background : void 0,
24254
- updateBounds: !(!_this10.dirtyBounds || _this10.dirtyBounds.empty())
24285
+ updateBounds: !(!_this10.dirtyBounds || _this10.dirtyBounds.empty()),
24286
+ viewBox: _this10.window.getViewBox(),
24287
+ transMatrix: _this10.window.getViewBoxTransform()
24255
24288
  }, Object.assign({
24256
- renderStyle: _this10.renderStyle,
24257
- keepMatrix: _this10.params.renderKeepMatrix
24289
+ renderStyle: _this10.renderStyle
24258
24290
  }, params)));
24259
24291
  }), this.interactiveLayer && !layerList.includes(this.interactiveLayer) && this.interactiveLayer.render({
24260
24292
  renderService: this.renderService,
24261
- updateBounds: !(!this.dirtyBounds || this.dirtyBounds.empty())
24293
+ updateBounds: !(!this.dirtyBounds || this.dirtyBounds.empty()),
24294
+ viewBox: this.window.getViewBox(),
24295
+ transMatrix: this.window.getViewBoxTransform()
24262
24296
  }, Object.assign({
24263
24297
  renderStyle: this.renderStyle
24264
24298
  }, params));
@@ -24273,9 +24307,9 @@
24273
24307
  key: "resize",
24274
24308
  value: function resize(w, h) {
24275
24309
  var rerender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
24276
- 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) {
24277
24311
  c.resize(w, h);
24278
- }), 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();
24279
24313
  }
24280
24314
  }, {
24281
24315
  key: "resizeView",
@@ -24358,50 +24392,44 @@
24358
24392
  }
24359
24393
  }, {
24360
24394
  key: "renderTo",
24361
- value: function renderTo(window, params) {
24395
+ value: function renderTo(window) {
24362
24396
  var _this12 = this;
24363
24397
  this.forEachChildren(function (layer, i) {
24364
- layer.drawTo(window, Object.assign(Object.assign({}, params), {
24398
+ layer.drawTo(window, {
24365
24399
  renderService: _this12.renderService,
24400
+ viewBox: window.getViewBox(),
24401
+ transMatrix: window.getViewBoxTransform(),
24366
24402
  background: layer === _this12.defaultLayer ? _this12.background : void 0,
24367
24403
  clear: 0 === i,
24368
24404
  updateBounds: !(!_this12.dirtyBounds || _this12.dirtyBounds.empty())
24369
- }));
24405
+ });
24370
24406
  });
24371
24407
  }
24372
24408
  }, {
24373
24409
  key: "renderToNewWindow",
24374
24410
  value: function renderToNewWindow() {
24375
- var fullImage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
24376
24411
  var viewBox = arguments.length > 1 ? arguments[1] : undefined;
24377
- var window = container.get(VWindow);
24378
- if (fullImage) window.create({
24379
- width: this.viewWidth,
24380
- 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,
24381
24428
  dpr: this.window.dpr,
24382
24429
  canvasControled: !0,
24383
24430
  offscreen: !0,
24384
24431
  title: ""
24385
- });else {
24386
- var width = viewBox ? viewBox.width() : Math.min(this.viewWidth, this.window.width - this.x),
24387
- height = viewBox ? viewBox.height() : Math.min(this.viewHeight, this.window.height - this.y);
24388
- window.create({
24389
- width: width,
24390
- height: height,
24391
- dpr: this.window.dpr,
24392
- canvasControled: !0,
24393
- offscreen: !0,
24394
- title: ""
24395
- });
24396
- }
24397
- var x = viewBox ? -viewBox.x1 : 0,
24398
- y = viewBox ? -viewBox.y1 : 0;
24399
- return this.renderTo(window, {
24400
- x: x,
24401
- y: y,
24402
- width: viewBox ? viewBox.x2 : window.width,
24403
- height: viewBox ? viewBox.y2 : window.height
24404
- }), window;
24432
+ }), this.renderTo(window), window;
24405
24433
  }
24406
24434
  }, {
24407
24435
  key: "toCanvas",
@@ -24441,7 +24469,7 @@
24441
24469
  __metadata$S = undefined && undefined.__metadata || function (k, v) {
24442
24470
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
24443
24471
  };
24444
- var initMatrix$1 = new Matrix(1, 0, 0, 1, 0, 0),
24472
+ var initMatrix = new Matrix(1, 0, 0, 1, 0, 0),
24445
24473
  globalPoint = {
24446
24474
  x: 0,
24447
24475
  y: 0
@@ -24449,7 +24477,7 @@
24449
24477
  exports.EmptyContext2d = /*#__PURE__*/function () {
24450
24478
  function EmptyContext2d(canvas, dpr) {
24451
24479
  _classCallCheck(this, EmptyContext2d);
24452
- 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);
24453
24481
  }
24454
24482
  _createClass(EmptyContext2d, [{
24455
24483
  key: "nativeContext",
@@ -24762,7 +24790,12 @@
24762
24790
  value: function clearMatrix() {
24763
24791
  var setTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
24764
24792
  var dpr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.dpr;
24765
- 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);
24766
24799
  }
24767
24800
  }, {
24768
24801
  key: "onlyTranslate",
@@ -25077,7 +25110,7 @@
25077
25110
  exports.BaseWindowHandlerContribution = /*#__PURE__*/function () {
25078
25111
  function BaseWindowHandlerContribution() {
25079
25112
  _classCallCheck(this, BaseWindowHandlerContribution);
25080
- this._uid = Generator.GenAutoIncrementId();
25113
+ this._uid = Generator.GenAutoIncrementId(), this.viewBox = new AABBBounds(), this.modelMatrix = new Matrix(1, 0, 0, 1, 0, 0);
25081
25114
  }
25082
25115
  _createClass(BaseWindowHandlerContribution, [{
25083
25116
  key: "onChange",
@@ -25110,6 +25143,26 @@
25110
25143
  left: 0
25111
25144
  };
25112
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
+ }
25113
25166
  }]);
25114
25167
  return BaseWindowHandlerContribution;
25115
25168
  }();
@@ -25150,23 +25203,14 @@
25150
25203
  group: null
25151
25204
  };
25152
25205
  params.pickerService = this;
25153
- var offsetX = 0,
25154
- offsetY = 0;
25155
- if (params && params.bounds) {
25156
- if (!params.bounds.contains(point.x, point.y)) return result;
25157
- offsetX = params.bounds.x1, offsetY = params.bounds.y1;
25158
- }
25159
- if (this.pickContext) if (params.keepMatrix) {
25160
- if (this.pickContext.nativeContext && this.pickContext.nativeContext.getTransform) {
25161
- var t = this.pickContext.nativeContext.getTransform();
25162
- this.pickContext.setTransformFromMatrix(t, !0, 1);
25163
- }
25164
- } else this.pickContext.inuse = !0, this.pickContext.clearMatrix(!0, 1);
25165
- params.pickContext = this.pickContext;
25166
- 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);
25167
25211
  var group;
25168
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);
25169
- 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) {
25170
25214
  var g = result.graphic;
25171
25215
  for (; g.parent;) g = g.parent;
25172
25216
  g.shadowHost && (result.params = {
@@ -29445,7 +29489,6 @@
29445
29489
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
29446
29490
  };
29447
29491
  var outP = [0, 0, 0],
29448
- initMatrix = new Matrix(1, 0, 0, 1, 0, 0),
29449
29492
  addArcToBezierPath = function addArcToBezierPath(bezierPath, startAngle, endAngle, cx, cy, rx, ry, clockwise) {
29450
29493
  if (clockwise) for (; endAngle > startAngle;) endAngle -= pi2;else for (; endAngle < startAngle;) endAngle += pi2;
29451
29494
  var step = pi / 3 * (endAngle > startAngle ? 1 : -1);
@@ -29481,7 +29524,7 @@
29481
29524
  }), this._clearShadowStyle = !1, this._clearFilterStyle = !1, this._clearGlobalCompositeOperationStyle = !1;
29482
29525
  var context = canvas.nativeCanvas.getContext("2d");
29483
29526
  if (!context) throw new Error("发生错误,获取2d上下文失败");
29484
- 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);
29485
29528
  }
29486
29529
  _createClass(BrowserContext2d, [{
29487
29530
  key: "fillStyle",
@@ -30117,7 +30160,12 @@
30117
30160
  value: function clearMatrix() {
30118
30161
  var setTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
30119
30162
  var dpr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.dpr;
30120
- 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);
30121
30169
  }
30122
30170
  }, {
30123
30171
  key: "onlyTranslate",
@@ -30401,7 +30449,7 @@
30401
30449
  function BrowserWindowHandlerContribution_1() {
30402
30450
  var _this;
30403
30451
  _classCallCheck(this, BrowserWindowHandlerContribution_1);
30404
- _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);
30405
30453
  return _this;
30406
30454
  }
30407
30455
  _createClass(BrowserWindowHandlerContribution_1, [{
@@ -30582,8 +30630,9 @@
30582
30630
  }
30583
30631
  }, {
30584
30632
  key: "clearViewBox",
30585
- value: function clearViewBox(vb, color) {
30586
- var context = this.getContext(),
30633
+ value: function clearViewBox(color) {
30634
+ var vb = this.viewBox,
30635
+ context = this.getContext(),
30587
30636
  dpr = this.getDpr();
30588
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();
30589
30638
  }
@@ -31187,8 +31236,9 @@
31187
31236
  }
31188
31237
  }, {
31189
31238
  key: "clearViewBox",
31190
- value: function clearViewBox(vb, color) {
31191
- var context = this.getContext(),
31239
+ value: function clearViewBox(color) {
31240
+ var vb = this.viewBox,
31241
+ context = this.getContext(),
31192
31242
  dpr = this.getDpr();
31193
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();
31194
31244
  }
@@ -31835,8 +31885,9 @@
31835
31885
  }
31836
31886
  }, {
31837
31887
  key: "clearViewBox",
31838
- value: function clearViewBox(vb, color) {
31839
- var context = this.getContext(),
31888
+ value: function clearViewBox(color) {
31889
+ var vb = this.viewBox,
31890
+ context = this.getContext(),
31840
31891
  dpr = this.getDpr();
31841
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();
31842
31893
  }
@@ -32236,7 +32287,7 @@
32236
32287
  }
32237
32288
  }, {
32238
32289
  key: "clearViewBox",
32239
- value: function clearViewBox(vb, color) {}
32290
+ value: function clearViewBox(color) {}
32240
32291
  }]);
32241
32292
  return NodeWindowHandlerContribution;
32242
32293
  }(exports.BaseWindowHandlerContribution);
@@ -32766,8 +32817,9 @@
32766
32817
  }
32767
32818
  }, {
32768
32819
  key: "clearViewBox",
32769
- value: function clearViewBox(vb, color) {
32770
- var context = this.getContext(),
32820
+ value: function clearViewBox(color) {
32821
+ var vb = this.viewBox,
32822
+ context = this.getContext(),
32771
32823
  dpr = this.getDpr();
32772
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();
32773
32825
  }
@@ -33198,8 +33250,9 @@
33198
33250
  }
33199
33251
  }, {
33200
33252
  key: "clearViewBox",
33201
- value: function clearViewBox(vb, color) {
33202
- var context = this.getContext(),
33253
+ value: function clearViewBox(color) {
33254
+ var vb = this.viewBox,
33255
+ context = this.getContext(),
33203
33256
  dpr = this.getDpr();
33204
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();
33205
33258
  }
@@ -35040,7 +35093,7 @@
35040
35093
 
35041
35094
  var roughModule = _roughModule;
35042
35095
 
35043
- const version = "0.17.20-alpha.5";
35096
+ const version = "0.17.20-alpha.7";
35044
35097
  preLoadAllModule();
35045
35098
  if (isBrowserEnv()) {
35046
35099
  loadBrowserEnv(container);