@visactor/vrender 0.20.15 → 0.20.17

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
@@ -1702,7 +1702,9 @@
1702
1702
  } = this.textSpec;
1703
1703
  return {
1704
1704
  width: metrics.width,
1705
- height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
1705
+ height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize,
1706
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
1707
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
1706
1708
  };
1707
1709
  }
1708
1710
  quickMeasure(text) {
@@ -1716,7 +1718,7 @@
1716
1718
  for (let i = 0; i < text.length; i++) {
1717
1719
  const char = text[i];
1718
1720
  let size = this._measureSpecialChar(char);
1719
- isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height);
1721
+ isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height), !isNil$1(size.fontBoundingBoxAscent) && (totalSize.fontBoundingBoxAscent = size.fontBoundingBoxAscent), !isNil$1(size.fontBoundingBoxDescent) && (totalSize.fontBoundingBoxDescent = size.fontBoundingBoxDescent);
1720
1722
  }
1721
1723
  return totalSize;
1722
1724
  }
@@ -1765,7 +1767,9 @@
1765
1767
  const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
1766
1768
  this._numberCharSize = {
1767
1769
  width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
1768
- height: numberBounds.height
1770
+ height: numberBounds.height,
1771
+ fontBoundingBoxAscent: numberBounds.fontBoundingBoxAscent,
1772
+ fontBoundingBoxDescent: numberBounds.fontBoundingBoxDescent
1769
1773
  };
1770
1774
  }
1771
1775
  return this._numberCharSize;
@@ -1778,7 +1782,9 @@
1778
1782
  const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
1779
1783
  this._letterCharSize = {
1780
1784
  width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
1781
- height: alphabetBounds.height
1785
+ height: alphabetBounds.height,
1786
+ fontBoundingBoxAscent: alphabetBounds.fontBoundingBoxAscent,
1787
+ fontBoundingBoxDescent: alphabetBounds.fontBoundingBoxDescent
1782
1788
  };
1783
1789
  }
1784
1790
  return this._letterCharSize;
@@ -4149,6 +4155,292 @@
4149
4155
  class Application {}
4150
4156
  const application = new Application();
4151
4157
 
4158
+ const parse = function () {
4159
+ const tokens = {
4160
+ linearGradient: /^(linear\-gradient)/i,
4161
+ radialGradient: /^(radial\-gradient)/i,
4162
+ conicGradient: /^(conic\-gradient)/i,
4163
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
4164
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
4165
+ positionKeywords: /^(left|center|right|top|bottom)/i,
4166
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
4167
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
4168
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
4169
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4170
+ fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4171
+ startCall: /^\(/,
4172
+ endCall: /^\)/,
4173
+ comma: /^,/,
4174
+ hexColor: /(^\#[0-9a-fA-F]+)/,
4175
+ literalColor: /^([a-zA-Z]+)/,
4176
+ rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
4177
+ rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
4178
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
4179
+ };
4180
+ let input = "";
4181
+ function error(msg) {
4182
+ const err = new Error(input + ": " + msg);
4183
+ throw err.source = input, err;
4184
+ }
4185
+ function getAST() {
4186
+ const ast = matchListing(matchDefinition);
4187
+ return input.length > 0 && error("Invalid input not EOF"), ast;
4188
+ }
4189
+ function matchDefinition() {
4190
+ return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
4191
+ }
4192
+ function matchGradient(gradientType, pattern, orientationMatcher) {
4193
+ return function (pattern, callback) {
4194
+ const captures = scan(pattern);
4195
+ if (captures) {
4196
+ scan(tokens.startCall) || error("Missing (");
4197
+ const result = callback(captures);
4198
+ return scan(tokens.endCall) || error("Missing )"), result;
4199
+ }
4200
+ }(pattern, function (captures) {
4201
+ const orientation = orientationMatcher();
4202
+ return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
4203
+ type: gradientType,
4204
+ orientation: orientation,
4205
+ colorStops: matchListing(matchColorStop)
4206
+ };
4207
+ });
4208
+ }
4209
+ function matchLinearOrientation() {
4210
+ return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
4211
+ }
4212
+ function matchConicalOrientation() {
4213
+ return match("angular", tokens.fromAngleValue, 1);
4214
+ }
4215
+ function matchListRadialOrientations() {
4216
+ let radialOrientations,
4217
+ lookaheadCache,
4218
+ radialOrientation = matchRadialOrientation();
4219
+ return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
4220
+ }
4221
+ function matchRadialOrientation() {
4222
+ let radialType = function () {
4223
+ const circle = match("shape", /^(circle)/i, 0);
4224
+ circle && (circle.style = matchLength() || matchExtentKeyword());
4225
+ return circle;
4226
+ }() || function () {
4227
+ const ellipse = match("shape", /^(ellipse)/i, 0);
4228
+ ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
4229
+ return ellipse;
4230
+ }();
4231
+ if (radialType) radialType.at = matchAtPosition();else {
4232
+ const extent = matchExtentKeyword();
4233
+ if (extent) {
4234
+ radialType = extent;
4235
+ const positionAt = matchAtPosition();
4236
+ positionAt && (radialType.at = positionAt);
4237
+ } else {
4238
+ const defaultPosition = matchPositioning();
4239
+ defaultPosition && (radialType = {
4240
+ type: "default-radial",
4241
+ at: defaultPosition
4242
+ });
4243
+ }
4244
+ }
4245
+ return radialType;
4246
+ }
4247
+ function matchExtentKeyword() {
4248
+ return match("extent-keyword", tokens.extentKeywords, 1);
4249
+ }
4250
+ function matchAtPosition() {
4251
+ if (match("position", /^at/, 0)) {
4252
+ const positioning = matchPositioning();
4253
+ return positioning || error("Missing positioning value"), positioning;
4254
+ }
4255
+ }
4256
+ function matchPositioning() {
4257
+ const location = {
4258
+ x: matchDistance(),
4259
+ y: matchDistance()
4260
+ };
4261
+ if (location.x || location.y) return {
4262
+ type: "position",
4263
+ value: location
4264
+ };
4265
+ }
4266
+ function matchListing(matcher) {
4267
+ let captures = matcher();
4268
+ const result = [];
4269
+ if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
4270
+ return result;
4271
+ }
4272
+ function matchColorStop() {
4273
+ const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
4274
+ return color || error("Expected color definition"), color.length = matchDistance(), color;
4275
+ }
4276
+ function matchDistance() {
4277
+ return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
4278
+ }
4279
+ function matchLength() {
4280
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
4281
+ }
4282
+ function match(type, pattern, captureIndex) {
4283
+ const captures = scan(pattern);
4284
+ if (captures) return {
4285
+ type: type,
4286
+ value: captures[captureIndex]
4287
+ };
4288
+ }
4289
+ function scan(regexp) {
4290
+ const blankCaptures = /^[\n\r\t\s]+/.exec(input);
4291
+ blankCaptures && consume(blankCaptures[0].length);
4292
+ const captures = regexp.exec(input);
4293
+ return captures && consume(captures[0].length), captures;
4294
+ }
4295
+ function consume(size) {
4296
+ input = input.substr(size);
4297
+ }
4298
+ return function (code) {
4299
+ return input = code.toString(), getAST();
4300
+ };
4301
+ }();
4302
+ class GradientParser {
4303
+ static IsGradient(c) {
4304
+ return !("string" == typeof c && !c.includes("gradient"));
4305
+ }
4306
+ static IsGradientStr(c) {
4307
+ return "string" == typeof c && c.includes("gradient");
4308
+ }
4309
+ static Parse(c) {
4310
+ if (GradientParser.IsGradientStr(c)) try {
4311
+ const datum = parse(c)[0];
4312
+ if (datum) {
4313
+ if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
4314
+ if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
4315
+ if ("conic" === datum.type) return GradientParser.ParseConic(datum);
4316
+ }
4317
+ } catch (err) {
4318
+ return c;
4319
+ }
4320
+ return c;
4321
+ }
4322
+ static ParseConic(datum) {
4323
+ const {
4324
+ orientation: orientation,
4325
+ colorStops = []
4326
+ } = datum,
4327
+ halfPi = pi / 2,
4328
+ sa = parseFloat(orientation.value) / 180 * pi - halfPi;
4329
+ return {
4330
+ gradient: "conical",
4331
+ x: .5,
4332
+ y: .5,
4333
+ startAngle: sa,
4334
+ endAngle: sa + pi2,
4335
+ stops: colorStops.map(item => ({
4336
+ color: item.value,
4337
+ offset: parseFloat(item.length.value) / 100
4338
+ }))
4339
+ };
4340
+ }
4341
+ static ParseRadial(datum) {
4342
+ const {
4343
+ colorStops = []
4344
+ } = datum;
4345
+ return {
4346
+ gradient: "radial",
4347
+ x0: .5,
4348
+ y0: .5,
4349
+ x1: .5,
4350
+ y1: .5,
4351
+ r0: 0,
4352
+ r1: 1,
4353
+ stops: colorStops.map(item => ({
4354
+ color: item.value,
4355
+ offset: parseFloat(item.length.value) / 100
4356
+ }))
4357
+ };
4358
+ }
4359
+ static ParseLinear(datum) {
4360
+ const {
4361
+ orientation: orientation,
4362
+ colorStops = []
4363
+ } = datum,
4364
+ halfPi = pi / 2;
4365
+ let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
4366
+ for (; angle < 0;) angle += pi2;
4367
+ for (; angle >= pi2;) angle -= pi2;
4368
+ let x0 = 0,
4369
+ y0 = 0,
4370
+ x1 = 0,
4371
+ y1 = 0;
4372
+ return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = y0 - Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
4373
+ gradient: "linear",
4374
+ x0: x0,
4375
+ y0: y0,
4376
+ x1: x1,
4377
+ y1: y1,
4378
+ stops: colorStops.map(item => ({
4379
+ color: item.value,
4380
+ offset: parseFloat(item.length.value) / 100
4381
+ }))
4382
+ };
4383
+ }
4384
+ }
4385
+
4386
+ function getScaledStroke(context, width, dpr) {
4387
+ let strokeWidth = width;
4388
+ const {
4389
+ a: a,
4390
+ b: b,
4391
+ c: c,
4392
+ d: d
4393
+ } = context.currentMatrix,
4394
+ scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
4395
+ scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
4396
+ return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
4397
+ }
4398
+ function createColor(context, c, params) {
4399
+ let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4400
+ let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4401
+ if (!c || !0 === c) return "black";
4402
+ let result, color;
4403
+ if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
4404
+ if (color = GradientParser.Parse(color), "string" == typeof color) return color;
4405
+ if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
4406
+ const bounds = params.AABBBounds;
4407
+ let w = bounds.x2 - bounds.x1,
4408
+ h = bounds.y2 - bounds.y1,
4409
+ x = bounds.x1 - offsetX,
4410
+ y = bounds.y1 - offsetY;
4411
+ if (params.attribute) {
4412
+ const {
4413
+ scaleX = 1,
4414
+ scaleY = 1
4415
+ } = params.attribute;
4416
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
4417
+ }
4418
+ "linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
4419
+ }
4420
+ return result || "orange";
4421
+ }
4422
+ function createLinearGradient(context, color, x, y, w, h) {
4423
+ var _a, _b, _c, _d;
4424
+ const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
4425
+ return color.stops.forEach(stop => {
4426
+ canvasGradient.addColorStop(stop.offset, stop.color);
4427
+ }), canvasGradient;
4428
+ }
4429
+ function createRadialGradient(context, color, x, y, w, h) {
4430
+ var _a, _b, _c, _d, _e, _f;
4431
+ const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
4432
+ return color.stops.forEach(stop => {
4433
+ canvasGradient.addColorStop(stop.offset, stop.color);
4434
+ }), canvasGradient;
4435
+ }
4436
+ function createConicGradient(context, color, x, y, w, h) {
4437
+ var _a, _b;
4438
+ const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
4439
+ return color.stops.forEach(stop => {
4440
+ canvasGradient.addColorStop(stop.offset, stop.color);
4441
+ }), canvasGradient.GetPattern(w + x, h + y, undefined);
4442
+ }
4443
+
4152
4444
  const DIRECTION_KEY = {
4153
4445
  horizontal: {
4154
4446
  width: "width",
@@ -4200,14 +4492,16 @@
4200
4492
  fontFamily: character.fontFamily || "sans-serif"
4201
4493
  });
4202
4494
  };
4203
- function applyFillStyle(ctx, character) {
4495
+ function applyFillStyle(ctx, character, b) {
4204
4496
  const fillStyle = character && character.fill || defaultFormatting.fill;
4205
4497
  if (!fillStyle) return void (ctx.globalAlpha = 0);
4206
4498
  const {
4207
4499
  fillOpacity = 1,
4208
4500
  opacity = 1
4209
4501
  } = character;
4210
- ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
4502
+ ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
4503
+ AABBBounds: b
4504
+ }) : fillStyle, setTextStyle(ctx, character);
4211
4505
  }
4212
4506
  function applyStrokeStyle(ctx, character) {
4213
4507
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
@@ -11119,697 +11413,411 @@
11119
11413
  allocate(a, b, c, d, e, f) {
11120
11414
  if (!this.pools.length) return new Matrix(a, b, c, d, e, f);
11121
11415
  const m = this.pools.pop();
11122
- return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
11123
- }
11124
- allocateByObj(matrix) {
11125
- if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
11126
- const m = this.pools.pop();
11127
- return m.a = matrix.a, m.b = matrix.b, m.c = matrix.c, m.d = matrix.d, m.e = matrix.e, m.f = matrix.f, m;
11128
- }
11129
- free(d) {
11130
- this.pools.push(d);
11131
- }
11132
- get length() {
11133
- return this.pools.length;
11134
- }
11135
- release() {
11136
- this.pools = [];
11137
- }
11138
- }
11139
- class DefaultMat4Allocate {
11140
- constructor() {
11141
- this.pools = [];
11142
- }
11143
- static identity(out) {
11144
- return identityMat4(out);
11145
- }
11146
- allocate() {
11147
- if (!this.pools.length) return createMat4();
11148
- const m = this.pools.pop();
11149
- return DefaultMat4Allocate.identity(m), m;
11150
- }
11151
- allocateByObj(d) {
11152
- let m;
11153
- m = this.pools.length ? this.pools.pop() : createMat4();
11154
- for (let i = 0; i < m.length; i++) m[i] = d[i];
11155
- return m;
11156
- }
11157
- free(m) {
11158
- m && this.pools.push(m);
11159
- }
11160
- get length() {
11161
- return this.pools.length;
11162
- }
11163
- release() {
11164
- this.pools = [];
11165
- }
11166
- }
11167
- const matrixAllocate = new DefaultMatrixAllocate();
11168
- const mat4Allocate = new DefaultMat4Allocate();
11169
-
11170
- var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
11171
- var d,
11172
- c = arguments.length,
11173
- r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
11174
- if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
11175
- return c > 3 && r && Object.defineProperty(target, key, r), r;
11176
- },
11177
- __metadata$1d = undefined && undefined.__metadata || function (k, v) {
11178
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11179
- },
11180
- __param$R = undefined && undefined.__param || function (paramIndex, decorator) {
11181
- return function (target, key) {
11182
- decorator(target, key, paramIndex);
11183
- };
11184
- };
11185
- function getExtraModelMatrix(dx, dy, graphic) {
11186
- const {
11187
- alpha: alpha,
11188
- beta: beta
11189
- } = graphic.attribute;
11190
- if (!alpha && !beta) return null;
11191
- const {
11192
- anchor3d = graphic.attribute.anchor
11193
- } = graphic.attribute,
11194
- _anchor = [0, 0];
11195
- if (anchor3d) {
11196
- if ("string" == typeof anchor3d[0]) {
11197
- const ratio = parseFloat(anchor3d[0]) / 100,
11198
- bounds = graphic.AABBBounds;
11199
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11200
- } else _anchor[0] = anchor3d[0];
11201
- if ("string" == typeof anchor3d[1]) {
11202
- const ratio = parseFloat(anchor3d[1]) / 100,
11203
- bounds = graphic.AABBBounds;
11204
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11205
- } else _anchor[1] = anchor3d[1];
11206
- }
11207
- if ("text" === graphic.type) {
11208
- const {
11209
- textAlign: textAlign
11210
- } = graphic.attribute;
11211
- _anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
11212
- }
11213
- _anchor[0] += dx, _anchor[1] += dy;
11214
- const modelMatrix = mat4Allocate.allocate();
11215
- return translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]), beta && rotateX(modelMatrix, modelMatrix, beta), alpha && rotateY(modelMatrix, modelMatrix, alpha), translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]), modelMatrix;
11216
- }
11217
- function getModelMatrix(out, graphic, theme) {
11218
- var _a;
11219
- const {
11220
- x = theme.x,
11221
- y = theme.y,
11222
- z = theme.z,
11223
- dx = theme.dx,
11224
- dy = theme.dy,
11225
- dz = theme.dz,
11226
- scaleX = theme.scaleX,
11227
- scaleY = theme.scaleY,
11228
- scaleZ = theme.scaleZ,
11229
- alpha = theme.alpha,
11230
- beta = theme.beta,
11231
- angle = theme.angle,
11232
- anchor3d = graphic.attribute.anchor,
11233
- anchor: anchor
11234
- } = graphic.attribute,
11235
- _anchor = [0, 0, 0];
11236
- if (anchor3d) {
11237
- if ("string" == typeof anchor3d[0]) {
11238
- const ratio = parseFloat(anchor3d[0]) / 100,
11239
- bounds = graphic.AABBBounds;
11240
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11241
- } else _anchor[0] = anchor3d[0];
11242
- if ("string" == typeof anchor3d[1]) {
11243
- const ratio = parseFloat(anchor3d[1]) / 100,
11244
- bounds = graphic.AABBBounds;
11245
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11246
- } else _anchor[1] = anchor3d[1];
11247
- _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
11248
- }
11249
- if (identityMat4(out), translate(out, out, [x + dx, y + dy, z + dz]), translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]), rotateX(out, out, beta), rotateY(out, out, alpha), translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]), scaleMat4(out, out, [scaleX, scaleY, scaleZ]), angle) {
11250
- const m = mat4Allocate.allocate(),
11251
- _anchor = [0, 0];
11252
- if (anchor) {
11253
- if ("string" == typeof anchor3d[0]) {
11254
- const ratio = parseFloat(anchor3d[0]) / 100,
11255
- bounds = graphic.AABBBounds;
11256
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11257
- } else _anchor[0] = anchor3d[0];
11258
- if ("string" == typeof anchor3d[1]) {
11259
- const ratio = parseFloat(anchor3d[1]) / 100,
11260
- bounds = graphic.AABBBounds;
11261
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11262
- } else _anchor[1] = anchor3d[1];
11263
- }
11264
- translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
11265
- }
11266
- }
11267
- function shouldUseMat4(graphic) {
11268
- const {
11269
- alpha: alpha,
11270
- beta: beta
11271
- } = graphic.attribute;
11272
- return alpha || beta;
11273
- }
11274
- exports.DefaultGraphicService = class DefaultGraphicService {
11275
- constructor(creator) {
11276
- this.creator = creator, this.hooks = {
11277
- onAttributeUpdate: new SyncHook(["graphic"]),
11278
- onSetStage: new SyncHook(["graphic", "stage"]),
11279
- onRemove: new SyncHook(["graphic"]),
11280
- onRelease: new SyncHook(["graphic"]),
11281
- onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
11282
- onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
11283
- beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
11284
- afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
11285
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
11286
- }
11287
- onAttributeUpdate(graphic) {
11288
- this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
11289
- }
11290
- onSetStage(graphic, stage) {
11291
- this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
11292
- }
11293
- onRemove(graphic) {
11294
- this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
11295
- }
11296
- onRelease(graphic) {
11297
- this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
11298
- }
11299
- onAddIncremental(graphic, group, stage) {
11300
- this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
11301
- }
11302
- onClearIncremental(group, stage) {
11303
- this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
11304
- }
11305
- beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
11306
- this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
11307
- }
11308
- afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
11309
- this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
11310
- }
11311
- updatePathProxyAABBBounds(aabbBounds, graphic) {
11312
- const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
11313
- if (!path) return !1;
11314
- const boundsContext = new BoundsContext(aabbBounds);
11315
- return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
11316
- }
11317
- updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
11318
- const {
11319
- textAlign: textAlign,
11320
- textBaseline: textBaseline
11321
- } = attribute;
11322
- if (null != attribute.forceBoundsHeight) {
11323
- const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
11324
- dy = textLayoutOffsetY(textBaseline, h, h);
11325
- aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
11326
- }
11327
- if (null != attribute.forceBoundsWidth) {
11328
- const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
11329
- dx = textDrawOffsetX(textAlign, w);
11330
- aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
11331
- }
11332
- }
11333
- combindShadowAABBBounds(bounds, graphic) {
11334
- if (graphic && graphic.shadowRoot) {
11335
- const b = graphic.shadowRoot.AABBBounds;
11336
- bounds.union(b);
11337
- }
11338
- }
11339
- transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
11340
- if (!aabbBounds.empty()) {
11341
- const {
11342
- scaleX = theme.scaleX,
11343
- scaleY = theme.scaleY,
11344
- stroke = theme.stroke,
11345
- shadowBlur = theme.shadowBlur,
11346
- lineWidth = theme.lineWidth,
11347
- pickStrokeBuffer = theme.pickStrokeBuffer,
11348
- strokeBoundsBuffer = theme.strokeBoundsBuffer
11349
- } = attribute,
11350
- tb1 = this.tempAABBBounds1,
11351
- tb2 = this.tempAABBBounds2;
11352
- if (stroke && lineWidth) {
11353
- const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
11354
- boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
11355
- }
11356
- if (shadowBlur) {
11357
- const {
11358
- shadowOffsetX = theme.shadowOffsetX,
11359
- shadowOffsetY = theme.shadowOffsetY
11360
- } = attribute,
11361
- shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
11362
- boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
11363
- }
11364
- }
11365
- if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
11366
- let updateMatrix = !0;
11367
- const m = graphic.transMatrix;
11368
- graphic && graphic.isContainer && (updateMatrix = !(1 === m.a && 0 === m.b && 0 === m.c && 1 === m.d && 0 === m.e && 0 === m.f)), updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);
11416
+ return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
11369
11417
  }
11370
- validCheck(attribute, theme, aabbBounds, graphic) {
11371
- if (!graphic) return !0;
11372
- if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
11373
- if (graphic.shadowRoot) return !0;
11374
- if (!graphic.valid) return aabbBounds.clear(), !1;
11375
- const {
11376
- visible = theme.visible
11377
- } = attribute;
11378
- return !!visible || (aabbBounds.clear(), !1);
11418
+ allocateByObj(matrix) {
11419
+ if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
11420
+ const m = this.pools.pop();
11421
+ return m.a = matrix.a, m.b = matrix.b, m.c = matrix.c, m.d = matrix.d, m.e = matrix.e, m.f = matrix.f, m;
11379
11422
  }
11380
- updateTempAABBBounds(aabbBounds) {
11381
- const tb1 = this.tempAABBBounds1,
11382
- tb2 = this.tempAABBBounds2;
11383
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
11384
- tb1: tb1,
11385
- tb2: tb2
11386
- };
11423
+ free(d) {
11424
+ this.pools.push(d);
11387
11425
  }
11388
- };
11389
- exports.DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], exports.DefaultGraphicService);
11390
-
11391
- const result = {
11392
- x: 0,
11393
- y: 0,
11394
- z: 0,
11395
- lastModelMatrix: null
11396
- };
11397
- class BaseRender {
11398
- init(contributions) {
11399
- contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
11426
+ get length() {
11427
+ return this.pools.length;
11400
11428
  }
11401
- beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11402
- this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
11403
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11404
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11405
- }
11406
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11407
- });
11429
+ release() {
11430
+ this.pools = [];
11408
11431
  }
11409
- afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11410
- this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
11411
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11412
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11413
- }
11414
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11415
- });
11432
+ }
11433
+ class DefaultMat4Allocate {
11434
+ constructor() {
11435
+ this.pools = [];
11416
11436
  }
11417
- valid(graphic, defaultAttribute, fillCb, strokeCb) {
11418
- const {
11419
- fill = defaultAttribute.fill,
11420
- background: background,
11421
- stroke = defaultAttribute.stroke,
11422
- opacity = defaultAttribute.opacity,
11423
- fillOpacity = defaultAttribute.fillOpacity,
11424
- lineWidth = defaultAttribute.lineWidth,
11425
- strokeOpacity = defaultAttribute.strokeOpacity,
11426
- visible = defaultAttribute.visible
11427
- } = graphic.attribute,
11428
- fVisible = fillVisible(opacity, fillOpacity, fill),
11429
- sVisible = strokeVisible(opacity, strokeOpacity),
11430
- doFill = runFill(fill, background),
11431
- doStroke = runStroke(stroke, lineWidth);
11432
- return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
11433
- fVisible: fVisible,
11434
- sVisible: sVisible,
11435
- doFill: doFill,
11436
- doStroke: doStroke
11437
- };
11437
+ static identity(out) {
11438
+ return identityMat4(out);
11438
11439
  }
11439
- transform(graphic, graphicAttribute, context) {
11440
- let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
11441
- const {
11442
- x = graphicAttribute.x,
11443
- y = graphicAttribute.y,
11444
- z = graphicAttribute.z,
11445
- scaleX = graphicAttribute.scaleX,
11446
- scaleY = graphicAttribute.scaleY,
11447
- angle = graphicAttribute.angle,
11448
- postMatrix: postMatrix
11449
- } = graphic.attribute,
11450
- lastModelMatrix = context.modelMatrix,
11451
- camera = context.camera;
11452
- result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
11453
- const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
11454
- onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
11455
- if (shouldTransform3d) {
11456
- const nextModelMatrix = mat4Allocate.allocate(),
11457
- modelMatrix = mat4Allocate.allocate();
11458
- getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
11459
- }
11460
- if (onlyTranslate && !lastModelMatrix) {
11461
- const point = graphic.getOffsetXY(graphicAttribute);
11462
- result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
11463
- } else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
11464
- const point = graphic.getOffsetXY(graphicAttribute);
11465
- result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
11466
- } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
11467
- return result;
11440
+ allocate() {
11441
+ if (!this.pools.length) return createMat4();
11442
+ const m = this.pools.pop();
11443
+ return DefaultMat4Allocate.identity(m), m;
11468
11444
  }
11469
- transformUseContext2d(graphic, graphicAttribute, z, context) {
11470
- const camera = context.camera;
11471
- if (this.camera = camera, camera) {
11472
- const bounds = graphic.AABBBounds,
11473
- width = bounds.x2 - bounds.x1,
11474
- height = bounds.y2 - bounds.y1,
11475
- p1 = context.project(0, 0, z),
11476
- p2 = context.project(width, 0, z),
11477
- p3 = context.project(width, height, z),
11478
- _p1 = {
11479
- x: 0,
11480
- y: 0
11481
- },
11482
- _p2 = {
11483
- x: width,
11484
- y: 0
11485
- },
11486
- _p3 = {
11487
- x: width,
11488
- y: height
11489
- };
11490
- context.camera = null;
11491
- const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
11492
- m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
11493
- m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
11494
- m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
11495
- m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
11496
- dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
11497
- dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
11498
- context.setTransform(m11, m12, m21, m22, dx, dy, !0);
11499
- }
11445
+ allocateByObj(d) {
11446
+ let m;
11447
+ m = this.pools.length ? this.pools.pop() : createMat4();
11448
+ for (let i = 0; i < m.length; i++) m[i] = d[i];
11449
+ return m;
11500
11450
  }
11501
- restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11502
- this.camera && (context.camera = this.camera);
11451
+ free(m) {
11452
+ m && this.pools.push(m);
11503
11453
  }
11504
- transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
11505
- const p = context.project(x, y, z);
11506
- context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
11454
+ get length() {
11455
+ return this.pools.length;
11507
11456
  }
11508
- _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11509
- const {
11510
- context: context
11511
- } = drawContext;
11512
- if (!context) return;
11457
+ release() {
11458
+ this.pools = [];
11459
+ }
11460
+ }
11461
+ const matrixAllocate = new DefaultMatrixAllocate();
11462
+ const mat4Allocate = new DefaultMat4Allocate();
11463
+
11464
+ var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
11465
+ var d,
11466
+ c = arguments.length,
11467
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
11468
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
11469
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11470
+ },
11471
+ __metadata$1d = undefined && undefined.__metadata || function (k, v) {
11472
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11473
+ },
11474
+ __param$R = undefined && undefined.__param || function (paramIndex, decorator) {
11475
+ return function (target, key) {
11476
+ decorator(target, key, paramIndex);
11477
+ };
11478
+ };
11479
+ function getExtraModelMatrix(dx, dy, graphic) {
11480
+ const {
11481
+ alpha: alpha,
11482
+ beta: beta
11483
+ } = graphic.attribute;
11484
+ if (!alpha && !beta) return null;
11485
+ const {
11486
+ anchor3d = graphic.attribute.anchor
11487
+ } = graphic.attribute,
11488
+ _anchor = [0, 0];
11489
+ if (anchor3d) {
11490
+ if ("string" == typeof anchor3d[0]) {
11491
+ const ratio = parseFloat(anchor3d[0]) / 100,
11492
+ bounds = graphic.AABBBounds;
11493
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11494
+ } else _anchor[0] = anchor3d[0];
11495
+ if ("string" == typeof anchor3d[1]) {
11496
+ const ratio = parseFloat(anchor3d[1]) / 100,
11497
+ bounds = graphic.AABBBounds;
11498
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11499
+ } else _anchor[1] = anchor3d[1];
11500
+ }
11501
+ if ("text" === graphic.type) {
11513
11502
  const {
11514
- renderable: renderable
11503
+ textAlign: textAlign
11515
11504
  } = graphic.attribute;
11516
- if (!1 === renderable) return;
11517
- context.highPerformanceSave();
11518
- const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
11519
- {
11520
- x: x,
11521
- y: y,
11522
- z: z,
11523
- lastModelMatrix: lastModelMatrix
11524
- } = data;
11525
- this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params), this.z = 0, context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix), context.modelMatrix = lastModelMatrix), context.highPerformanceRestore();
11505
+ _anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
11506
+ }
11507
+ _anchor[0] += dx, _anchor[1] += dy;
11508
+ const modelMatrix = mat4Allocate.allocate();
11509
+ return translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]), beta && rotateX(modelMatrix, modelMatrix, beta), alpha && rotateY(modelMatrix, modelMatrix, alpha), translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]), modelMatrix;
11510
+ }
11511
+ function getModelMatrix(out, graphic, theme) {
11512
+ var _a;
11513
+ const {
11514
+ x = theme.x,
11515
+ y = theme.y,
11516
+ z = theme.z,
11517
+ dx = theme.dx,
11518
+ dy = theme.dy,
11519
+ dz = theme.dz,
11520
+ scaleX = theme.scaleX,
11521
+ scaleY = theme.scaleY,
11522
+ scaleZ = theme.scaleZ,
11523
+ alpha = theme.alpha,
11524
+ beta = theme.beta,
11525
+ angle = theme.angle,
11526
+ anchor3d = graphic.attribute.anchor,
11527
+ anchor: anchor
11528
+ } = graphic.attribute,
11529
+ _anchor = [0, 0, 0];
11530
+ if (anchor3d) {
11531
+ if ("string" == typeof anchor3d[0]) {
11532
+ const ratio = parseFloat(anchor3d[0]) / 100,
11533
+ bounds = graphic.AABBBounds;
11534
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11535
+ } else _anchor[0] = anchor3d[0];
11536
+ if ("string" == typeof anchor3d[1]) {
11537
+ const ratio = parseFloat(anchor3d[1]) / 100,
11538
+ bounds = graphic.AABBBounds;
11539
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11540
+ } else _anchor[1] = anchor3d[1];
11541
+ _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
11526
11542
  }
11527
- }
11528
-
11529
- const parse = function () {
11530
- const tokens = {
11531
- linearGradient: /^(linear\-gradient)/i,
11532
- radialGradient: /^(radial\-gradient)/i,
11533
- conicGradient: /^(conic\-gradient)/i,
11534
- sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
11535
- extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
11536
- positionKeywords: /^(left|center|right|top|bottom)/i,
11537
- pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
11538
- percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
11539
- emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
11540
- angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
11541
- fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
11542
- startCall: /^\(/,
11543
- endCall: /^\)/,
11544
- comma: /^,/,
11545
- hexColor: /(^\#[0-9a-fA-F]+)/,
11546
- literalColor: /^([a-zA-Z]+)/,
11547
- rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
11548
- rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
11549
- number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
11550
- };
11551
- let input = "";
11552
- function error(msg) {
11553
- const err = new Error(input + ": " + msg);
11554
- throw err.source = input, err;
11543
+ if (identityMat4(out), translate(out, out, [x + dx, y + dy, z + dz]), translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]), rotateX(out, out, beta), rotateY(out, out, alpha), translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]), scaleMat4(out, out, [scaleX, scaleY, scaleZ]), angle) {
11544
+ const m = mat4Allocate.allocate(),
11545
+ _anchor = [0, 0];
11546
+ if (anchor) {
11547
+ if ("string" == typeof anchor3d[0]) {
11548
+ const ratio = parseFloat(anchor3d[0]) / 100,
11549
+ bounds = graphic.AABBBounds;
11550
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11551
+ } else _anchor[0] = anchor3d[0];
11552
+ if ("string" == typeof anchor3d[1]) {
11553
+ const ratio = parseFloat(anchor3d[1]) / 100,
11554
+ bounds = graphic.AABBBounds;
11555
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11556
+ } else _anchor[1] = anchor3d[1];
11557
+ }
11558
+ translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
11555
11559
  }
11556
- function getAST() {
11557
- const ast = matchListing(matchDefinition);
11558
- return input.length > 0 && error("Invalid input not EOF"), ast;
11560
+ }
11561
+ function shouldUseMat4(graphic) {
11562
+ const {
11563
+ alpha: alpha,
11564
+ beta: beta
11565
+ } = graphic.attribute;
11566
+ return alpha || beta;
11567
+ }
11568
+ exports.DefaultGraphicService = class DefaultGraphicService {
11569
+ constructor(creator) {
11570
+ this.creator = creator, this.hooks = {
11571
+ onAttributeUpdate: new SyncHook(["graphic"]),
11572
+ onSetStage: new SyncHook(["graphic", "stage"]),
11573
+ onRemove: new SyncHook(["graphic"]),
11574
+ onRelease: new SyncHook(["graphic"]),
11575
+ onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
11576
+ onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
11577
+ beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
11578
+ afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
11579
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
11559
11580
  }
11560
- function matchDefinition() {
11561
- return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
11581
+ onAttributeUpdate(graphic) {
11582
+ this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
11562
11583
  }
11563
- function matchGradient(gradientType, pattern, orientationMatcher) {
11564
- return function (pattern, callback) {
11565
- const captures = scan(pattern);
11566
- if (captures) {
11567
- scan(tokens.startCall) || error("Missing (");
11568
- const result = callback(captures);
11569
- return scan(tokens.endCall) || error("Missing )"), result;
11570
- }
11571
- }(pattern, function (captures) {
11572
- const orientation = orientationMatcher();
11573
- return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
11574
- type: gradientType,
11575
- orientation: orientation,
11576
- colorStops: matchListing(matchColorStop)
11577
- };
11578
- });
11584
+ onSetStage(graphic, stage) {
11585
+ this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
11579
11586
  }
11580
- function matchLinearOrientation() {
11581
- return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
11587
+ onRemove(graphic) {
11588
+ this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
11582
11589
  }
11583
- function matchConicalOrientation() {
11584
- return match("angular", tokens.fromAngleValue, 1);
11590
+ onRelease(graphic) {
11591
+ this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
11585
11592
  }
11586
- function matchListRadialOrientations() {
11587
- let radialOrientations,
11588
- lookaheadCache,
11589
- radialOrientation = matchRadialOrientation();
11590
- return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
11593
+ onAddIncremental(graphic, group, stage) {
11594
+ this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
11591
11595
  }
11592
- function matchRadialOrientation() {
11593
- let radialType = function () {
11594
- const circle = match("shape", /^(circle)/i, 0);
11595
- circle && (circle.style = matchLength() || matchExtentKeyword());
11596
- return circle;
11597
- }() || function () {
11598
- const ellipse = match("shape", /^(ellipse)/i, 0);
11599
- ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
11600
- return ellipse;
11601
- }();
11602
- if (radialType) radialType.at = matchAtPosition();else {
11603
- const extent = matchExtentKeyword();
11604
- if (extent) {
11605
- radialType = extent;
11606
- const positionAt = matchAtPosition();
11607
- positionAt && (radialType.at = positionAt);
11608
- } else {
11609
- const defaultPosition = matchPositioning();
11610
- defaultPosition && (radialType = {
11611
- type: "default-radial",
11612
- at: defaultPosition
11613
- });
11614
- }
11615
- }
11616
- return radialType;
11596
+ onClearIncremental(group, stage) {
11597
+ this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
11617
11598
  }
11618
- function matchExtentKeyword() {
11619
- return match("extent-keyword", tokens.extentKeywords, 1);
11599
+ beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
11600
+ this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
11620
11601
  }
11621
- function matchAtPosition() {
11622
- if (match("position", /^at/, 0)) {
11623
- const positioning = matchPositioning();
11624
- return positioning || error("Missing positioning value"), positioning;
11625
- }
11602
+ afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
11603
+ this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
11626
11604
  }
11627
- function matchPositioning() {
11628
- const location = {
11629
- x: matchDistance(),
11630
- y: matchDistance()
11631
- };
11632
- if (location.x || location.y) return {
11633
- type: "position",
11634
- value: location
11635
- };
11605
+ updatePathProxyAABBBounds(aabbBounds, graphic) {
11606
+ const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
11607
+ if (!path) return !1;
11608
+ const boundsContext = new BoundsContext(aabbBounds);
11609
+ return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
11636
11610
  }
11637
- function matchListing(matcher) {
11638
- let captures = matcher();
11639
- const result = [];
11640
- if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
11641
- return result;
11611
+ updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
11612
+ const {
11613
+ textAlign: textAlign,
11614
+ textBaseline: textBaseline
11615
+ } = attribute;
11616
+ if (null != attribute.forceBoundsHeight) {
11617
+ const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
11618
+ dy = textLayoutOffsetY(textBaseline, h, h);
11619
+ aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
11620
+ }
11621
+ if (null != attribute.forceBoundsWidth) {
11622
+ const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
11623
+ dx = textDrawOffsetX(textAlign, w);
11624
+ aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
11625
+ }
11642
11626
  }
11643
- function matchColorStop() {
11644
- const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
11645
- return color || error("Expected color definition"), color.length = matchDistance(), color;
11627
+ combindShadowAABBBounds(bounds, graphic) {
11628
+ if (graphic && graphic.shadowRoot) {
11629
+ const b = graphic.shadowRoot.AABBBounds;
11630
+ bounds.union(b);
11631
+ }
11646
11632
  }
11647
- function matchDistance() {
11648
- return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
11633
+ transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
11634
+ if (!aabbBounds.empty()) {
11635
+ const {
11636
+ scaleX = theme.scaleX,
11637
+ scaleY = theme.scaleY,
11638
+ stroke = theme.stroke,
11639
+ shadowBlur = theme.shadowBlur,
11640
+ lineWidth = theme.lineWidth,
11641
+ pickStrokeBuffer = theme.pickStrokeBuffer,
11642
+ strokeBoundsBuffer = theme.strokeBoundsBuffer
11643
+ } = attribute,
11644
+ tb1 = this.tempAABBBounds1,
11645
+ tb2 = this.tempAABBBounds2;
11646
+ if (stroke && lineWidth) {
11647
+ const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
11648
+ boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
11649
+ }
11650
+ if (shadowBlur) {
11651
+ const {
11652
+ shadowOffsetX = theme.shadowOffsetX,
11653
+ shadowOffsetY = theme.shadowOffsetY
11654
+ } = attribute,
11655
+ shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
11656
+ boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
11657
+ }
11658
+ }
11659
+ if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
11660
+ let updateMatrix = !0;
11661
+ const m = graphic.transMatrix;
11662
+ graphic && graphic.isContainer && (updateMatrix = !(1 === m.a && 0 === m.b && 0 === m.c && 1 === m.d && 0 === m.e && 0 === m.f)), updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);
11649
11663
  }
11650
- function matchLength() {
11651
- return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
11664
+ validCheck(attribute, theme, aabbBounds, graphic) {
11665
+ if (!graphic) return !0;
11666
+ if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
11667
+ if (graphic.shadowRoot) return !0;
11668
+ if (!graphic.valid) return aabbBounds.clear(), !1;
11669
+ const {
11670
+ visible = theme.visible
11671
+ } = attribute;
11672
+ return !!visible || (aabbBounds.clear(), !1);
11652
11673
  }
11653
- function match(type, pattern, captureIndex) {
11654
- const captures = scan(pattern);
11655
- if (captures) return {
11656
- type: type,
11657
- value: captures[captureIndex]
11674
+ updateTempAABBBounds(aabbBounds) {
11675
+ const tb1 = this.tempAABBBounds1,
11676
+ tb2 = this.tempAABBBounds2;
11677
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
11678
+ tb1: tb1,
11679
+ tb2: tb2
11658
11680
  };
11659
11681
  }
11660
- function scan(regexp) {
11661
- const blankCaptures = /^[\n\r\t\s]+/.exec(input);
11662
- blankCaptures && consume(blankCaptures[0].length);
11663
- const captures = regexp.exec(input);
11664
- return captures && consume(captures[0].length), captures;
11665
- }
11666
- function consume(size) {
11667
- input = input.substr(size);
11668
- }
11669
- return function (code) {
11670
- return input = code.toString(), getAST();
11671
- };
11672
- }();
11673
- class GradientParser {
11674
- static IsGradient(c) {
11675
- return !("string" == typeof c && !c.includes("gradient"));
11676
- }
11677
- static IsGradientStr(c) {
11678
- return "string" == typeof c && c.includes("gradient");
11682
+ };
11683
+ exports.DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], exports.DefaultGraphicService);
11684
+
11685
+ const result = {
11686
+ x: 0,
11687
+ y: 0,
11688
+ z: 0,
11689
+ lastModelMatrix: null
11690
+ };
11691
+ class BaseRender {
11692
+ init(contributions) {
11693
+ contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
11679
11694
  }
11680
- static Parse(c) {
11681
- if (GradientParser.IsGradientStr(c)) try {
11682
- const datum = parse(c)[0];
11683
- if (datum) {
11684
- if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
11685
- if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
11686
- if ("conic" === datum.type) return GradientParser.ParseConic(datum);
11695
+ beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11696
+ this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
11697
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11698
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11687
11699
  }
11688
- } catch (err) {
11689
- return c;
11690
- }
11691
- return c;
11700
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11701
+ });
11692
11702
  }
11693
- static ParseConic(datum) {
11694
- const {
11695
- orientation: orientation,
11696
- colorStops = []
11697
- } = datum,
11698
- halfPi = pi / 2,
11699
- sa = parseFloat(orientation.value) / 180 * pi - halfPi;
11700
- return {
11701
- gradient: "conical",
11702
- x: .5,
11703
- y: .5,
11704
- startAngle: sa,
11705
- endAngle: sa + pi2,
11706
- stops: colorStops.map(item => ({
11707
- color: item.value,
11708
- offset: parseFloat(item.length.value) / 100
11709
- }))
11710
- };
11703
+ afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11704
+ this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
11705
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11706
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11707
+ }
11708
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11709
+ });
11711
11710
  }
11712
- static ParseRadial(datum) {
11711
+ valid(graphic, defaultAttribute, fillCb, strokeCb) {
11713
11712
  const {
11714
- colorStops = []
11715
- } = datum;
11716
- return {
11717
- gradient: "radial",
11718
- x0: .5,
11719
- y0: .5,
11720
- x1: .5,
11721
- y1: .5,
11722
- r0: 0,
11723
- r1: 1,
11724
- stops: colorStops.map(item => ({
11725
- color: item.value,
11726
- offset: parseFloat(item.length.value) / 100
11727
- }))
11713
+ fill = defaultAttribute.fill,
11714
+ background: background,
11715
+ stroke = defaultAttribute.stroke,
11716
+ opacity = defaultAttribute.opacity,
11717
+ fillOpacity = defaultAttribute.fillOpacity,
11718
+ lineWidth = defaultAttribute.lineWidth,
11719
+ strokeOpacity = defaultAttribute.strokeOpacity,
11720
+ visible = defaultAttribute.visible
11721
+ } = graphic.attribute,
11722
+ fVisible = fillVisible(opacity, fillOpacity, fill),
11723
+ sVisible = strokeVisible(opacity, strokeOpacity),
11724
+ doFill = runFill(fill, background),
11725
+ doStroke = runStroke(stroke, lineWidth);
11726
+ return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
11727
+ fVisible: fVisible,
11728
+ sVisible: sVisible,
11729
+ doFill: doFill,
11730
+ doStroke: doStroke
11728
11731
  };
11729
11732
  }
11730
- static ParseLinear(datum) {
11733
+ transform(graphic, graphicAttribute, context) {
11734
+ let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
11731
11735
  const {
11732
- orientation: orientation,
11733
- colorStops = []
11734
- } = datum,
11735
- halfPi = pi / 2;
11736
- let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
11737
- for (; angle < 0;) angle += pi2;
11738
- for (; angle > pi2;) angle -= pi2;
11739
- let x0 = 0,
11740
- y0 = 0,
11741
- x1 = 0,
11742
- y1 = 0;
11743
- return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
11744
- gradient: "linear",
11745
- x0: x0,
11746
- y0: y0,
11747
- x1: x1,
11748
- y1: y1,
11749
- stops: colorStops.map(item => ({
11750
- color: item.value,
11751
- offset: parseFloat(item.length.value) / 100
11752
- }))
11753
- };
11736
+ x = graphicAttribute.x,
11737
+ y = graphicAttribute.y,
11738
+ z = graphicAttribute.z,
11739
+ scaleX = graphicAttribute.scaleX,
11740
+ scaleY = graphicAttribute.scaleY,
11741
+ angle = graphicAttribute.angle,
11742
+ postMatrix: postMatrix
11743
+ } = graphic.attribute,
11744
+ lastModelMatrix = context.modelMatrix,
11745
+ camera = context.camera;
11746
+ result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
11747
+ const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
11748
+ onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
11749
+ if (shouldTransform3d) {
11750
+ const nextModelMatrix = mat4Allocate.allocate(),
11751
+ modelMatrix = mat4Allocate.allocate();
11752
+ getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
11753
+ }
11754
+ if (onlyTranslate && !lastModelMatrix) {
11755
+ const point = graphic.getOffsetXY(graphicAttribute);
11756
+ result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
11757
+ } else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
11758
+ const point = graphic.getOffsetXY(graphicAttribute);
11759
+ result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
11760
+ } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
11761
+ return result;
11754
11762
  }
11755
- }
11756
-
11757
- function getScaledStroke(context, width, dpr) {
11758
- let strokeWidth = width;
11759
- const {
11760
- a: a,
11761
- b: b,
11762
- c: c,
11763
- d: d
11764
- } = context.currentMatrix,
11765
- scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
11766
- scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
11767
- return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
11768
- }
11769
- function createColor(context, c, params) {
11770
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
11771
- let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
11772
- if (!c || !0 === c) return "black";
11773
- let result, color;
11774
- if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
11775
- if (color = GradientParser.Parse(color), "string" == typeof color) return color;
11776
- if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
11777
- const bounds = params.AABBBounds;
11778
- let w = bounds.x2 - bounds.x1,
11779
- h = bounds.y2 - bounds.y1,
11780
- x = bounds.x1 - offsetX,
11781
- y = bounds.y1 - offsetY;
11782
- if (params.attribute) {
11783
- const {
11784
- scaleX = 1,
11785
- scaleY = 1
11786
- } = params.attribute;
11787
- w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
11763
+ transformUseContext2d(graphic, graphicAttribute, z, context) {
11764
+ const camera = context.camera;
11765
+ if (this.camera = camera, camera) {
11766
+ const bounds = graphic.AABBBounds,
11767
+ width = bounds.x2 - bounds.x1,
11768
+ height = bounds.y2 - bounds.y1,
11769
+ p1 = context.project(0, 0, z),
11770
+ p2 = context.project(width, 0, z),
11771
+ p3 = context.project(width, height, z),
11772
+ _p1 = {
11773
+ x: 0,
11774
+ y: 0
11775
+ },
11776
+ _p2 = {
11777
+ x: width,
11778
+ y: 0
11779
+ },
11780
+ _p3 = {
11781
+ x: width,
11782
+ y: height
11783
+ };
11784
+ context.camera = null;
11785
+ const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
11786
+ m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
11787
+ m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
11788
+ m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
11789
+ m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
11790
+ dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
11791
+ dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
11792
+ context.setTransform(m11, m12, m21, m22, dx, dy, !0);
11788
11793
  }
11789
- "linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
11790
11794
  }
11791
- return result || "orange";
11792
- }
11793
- function createLinearGradient(context, color, x, y, w, h) {
11794
- var _a, _b, _c, _d;
11795
- const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
11796
- return color.stops.forEach(stop => {
11797
- canvasGradient.addColorStop(stop.offset, stop.color);
11798
- }), canvasGradient;
11799
- }
11800
- function createRadialGradient(context, color, x, y, w, h) {
11801
- var _a, _b, _c, _d, _e, _f;
11802
- const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
11803
- return color.stops.forEach(stop => {
11804
- canvasGradient.addColorStop(stop.offset, stop.color);
11805
- }), canvasGradient;
11806
- }
11807
- function createConicGradient(context, color, x, y, w, h) {
11808
- var _a, _b;
11809
- const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
11810
- return color.stops.forEach(stop => {
11811
- canvasGradient.addColorStop(stop.offset, stop.color);
11812
- }), canvasGradient.GetPattern(w + x, h + y, undefined);
11795
+ restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11796
+ this.camera && (context.camera = this.camera);
11797
+ }
11798
+ transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
11799
+ const p = context.project(x, y, z);
11800
+ context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
11801
+ }
11802
+ _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11803
+ const {
11804
+ context: context
11805
+ } = drawContext;
11806
+ if (!context) return;
11807
+ const {
11808
+ renderable: renderable
11809
+ } = graphic.attribute;
11810
+ if (!1 === renderable) return;
11811
+ context.highPerformanceSave();
11812
+ const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
11813
+ {
11814
+ x: x,
11815
+ y: y,
11816
+ z: z,
11817
+ lastModelMatrix: lastModelMatrix
11818
+ } = data;
11819
+ this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params), this.z = 0, context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix), context.modelMatrix = lastModelMatrix), context.highPerformanceRestore();
11820
+ }
11813
11821
  }
11814
11822
 
11815
11823
  var __decorate$1A = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -12689,7 +12697,7 @@
12689
12697
  originP2: originP2
12690
12698
  } = curve;
12691
12699
  let validP;
12692
- if (originP1 && !1 !== originP1.defined ? validP = p0 : originP1 && !1 !== originP2.defined && (validP = null !== (_a = curve.p3) && void 0 !== _a ? _a : curve.p1), defined0) {
12700
+ if (originP1 && !1 !== originP1.defined && !lastCurve ? validP = p0 : originP1 && !1 !== originP2.defined && (validP = null !== (_a = curve.p3) && void 0 !== _a ? _a : curve.p1), defined0) {
12693
12701
  newDefined0 = !defined0;
12694
12702
  const x = validP ? validP.x : curve.p0.x,
12695
12703
  y = validP ? validP.y : curve.p0.y;
@@ -14225,7 +14233,10 @@
14225
14233
  const {
14226
14234
  context: context
14227
14235
  } = drawContext;
14228
- if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14236
+ context.highPerformanceSave();
14237
+ const t1 = graphic.parent.globalTransMatrix,
14238
+ t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
14239
+ if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14229
14240
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
14230
14241
  const m = graphic.globalTransMatrix.getInverse();
14231
14242
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -15248,6 +15259,9 @@
15248
15259
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15249
15260
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15250
15261
  }
15262
+ parseSize(size) {
15263
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15264
+ }
15251
15265
  }
15252
15266
 
15253
15267
  function circle(ctx, r, x, y, z) {
@@ -15258,13 +15272,13 @@
15258
15272
  super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
15259
15273
  }
15260
15274
  draw(ctx, size, x, y, z) {
15261
- return circle(ctx, size / 2, x, y, z);
15275
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15262
15276
  }
15263
15277
  drawOffset(ctx, size, x, y, offset, z) {
15264
- return circle(ctx, size / 2 + offset, x, y, z);
15278
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15265
15279
  }
15266
15280
  drawToSvgPath(size, x, y, z) {
15267
- const r = size / 2;
15281
+ const r = this.parseSize(size) / 2;
15268
15282
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15269
15283
  }
15270
15284
  }
@@ -15281,10 +15295,10 @@
15281
15295
  super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
15282
15296
  }
15283
15297
  draw(ctx, size, x, y, z) {
15284
- return cross(ctx, size / 6, x, y, z);
15298
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15285
15299
  }
15286
15300
  drawOffset(ctx, size, x, y, offset, z) {
15287
- return crossOffset(ctx, size / 6, x, y, offset, z);
15301
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15288
15302
  }
15289
15303
  }
15290
15304
  var cross$1 = new CrossSymbol();
@@ -15297,13 +15311,13 @@
15297
15311
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15298
15312
  }
15299
15313
  draw(ctx, size, x, y, z) {
15300
- return diamond(ctx, size / 2, x, y, z);
15314
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15301
15315
  }
15302
15316
  drawFitDir(ctx, size, x, y, z) {
15303
- return diamond(ctx, size / 2, x, y, z);
15317
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15304
15318
  }
15305
15319
  drawOffset(ctx, size, x, y, offset, z) {
15306
- return diamond(ctx, size / 2 + offset, x, y, z);
15320
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15307
15321
  }
15308
15322
  }
15309
15323
  var diamond$1 = new DiamondSymbol();
@@ -15317,10 +15331,10 @@
15317
15331
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15318
15332
  }
15319
15333
  draw(ctx, size, x, y) {
15320
- return square(ctx, size / 2, x, y);
15334
+ return square(ctx, this.parseSize(size) / 2, x, y);
15321
15335
  }
15322
15336
  drawOffset(ctx, size, x, y, offset) {
15323
- return square(ctx, size / 2 + offset, x, y);
15337
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15324
15338
  }
15325
15339
  }
15326
15340
  var square$1 = new SquareSymbol();
@@ -15334,10 +15348,10 @@
15334
15348
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15335
15349
  }
15336
15350
  draw(ctx, size, x, y) {
15337
- return trianglUpOffset(ctx, size / 2, x, y);
15351
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15338
15352
  }
15339
15353
  drawOffset(ctx, size, x, y, offset) {
15340
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15354
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15341
15355
  }
15342
15356
  }
15343
15357
  var triangleUp = new TriangleUpSymbol();
@@ -15369,10 +15383,10 @@
15369
15383
  super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
15370
15384
  }
15371
15385
  draw(ctx, size, transX, transY) {
15372
- return star(ctx, size / 2, transX, transY);
15386
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15373
15387
  }
15374
15388
  drawOffset(ctx, size, transX, transY, offset) {
15375
- return star(ctx, size / 2 + offset, transX, transY);
15389
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15376
15390
  }
15377
15391
  }
15378
15392
  var star$1 = new StarSymbol();
@@ -15390,10 +15404,10 @@
15390
15404
  super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
15391
15405
  }
15392
15406
  draw(ctx, size, transX, transY) {
15393
- return arrow(ctx, size / 2, transX, transY);
15407
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15394
15408
  }
15395
15409
  drawOffset(ctx, size, transX, transY, offset) {
15396
- return arrow(ctx, size / 2 + offset, transX, transY);
15410
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15397
15411
  }
15398
15412
  }
15399
15413
  var arrow$1 = new ArrowSymbol();
@@ -15407,10 +15421,10 @@
15407
15421
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15408
15422
  }
15409
15423
  draw(ctx, size, transX, transY) {
15410
- return wedge(ctx, size / 2, transX, transY);
15424
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15411
15425
  }
15412
15426
  drawOffset(ctx, size, transX, transY, offset) {
15413
- return wedge(ctx, size / 2 + offset, transX, transY);
15427
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15414
15428
  }
15415
15429
  }
15416
15430
  var wedge$1 = new WedgeSymbol();
@@ -15423,10 +15437,10 @@
15423
15437
  super(...arguments), this.type = "stroke", this.pathStr = "";
15424
15438
  }
15425
15439
  draw(ctx, size, transX, transY) {
15426
- return stroke(ctx, size / 2, transX, transY);
15440
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15427
15441
  }
15428
15442
  drawOffset(ctx, size, transX, transY, offset) {
15429
- return stroke(ctx, size / 2 + offset, transX, transY);
15443
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15430
15444
  }
15431
15445
  }
15432
15446
  var stroke$1 = new StrokeSymbol();
@@ -15448,10 +15462,10 @@
15448
15462
  super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
15449
15463
  }
15450
15464
  draw(ctx, size, transX, transY) {
15451
- return wye(ctx, size / 2, transX, transY);
15465
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15452
15466
  }
15453
15467
  drawOffset(ctx, size, transX, transY, offset) {
15454
- return wye(ctx, size / 2 + offset, transX, transY);
15468
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15455
15469
  }
15456
15470
  }
15457
15471
  var wye$1 = new WyeSymbol();
@@ -15464,10 +15478,10 @@
15464
15478
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15465
15479
  }
15466
15480
  draw(ctx, size, x, y) {
15467
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15481
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15468
15482
  }
15469
15483
  drawOffset(ctx, size, x, y, offset) {
15470
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15484
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15471
15485
  }
15472
15486
  }
15473
15487
  var triangleLeft = new TriangleLeftSymbol();
@@ -15481,10 +15495,10 @@
15481
15495
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15482
15496
  }
15483
15497
  draw(ctx, size, x, y) {
15484
- return trianglRightOffset(ctx, size / 2, x, y);
15498
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15485
15499
  }
15486
15500
  drawOffset(ctx, size, x, y, offset) {
15487
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15501
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15488
15502
  }
15489
15503
  }
15490
15504
  var triangleRight = new TriangleRightSymbol();
@@ -15498,10 +15512,10 @@
15498
15512
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15499
15513
  }
15500
15514
  draw(ctx, size, x, y) {
15501
- return trianglDownOffset(ctx, size / 2, x, y);
15515
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15502
15516
  }
15503
15517
  drawOffset(ctx, size, x, y, offset) {
15504
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15518
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15505
15519
  }
15506
15520
  }
15507
15521
  var triangleDown = new TriangleDownSymbol();
@@ -15516,10 +15530,10 @@
15516
15530
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15517
15531
  }
15518
15532
  draw(ctx, size, x, y) {
15519
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15533
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15520
15534
  }
15521
15535
  drawOffset(ctx, size, x, y, offset) {
15522
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15536
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15523
15537
  }
15524
15538
  }
15525
15539
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15533,10 +15547,10 @@
15533
15547
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15534
15548
  }
15535
15549
  draw(ctx, size, transX, transY) {
15536
- return arrow2Left(ctx, size / 4, transX, transY);
15550
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15537
15551
  }
15538
15552
  drawOffset(ctx, size, transX, transY, offset) {
15539
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15553
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15540
15554
  }
15541
15555
  }
15542
15556
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15550,10 +15564,10 @@
15550
15564
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15551
15565
  }
15552
15566
  draw(ctx, size, transX, transY) {
15553
- return arrow2Right(ctx, size / 4, transX, transY);
15567
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15554
15568
  }
15555
15569
  drawOffset(ctx, size, transX, transY, offset) {
15556
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15570
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15557
15571
  }
15558
15572
  }
15559
15573
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15567,10 +15581,10 @@
15567
15581
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15568
15582
  }
15569
15583
  draw(ctx, size, transX, transY) {
15570
- return arrow2Up(ctx, size / 4, transX, transY);
15584
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15571
15585
  }
15572
15586
  drawOffset(ctx, size, transX, transY, offset) {
15573
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15587
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15574
15588
  }
15575
15589
  }
15576
15590
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15584,10 +15598,10 @@
15584
15598
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15585
15599
  }
15586
15600
  draw(ctx, size, transX, transY) {
15587
- return arrow2Down(ctx, size / 4, transX, transY);
15601
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15588
15602
  }
15589
15603
  drawOffset(ctx, size, transX, transY, offset) {
15590
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15604
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15591
15605
  }
15592
15606
  }
15593
15607
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15600,13 +15614,13 @@
15600
15614
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15601
15615
  }
15602
15616
  draw(ctx, size, x, y, z) {
15603
- return lineV(ctx, size / 2, x, y);
15617
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15604
15618
  }
15605
15619
  drawOffset(ctx, size, x, y, offset, z) {
15606
- return lineV(ctx, size / 2 + offset, x, y);
15620
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15607
15621
  }
15608
15622
  drawToSvgPath(size, x, y, z) {
15609
- const r = size / 2;
15623
+ const r = this.parseSize(size) / 2;
15610
15624
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15611
15625
  }
15612
15626
  }
@@ -15620,13 +15634,13 @@
15620
15634
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15621
15635
  }
15622
15636
  draw(ctx, size, x, y, z) {
15623
- return lineH(ctx, size / 2, x, y);
15637
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15624
15638
  }
15625
15639
  drawOffset(ctx, size, x, y, offset, z) {
15626
- return lineH(ctx, size / 2 + offset, x, y);
15640
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15627
15641
  }
15628
15642
  drawToSvgPath(size, x, y, z) {
15629
- const r = size / 2;
15643
+ const r = this.parseSize(size) / 2;
15630
15644
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15631
15645
  }
15632
15646
  }
@@ -15640,13 +15654,13 @@
15640
15654
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15641
15655
  }
15642
15656
  draw(ctx, size, x, y, z) {
15643
- return close(ctx, size / 2, x, y);
15657
+ return close(ctx, this.parseSize(size) / 2, x, y);
15644
15658
  }
15645
15659
  drawOffset(ctx, size, x, y, offset, z) {
15646
- return close(ctx, size / 2 + offset, x, y);
15660
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15647
15661
  }
15648
15662
  drawToSvgPath(size, x, y, z) {
15649
- const r = size / 2;
15663
+ const r = this.parseSize(size) / 2;
15650
15664
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15651
15665
  }
15652
15666
  }
@@ -15680,15 +15694,18 @@
15680
15694
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15681
15695
  }
15682
15696
  drawOffset(ctx, size, x, y, offset, z, cb) {
15683
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15697
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15684
15698
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15685
15699
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15686
15700
  }
15687
15701
  draw(ctx, size, x, y, z, cb) {
15688
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15702
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15703
+ }
15704
+ parseSize(size) {
15705
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15689
15706
  }
15690
15707
  bounds(size, bounds) {
15691
- if (this.isSvg) {
15708
+ if (size = this.parseSize(size), this.isSvg) {
15692
15709
  if (!this.svgCache) return;
15693
15710
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15694
15711
  let {
@@ -16371,7 +16388,11 @@
16371
16388
  case "sub":
16372
16389
  baseline += this.descent / 2;
16373
16390
  }
16374
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16391
+ "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
16392
+ const {
16393
+ lineWidth = 1
16394
+ } = this.character;
16395
+ this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
16375
16396
  }
16376
16397
  getWidthWithEllips(direction) {
16377
16398
  let text = this.text;
@@ -16594,12 +16615,18 @@
16594
16615
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16595
16616
  }
16596
16617
  }
16597
- this.paragraphs.map((paragraph, index) => {
16618
+ this.paragraphs.forEach((paragraph, index) => {
16598
16619
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
16599
16620
  x: x + paragraph._x,
16600
16621
  y: y + paragraph._y
16601
16622
  }), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
16602
- paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16623
+ const b = {
16624
+ x1: this.left,
16625
+ y1: this.top,
16626
+ x2: this.left + this.actualWidth,
16627
+ y2: this.top + this.height
16628
+ };
16629
+ applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16603
16630
  });
16604
16631
  }
16605
16632
  getWidthWithEllips(ellipsis) {
@@ -16622,7 +16649,7 @@
16622
16649
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16623
16650
  }
16624
16651
  let width = 0;
16625
- return this.paragraphs.map((paragraph, index) => {
16652
+ return this.paragraphs.forEach((paragraph, index) => {
16626
16653
  width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
16627
16654
  }), width;
16628
16655
  }
@@ -16662,7 +16689,7 @@
16662
16689
  }
16663
16690
  }
16664
16691
 
16665
- const RICHTEXT_UPDATE_TAG_KEY = ["width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", "fill", "stroke", "fontSize", ...GRAPHIC_UPDATE_TAG_KEY];
16692
+ const RICHTEXT_UPDATE_TAG_KEY = ["width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", "fill", "stroke", "fontSize", "fontFamily", "fontStyle", "fontWeight", "lineWidth", "opacity", "fillOpacity", "strokeOpacity", ...GRAPHIC_UPDATE_TAG_KEY];
16666
16693
  class RichText extends Graphic {
16667
16694
  constructor(params) {
16668
16695
  super(params), this.type = "richtext", this._currentHoverIcon = null, this.numberType = RICHTEXT_NUMBER_TYPE, this.onBeforeAttributeUpdate = (val, attributes, key) => {
@@ -28614,7 +28641,7 @@
28614
28641
 
28615
28642
  const roughModule = _roughModule;
28616
28643
 
28617
- const version = "0.20.15";
28644
+ const version = "0.20.17";
28618
28645
  preLoadAllModule();
28619
28646
  if (isBrowserEnv()) {
28620
28647
  loadBrowserEnv(container);