@visactor/vrender 0.20.15 → 0.20.16

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
@@ -4149,6 +4149,292 @@
4149
4149
  class Application {}
4150
4150
  const application = new Application();
4151
4151
 
4152
+ const parse = function () {
4153
+ const tokens = {
4154
+ linearGradient: /^(linear\-gradient)/i,
4155
+ radialGradient: /^(radial\-gradient)/i,
4156
+ conicGradient: /^(conic\-gradient)/i,
4157
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
4158
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
4159
+ positionKeywords: /^(left|center|right|top|bottom)/i,
4160
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
4161
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
4162
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
4163
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4164
+ fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4165
+ startCall: /^\(/,
4166
+ endCall: /^\)/,
4167
+ comma: /^,/,
4168
+ hexColor: /(^\#[0-9a-fA-F]+)/,
4169
+ literalColor: /^([a-zA-Z]+)/,
4170
+ rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
4171
+ rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
4172
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
4173
+ };
4174
+ let input = "";
4175
+ function error(msg) {
4176
+ const err = new Error(input + ": " + msg);
4177
+ throw err.source = input, err;
4178
+ }
4179
+ function getAST() {
4180
+ const ast = matchListing(matchDefinition);
4181
+ return input.length > 0 && error("Invalid input not EOF"), ast;
4182
+ }
4183
+ function matchDefinition() {
4184
+ return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
4185
+ }
4186
+ function matchGradient(gradientType, pattern, orientationMatcher) {
4187
+ return function (pattern, callback) {
4188
+ const captures = scan(pattern);
4189
+ if (captures) {
4190
+ scan(tokens.startCall) || error("Missing (");
4191
+ const result = callback(captures);
4192
+ return scan(tokens.endCall) || error("Missing )"), result;
4193
+ }
4194
+ }(pattern, function (captures) {
4195
+ const orientation = orientationMatcher();
4196
+ return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
4197
+ type: gradientType,
4198
+ orientation: orientation,
4199
+ colorStops: matchListing(matchColorStop)
4200
+ };
4201
+ });
4202
+ }
4203
+ function matchLinearOrientation() {
4204
+ return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
4205
+ }
4206
+ function matchConicalOrientation() {
4207
+ return match("angular", tokens.fromAngleValue, 1);
4208
+ }
4209
+ function matchListRadialOrientations() {
4210
+ let radialOrientations,
4211
+ lookaheadCache,
4212
+ radialOrientation = matchRadialOrientation();
4213
+ return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
4214
+ }
4215
+ function matchRadialOrientation() {
4216
+ let radialType = function () {
4217
+ const circle = match("shape", /^(circle)/i, 0);
4218
+ circle && (circle.style = matchLength() || matchExtentKeyword());
4219
+ return circle;
4220
+ }() || function () {
4221
+ const ellipse = match("shape", /^(ellipse)/i, 0);
4222
+ ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
4223
+ return ellipse;
4224
+ }();
4225
+ if (radialType) radialType.at = matchAtPosition();else {
4226
+ const extent = matchExtentKeyword();
4227
+ if (extent) {
4228
+ radialType = extent;
4229
+ const positionAt = matchAtPosition();
4230
+ positionAt && (radialType.at = positionAt);
4231
+ } else {
4232
+ const defaultPosition = matchPositioning();
4233
+ defaultPosition && (radialType = {
4234
+ type: "default-radial",
4235
+ at: defaultPosition
4236
+ });
4237
+ }
4238
+ }
4239
+ return radialType;
4240
+ }
4241
+ function matchExtentKeyword() {
4242
+ return match("extent-keyword", tokens.extentKeywords, 1);
4243
+ }
4244
+ function matchAtPosition() {
4245
+ if (match("position", /^at/, 0)) {
4246
+ const positioning = matchPositioning();
4247
+ return positioning || error("Missing positioning value"), positioning;
4248
+ }
4249
+ }
4250
+ function matchPositioning() {
4251
+ const location = {
4252
+ x: matchDistance(),
4253
+ y: matchDistance()
4254
+ };
4255
+ if (location.x || location.y) return {
4256
+ type: "position",
4257
+ value: location
4258
+ };
4259
+ }
4260
+ function matchListing(matcher) {
4261
+ let captures = matcher();
4262
+ const result = [];
4263
+ if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
4264
+ return result;
4265
+ }
4266
+ function matchColorStop() {
4267
+ const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
4268
+ return color || error("Expected color definition"), color.length = matchDistance(), color;
4269
+ }
4270
+ function matchDistance() {
4271
+ return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
4272
+ }
4273
+ function matchLength() {
4274
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
4275
+ }
4276
+ function match(type, pattern, captureIndex) {
4277
+ const captures = scan(pattern);
4278
+ if (captures) return {
4279
+ type: type,
4280
+ value: captures[captureIndex]
4281
+ };
4282
+ }
4283
+ function scan(regexp) {
4284
+ const blankCaptures = /^[\n\r\t\s]+/.exec(input);
4285
+ blankCaptures && consume(blankCaptures[0].length);
4286
+ const captures = regexp.exec(input);
4287
+ return captures && consume(captures[0].length), captures;
4288
+ }
4289
+ function consume(size) {
4290
+ input = input.substr(size);
4291
+ }
4292
+ return function (code) {
4293
+ return input = code.toString(), getAST();
4294
+ };
4295
+ }();
4296
+ class GradientParser {
4297
+ static IsGradient(c) {
4298
+ return !("string" == typeof c && !c.includes("gradient"));
4299
+ }
4300
+ static IsGradientStr(c) {
4301
+ return "string" == typeof c && c.includes("gradient");
4302
+ }
4303
+ static Parse(c) {
4304
+ if (GradientParser.IsGradientStr(c)) try {
4305
+ const datum = parse(c)[0];
4306
+ if (datum) {
4307
+ if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
4308
+ if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
4309
+ if ("conic" === datum.type) return GradientParser.ParseConic(datum);
4310
+ }
4311
+ } catch (err) {
4312
+ return c;
4313
+ }
4314
+ return c;
4315
+ }
4316
+ static ParseConic(datum) {
4317
+ const {
4318
+ orientation: orientation,
4319
+ colorStops = []
4320
+ } = datum,
4321
+ halfPi = pi / 2,
4322
+ sa = parseFloat(orientation.value) / 180 * pi - halfPi;
4323
+ return {
4324
+ gradient: "conical",
4325
+ x: .5,
4326
+ y: .5,
4327
+ startAngle: sa,
4328
+ endAngle: sa + pi2,
4329
+ stops: colorStops.map(item => ({
4330
+ color: item.value,
4331
+ offset: parseFloat(item.length.value) / 100
4332
+ }))
4333
+ };
4334
+ }
4335
+ static ParseRadial(datum) {
4336
+ const {
4337
+ colorStops = []
4338
+ } = datum;
4339
+ return {
4340
+ gradient: "radial",
4341
+ x0: .5,
4342
+ y0: .5,
4343
+ x1: .5,
4344
+ y1: .5,
4345
+ r0: 0,
4346
+ r1: 1,
4347
+ stops: colorStops.map(item => ({
4348
+ color: item.value,
4349
+ offset: parseFloat(item.length.value) / 100
4350
+ }))
4351
+ };
4352
+ }
4353
+ static ParseLinear(datum) {
4354
+ const {
4355
+ orientation: orientation,
4356
+ colorStops = []
4357
+ } = datum,
4358
+ halfPi = pi / 2;
4359
+ let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
4360
+ for (; angle < 0;) angle += pi2;
4361
+ for (; angle >= pi2;) angle -= pi2;
4362
+ let x0 = 0,
4363
+ y0 = 0,
4364
+ x1 = 0,
4365
+ y1 = 0;
4366
+ 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)), {
4367
+ gradient: "linear",
4368
+ x0: x0,
4369
+ y0: y0,
4370
+ x1: x1,
4371
+ y1: y1,
4372
+ stops: colorStops.map(item => ({
4373
+ color: item.value,
4374
+ offset: parseFloat(item.length.value) / 100
4375
+ }))
4376
+ };
4377
+ }
4378
+ }
4379
+
4380
+ function getScaledStroke(context, width, dpr) {
4381
+ let strokeWidth = width;
4382
+ const {
4383
+ a: a,
4384
+ b: b,
4385
+ c: c,
4386
+ d: d
4387
+ } = context.currentMatrix,
4388
+ scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
4389
+ scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
4390
+ return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
4391
+ }
4392
+ function createColor(context, c, params) {
4393
+ let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4394
+ let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4395
+ if (!c || !0 === c) return "black";
4396
+ let result, color;
4397
+ if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
4398
+ if (color = GradientParser.Parse(color), "string" == typeof color) return color;
4399
+ if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
4400
+ const bounds = params.AABBBounds;
4401
+ let w = bounds.x2 - bounds.x1,
4402
+ h = bounds.y2 - bounds.y1,
4403
+ x = bounds.x1 - offsetX,
4404
+ y = bounds.y1 - offsetY;
4405
+ if (params.attribute) {
4406
+ const {
4407
+ scaleX = 1,
4408
+ scaleY = 1
4409
+ } = params.attribute;
4410
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
4411
+ }
4412
+ "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));
4413
+ }
4414
+ return result || "orange";
4415
+ }
4416
+ function createLinearGradient(context, color, x, y, w, h) {
4417
+ var _a, _b, _c, _d;
4418
+ 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);
4419
+ return color.stops.forEach(stop => {
4420
+ canvasGradient.addColorStop(stop.offset, stop.color);
4421
+ }), canvasGradient;
4422
+ }
4423
+ function createRadialGradient(context, color, x, y, w, h) {
4424
+ var _a, _b, _c, _d, _e, _f;
4425
+ 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));
4426
+ return color.stops.forEach(stop => {
4427
+ canvasGradient.addColorStop(stop.offset, stop.color);
4428
+ }), canvasGradient;
4429
+ }
4430
+ function createConicGradient(context, color, x, y, w, h) {
4431
+ var _a, _b;
4432
+ 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);
4433
+ return color.stops.forEach(stop => {
4434
+ canvasGradient.addColorStop(stop.offset, stop.color);
4435
+ }), canvasGradient.GetPattern(w + x, h + y, undefined);
4436
+ }
4437
+
4152
4438
  const DIRECTION_KEY = {
4153
4439
  horizontal: {
4154
4440
  width: "width",
@@ -4200,14 +4486,16 @@
4200
4486
  fontFamily: character.fontFamily || "sans-serif"
4201
4487
  });
4202
4488
  };
4203
- function applyFillStyle(ctx, character) {
4489
+ function applyFillStyle(ctx, character, b) {
4204
4490
  const fillStyle = character && character.fill || defaultFormatting.fill;
4205
4491
  if (!fillStyle) return void (ctx.globalAlpha = 0);
4206
4492
  const {
4207
4493
  fillOpacity = 1,
4208
4494
  opacity = 1
4209
4495
  } = character;
4210
- ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
4496
+ ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
4497
+ AABBBounds: b
4498
+ }) : fillStyle, setTextStyle(ctx, character);
4211
4499
  }
4212
4500
  function applyStrokeStyle(ctx, character) {
4213
4501
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
@@ -11119,697 +11407,411 @@
11119
11407
  allocate(a, b, c, d, e, f) {
11120
11408
  if (!this.pools.length) return new Matrix(a, b, c, d, e, f);
11121
11409
  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);
11410
+ return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
11369
11411
  }
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);
11412
+ allocateByObj(matrix) {
11413
+ if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
11414
+ const m = this.pools.pop();
11415
+ 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
11416
  }
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
- };
11417
+ free(d) {
11418
+ this.pools.push(d);
11387
11419
  }
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));
11420
+ get length() {
11421
+ return this.pools.length;
11400
11422
  }
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
- });
11423
+ release() {
11424
+ this.pools = [];
11408
11425
  }
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
- });
11426
+ }
11427
+ class DefaultMat4Allocate {
11428
+ constructor() {
11429
+ this.pools = [];
11416
11430
  }
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
- };
11431
+ static identity(out) {
11432
+ return identityMat4(out);
11438
11433
  }
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;
11434
+ allocate() {
11435
+ if (!this.pools.length) return createMat4();
11436
+ const m = this.pools.pop();
11437
+ return DefaultMat4Allocate.identity(m), m;
11468
11438
  }
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
- }
11439
+ allocateByObj(d) {
11440
+ let m;
11441
+ m = this.pools.length ? this.pools.pop() : createMat4();
11442
+ for (let i = 0; i < m.length; i++) m[i] = d[i];
11443
+ return m;
11500
11444
  }
11501
- restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11502
- this.camera && (context.camera = this.camera);
11445
+ free(m) {
11446
+ m && this.pools.push(m);
11503
11447
  }
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();
11448
+ get length() {
11449
+ return this.pools.length;
11507
11450
  }
11508
- _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11509
- const {
11510
- context: context
11511
- } = drawContext;
11512
- if (!context) return;
11451
+ release() {
11452
+ this.pools = [];
11453
+ }
11454
+ }
11455
+ const matrixAllocate = new DefaultMatrixAllocate();
11456
+ const mat4Allocate = new DefaultMat4Allocate();
11457
+
11458
+ var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
11459
+ var d,
11460
+ c = arguments.length,
11461
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
11462
+ 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);
11463
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11464
+ },
11465
+ __metadata$1d = undefined && undefined.__metadata || function (k, v) {
11466
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11467
+ },
11468
+ __param$R = undefined && undefined.__param || function (paramIndex, decorator) {
11469
+ return function (target, key) {
11470
+ decorator(target, key, paramIndex);
11471
+ };
11472
+ };
11473
+ function getExtraModelMatrix(dx, dy, graphic) {
11474
+ const {
11475
+ alpha: alpha,
11476
+ beta: beta
11477
+ } = graphic.attribute;
11478
+ if (!alpha && !beta) return null;
11479
+ const {
11480
+ anchor3d = graphic.attribute.anchor
11481
+ } = graphic.attribute,
11482
+ _anchor = [0, 0];
11483
+ if (anchor3d) {
11484
+ if ("string" == typeof anchor3d[0]) {
11485
+ const ratio = parseFloat(anchor3d[0]) / 100,
11486
+ bounds = graphic.AABBBounds;
11487
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11488
+ } else _anchor[0] = anchor3d[0];
11489
+ if ("string" == typeof anchor3d[1]) {
11490
+ const ratio = parseFloat(anchor3d[1]) / 100,
11491
+ bounds = graphic.AABBBounds;
11492
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11493
+ } else _anchor[1] = anchor3d[1];
11494
+ }
11495
+ if ("text" === graphic.type) {
11513
11496
  const {
11514
- renderable: renderable
11497
+ textAlign: textAlign
11515
11498
  } = 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();
11499
+ _anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
11500
+ }
11501
+ _anchor[0] += dx, _anchor[1] += dy;
11502
+ const modelMatrix = mat4Allocate.allocate();
11503
+ 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;
11504
+ }
11505
+ function getModelMatrix(out, graphic, theme) {
11506
+ var _a;
11507
+ const {
11508
+ x = theme.x,
11509
+ y = theme.y,
11510
+ z = theme.z,
11511
+ dx = theme.dx,
11512
+ dy = theme.dy,
11513
+ dz = theme.dz,
11514
+ scaleX = theme.scaleX,
11515
+ scaleY = theme.scaleY,
11516
+ scaleZ = theme.scaleZ,
11517
+ alpha = theme.alpha,
11518
+ beta = theme.beta,
11519
+ angle = theme.angle,
11520
+ anchor3d = graphic.attribute.anchor,
11521
+ anchor: anchor
11522
+ } = graphic.attribute,
11523
+ _anchor = [0, 0, 0];
11524
+ if (anchor3d) {
11525
+ if ("string" == typeof anchor3d[0]) {
11526
+ const ratio = parseFloat(anchor3d[0]) / 100,
11527
+ bounds = graphic.AABBBounds;
11528
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11529
+ } else _anchor[0] = anchor3d[0];
11530
+ if ("string" == typeof anchor3d[1]) {
11531
+ const ratio = parseFloat(anchor3d[1]) / 100,
11532
+ bounds = graphic.AABBBounds;
11533
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11534
+ } else _anchor[1] = anchor3d[1];
11535
+ _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
11526
11536
  }
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;
11537
+ 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) {
11538
+ const m = mat4Allocate.allocate(),
11539
+ _anchor = [0, 0];
11540
+ if (anchor) {
11541
+ if ("string" == typeof anchor3d[0]) {
11542
+ const ratio = parseFloat(anchor3d[0]) / 100,
11543
+ bounds = graphic.AABBBounds;
11544
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11545
+ } else _anchor[0] = anchor3d[0];
11546
+ if ("string" == typeof anchor3d[1]) {
11547
+ const ratio = parseFloat(anchor3d[1]) / 100,
11548
+ bounds = graphic.AABBBounds;
11549
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11550
+ } else _anchor[1] = anchor3d[1];
11551
+ }
11552
+ 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
11553
  }
11556
- function getAST() {
11557
- const ast = matchListing(matchDefinition);
11558
- return input.length > 0 && error("Invalid input not EOF"), ast;
11554
+ }
11555
+ function shouldUseMat4(graphic) {
11556
+ const {
11557
+ alpha: alpha,
11558
+ beta: beta
11559
+ } = graphic.attribute;
11560
+ return alpha || beta;
11561
+ }
11562
+ exports.DefaultGraphicService = class DefaultGraphicService {
11563
+ constructor(creator) {
11564
+ this.creator = creator, this.hooks = {
11565
+ onAttributeUpdate: new SyncHook(["graphic"]),
11566
+ onSetStage: new SyncHook(["graphic", "stage"]),
11567
+ onRemove: new SyncHook(["graphic"]),
11568
+ onRelease: new SyncHook(["graphic"]),
11569
+ onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
11570
+ onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
11571
+ beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
11572
+ afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
11573
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
11559
11574
  }
11560
- function matchDefinition() {
11561
- return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
11575
+ onAttributeUpdate(graphic) {
11576
+ this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
11562
11577
  }
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
- });
11578
+ onSetStage(graphic, stage) {
11579
+ this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
11579
11580
  }
11580
- function matchLinearOrientation() {
11581
- return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
11581
+ onRemove(graphic) {
11582
+ this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
11582
11583
  }
11583
- function matchConicalOrientation() {
11584
- return match("angular", tokens.fromAngleValue, 1);
11584
+ onRelease(graphic) {
11585
+ this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
11585
11586
  }
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;
11587
+ onAddIncremental(graphic, group, stage) {
11588
+ this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
11591
11589
  }
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;
11590
+ onClearIncremental(group, stage) {
11591
+ this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
11617
11592
  }
11618
- function matchExtentKeyword() {
11619
- return match("extent-keyword", tokens.extentKeywords, 1);
11593
+ beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
11594
+ this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
11620
11595
  }
11621
- function matchAtPosition() {
11622
- if (match("position", /^at/, 0)) {
11623
- const positioning = matchPositioning();
11624
- return positioning || error("Missing positioning value"), positioning;
11625
- }
11596
+ afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
11597
+ this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
11626
11598
  }
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
- };
11599
+ updatePathProxyAABBBounds(aabbBounds, graphic) {
11600
+ const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
11601
+ if (!path) return !1;
11602
+ const boundsContext = new BoundsContext(aabbBounds);
11603
+ return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
11636
11604
  }
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;
11605
+ updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
11606
+ const {
11607
+ textAlign: textAlign,
11608
+ textBaseline: textBaseline
11609
+ } = attribute;
11610
+ if (null != attribute.forceBoundsHeight) {
11611
+ const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
11612
+ dy = textLayoutOffsetY(textBaseline, h, h);
11613
+ aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
11614
+ }
11615
+ if (null != attribute.forceBoundsWidth) {
11616
+ const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
11617
+ dx = textDrawOffsetX(textAlign, w);
11618
+ aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
11619
+ }
11642
11620
  }
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;
11621
+ combindShadowAABBBounds(bounds, graphic) {
11622
+ if (graphic && graphic.shadowRoot) {
11623
+ const b = graphic.shadowRoot.AABBBounds;
11624
+ bounds.union(b);
11625
+ }
11646
11626
  }
11647
- function matchDistance() {
11648
- return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
11627
+ transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
11628
+ if (!aabbBounds.empty()) {
11629
+ const {
11630
+ scaleX = theme.scaleX,
11631
+ scaleY = theme.scaleY,
11632
+ stroke = theme.stroke,
11633
+ shadowBlur = theme.shadowBlur,
11634
+ lineWidth = theme.lineWidth,
11635
+ pickStrokeBuffer = theme.pickStrokeBuffer,
11636
+ strokeBoundsBuffer = theme.strokeBoundsBuffer
11637
+ } = attribute,
11638
+ tb1 = this.tempAABBBounds1,
11639
+ tb2 = this.tempAABBBounds2;
11640
+ if (stroke && lineWidth) {
11641
+ const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
11642
+ boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
11643
+ }
11644
+ if (shadowBlur) {
11645
+ const {
11646
+ shadowOffsetX = theme.shadowOffsetX,
11647
+ shadowOffsetY = theme.shadowOffsetY
11648
+ } = attribute,
11649
+ shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
11650
+ boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
11651
+ }
11652
+ }
11653
+ if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
11654
+ let updateMatrix = !0;
11655
+ const m = graphic.transMatrix;
11656
+ 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
11657
  }
11650
- function matchLength() {
11651
- return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
11658
+ validCheck(attribute, theme, aabbBounds, graphic) {
11659
+ if (!graphic) return !0;
11660
+ if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
11661
+ if (graphic.shadowRoot) return !0;
11662
+ if (!graphic.valid) return aabbBounds.clear(), !1;
11663
+ const {
11664
+ visible = theme.visible
11665
+ } = attribute;
11666
+ return !!visible || (aabbBounds.clear(), !1);
11652
11667
  }
11653
- function match(type, pattern, captureIndex) {
11654
- const captures = scan(pattern);
11655
- if (captures) return {
11656
- type: type,
11657
- value: captures[captureIndex]
11668
+ updateTempAABBBounds(aabbBounds) {
11669
+ const tb1 = this.tempAABBBounds1,
11670
+ tb2 = this.tempAABBBounds2;
11671
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
11672
+ tb1: tb1,
11673
+ tb2: tb2
11658
11674
  };
11659
11675
  }
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");
11676
+ };
11677
+ exports.DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], exports.DefaultGraphicService);
11678
+
11679
+ const result = {
11680
+ x: 0,
11681
+ y: 0,
11682
+ z: 0,
11683
+ lastModelMatrix: null
11684
+ };
11685
+ class BaseRender {
11686
+ init(contributions) {
11687
+ 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
11688
  }
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);
11689
+ beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11690
+ this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
11691
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11692
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11687
11693
  }
11688
- } catch (err) {
11689
- return c;
11690
- }
11691
- return c;
11694
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11695
+ });
11692
11696
  }
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
- };
11697
+ afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11698
+ this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
11699
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11700
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11701
+ }
11702
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11703
+ });
11711
11704
  }
11712
- static ParseRadial(datum) {
11705
+ valid(graphic, defaultAttribute, fillCb, strokeCb) {
11713
11706
  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
- }))
11707
+ fill = defaultAttribute.fill,
11708
+ background: background,
11709
+ stroke = defaultAttribute.stroke,
11710
+ opacity = defaultAttribute.opacity,
11711
+ fillOpacity = defaultAttribute.fillOpacity,
11712
+ lineWidth = defaultAttribute.lineWidth,
11713
+ strokeOpacity = defaultAttribute.strokeOpacity,
11714
+ visible = defaultAttribute.visible
11715
+ } = graphic.attribute,
11716
+ fVisible = fillVisible(opacity, fillOpacity, fill),
11717
+ sVisible = strokeVisible(opacity, strokeOpacity),
11718
+ doFill = runFill(fill, background),
11719
+ doStroke = runStroke(stroke, lineWidth);
11720
+ return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
11721
+ fVisible: fVisible,
11722
+ sVisible: sVisible,
11723
+ doFill: doFill,
11724
+ doStroke: doStroke
11728
11725
  };
11729
11726
  }
11730
- static ParseLinear(datum) {
11727
+ transform(graphic, graphicAttribute, context) {
11728
+ let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
11731
11729
  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
- };
11730
+ x = graphicAttribute.x,
11731
+ y = graphicAttribute.y,
11732
+ z = graphicAttribute.z,
11733
+ scaleX = graphicAttribute.scaleX,
11734
+ scaleY = graphicAttribute.scaleY,
11735
+ angle = graphicAttribute.angle,
11736
+ postMatrix: postMatrix
11737
+ } = graphic.attribute,
11738
+ lastModelMatrix = context.modelMatrix,
11739
+ camera = context.camera;
11740
+ result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
11741
+ const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
11742
+ onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
11743
+ if (shouldTransform3d) {
11744
+ const nextModelMatrix = mat4Allocate.allocate(),
11745
+ modelMatrix = mat4Allocate.allocate();
11746
+ 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);
11747
+ }
11748
+ if (onlyTranslate && !lastModelMatrix) {
11749
+ const point = graphic.getOffsetXY(graphicAttribute);
11750
+ result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
11751
+ } 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) {
11752
+ const point = graphic.getOffsetXY(graphicAttribute);
11753
+ result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
11754
+ } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
11755
+ return result;
11754
11756
  }
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;
11757
+ transformUseContext2d(graphic, graphicAttribute, z, context) {
11758
+ const camera = context.camera;
11759
+ if (this.camera = camera, camera) {
11760
+ const bounds = graphic.AABBBounds,
11761
+ width = bounds.x2 - bounds.x1,
11762
+ height = bounds.y2 - bounds.y1,
11763
+ p1 = context.project(0, 0, z),
11764
+ p2 = context.project(width, 0, z),
11765
+ p3 = context.project(width, height, z),
11766
+ _p1 = {
11767
+ x: 0,
11768
+ y: 0
11769
+ },
11770
+ _p2 = {
11771
+ x: width,
11772
+ y: 0
11773
+ },
11774
+ _p3 = {
11775
+ x: width,
11776
+ y: height
11777
+ };
11778
+ context.camera = null;
11779
+ const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
11780
+ m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
11781
+ m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
11782
+ m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
11783
+ m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
11784
+ 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,
11785
+ 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;
11786
+ context.setTransform(m11, m12, m21, m22, dx, dy, !0);
11788
11787
  }
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
11788
  }
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);
11789
+ restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11790
+ this.camera && (context.camera = this.camera);
11791
+ }
11792
+ transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
11793
+ const p = context.project(x, y, z);
11794
+ 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();
11795
+ }
11796
+ _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11797
+ const {
11798
+ context: context
11799
+ } = drawContext;
11800
+ if (!context) return;
11801
+ const {
11802
+ renderable: renderable
11803
+ } = graphic.attribute;
11804
+ if (!1 === renderable) return;
11805
+ context.highPerformanceSave();
11806
+ const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
11807
+ {
11808
+ x: x,
11809
+ y: y,
11810
+ z: z,
11811
+ lastModelMatrix: lastModelMatrix
11812
+ } = data;
11813
+ 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();
11814
+ }
11813
11815
  }
11814
11816
 
11815
11817
  var __decorate$1A = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -14225,7 +14227,10 @@
14225
14227
  const {
14226
14228
  context: context
14227
14229
  } = drawContext;
14228
- if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14230
+ context.highPerformanceSave();
14231
+ const t1 = graphic.parent.globalTransMatrix,
14232
+ t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
14233
+ if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14229
14234
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
14230
14235
  const m = graphic.globalTransMatrix.getInverse();
14231
14236
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -15248,6 +15253,9 @@
15248
15253
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15249
15254
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15250
15255
  }
15256
+ parseSize(size) {
15257
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15258
+ }
15251
15259
  }
15252
15260
 
15253
15261
  function circle(ctx, r, x, y, z) {
@@ -15258,13 +15266,13 @@
15258
15266
  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
15267
  }
15260
15268
  draw(ctx, size, x, y, z) {
15261
- return circle(ctx, size / 2, x, y, z);
15269
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15262
15270
  }
15263
15271
  drawOffset(ctx, size, x, y, offset, z) {
15264
- return circle(ctx, size / 2 + offset, x, y, z);
15272
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15265
15273
  }
15266
15274
  drawToSvgPath(size, x, y, z) {
15267
- const r = size / 2;
15275
+ const r = this.parseSize(size) / 2;
15268
15276
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15269
15277
  }
15270
15278
  }
@@ -15281,10 +15289,10 @@
15281
15289
  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
15290
  }
15283
15291
  draw(ctx, size, x, y, z) {
15284
- return cross(ctx, size / 6, x, y, z);
15292
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15285
15293
  }
15286
15294
  drawOffset(ctx, size, x, y, offset, z) {
15287
- return crossOffset(ctx, size / 6, x, y, offset, z);
15295
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15288
15296
  }
15289
15297
  }
15290
15298
  var cross$1 = new CrossSymbol();
@@ -15297,13 +15305,13 @@
15297
15305
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15298
15306
  }
15299
15307
  draw(ctx, size, x, y, z) {
15300
- return diamond(ctx, size / 2, x, y, z);
15308
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15301
15309
  }
15302
15310
  drawFitDir(ctx, size, x, y, z) {
15303
- return diamond(ctx, size / 2, x, y, z);
15311
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15304
15312
  }
15305
15313
  drawOffset(ctx, size, x, y, offset, z) {
15306
- return diamond(ctx, size / 2 + offset, x, y, z);
15314
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15307
15315
  }
15308
15316
  }
15309
15317
  var diamond$1 = new DiamondSymbol();
@@ -15317,10 +15325,10 @@
15317
15325
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15318
15326
  }
15319
15327
  draw(ctx, size, x, y) {
15320
- return square(ctx, size / 2, x, y);
15328
+ return square(ctx, this.parseSize(size) / 2, x, y);
15321
15329
  }
15322
15330
  drawOffset(ctx, size, x, y, offset) {
15323
- return square(ctx, size / 2 + offset, x, y);
15331
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15324
15332
  }
15325
15333
  }
15326
15334
  var square$1 = new SquareSymbol();
@@ -15334,10 +15342,10 @@
15334
15342
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15335
15343
  }
15336
15344
  draw(ctx, size, x, y) {
15337
- return trianglUpOffset(ctx, size / 2, x, y);
15345
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15338
15346
  }
15339
15347
  drawOffset(ctx, size, x, y, offset) {
15340
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15348
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15341
15349
  }
15342
15350
  }
15343
15351
  var triangleUp = new TriangleUpSymbol();
@@ -15369,10 +15377,10 @@
15369
15377
  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
15378
  }
15371
15379
  draw(ctx, size, transX, transY) {
15372
- return star(ctx, size / 2, transX, transY);
15380
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15373
15381
  }
15374
15382
  drawOffset(ctx, size, transX, transY, offset) {
15375
- return star(ctx, size / 2 + offset, transX, transY);
15383
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15376
15384
  }
15377
15385
  }
15378
15386
  var star$1 = new StarSymbol();
@@ -15390,10 +15398,10 @@
15390
15398
  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
15399
  }
15392
15400
  draw(ctx, size, transX, transY) {
15393
- return arrow(ctx, size / 2, transX, transY);
15401
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15394
15402
  }
15395
15403
  drawOffset(ctx, size, transX, transY, offset) {
15396
- return arrow(ctx, size / 2 + offset, transX, transY);
15404
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15397
15405
  }
15398
15406
  }
15399
15407
  var arrow$1 = new ArrowSymbol();
@@ -15407,10 +15415,10 @@
15407
15415
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15408
15416
  }
15409
15417
  draw(ctx, size, transX, transY) {
15410
- return wedge(ctx, size / 2, transX, transY);
15418
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15411
15419
  }
15412
15420
  drawOffset(ctx, size, transX, transY, offset) {
15413
- return wedge(ctx, size / 2 + offset, transX, transY);
15421
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15414
15422
  }
15415
15423
  }
15416
15424
  var wedge$1 = new WedgeSymbol();
@@ -15423,10 +15431,10 @@
15423
15431
  super(...arguments), this.type = "stroke", this.pathStr = "";
15424
15432
  }
15425
15433
  draw(ctx, size, transX, transY) {
15426
- return stroke(ctx, size / 2, transX, transY);
15434
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15427
15435
  }
15428
15436
  drawOffset(ctx, size, transX, transY, offset) {
15429
- return stroke(ctx, size / 2 + offset, transX, transY);
15437
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15430
15438
  }
15431
15439
  }
15432
15440
  var stroke$1 = new StrokeSymbol();
@@ -15448,10 +15456,10 @@
15448
15456
  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
15457
  }
15450
15458
  draw(ctx, size, transX, transY) {
15451
- return wye(ctx, size / 2, transX, transY);
15459
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15452
15460
  }
15453
15461
  drawOffset(ctx, size, transX, transY, offset) {
15454
- return wye(ctx, size / 2 + offset, transX, transY);
15462
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15455
15463
  }
15456
15464
  }
15457
15465
  var wye$1 = new WyeSymbol();
@@ -15464,10 +15472,10 @@
15464
15472
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15465
15473
  }
15466
15474
  draw(ctx, size, x, y) {
15467
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15475
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15468
15476
  }
15469
15477
  drawOffset(ctx, size, x, y, offset) {
15470
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15478
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15471
15479
  }
15472
15480
  }
15473
15481
  var triangleLeft = new TriangleLeftSymbol();
@@ -15481,10 +15489,10 @@
15481
15489
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15482
15490
  }
15483
15491
  draw(ctx, size, x, y) {
15484
- return trianglRightOffset(ctx, size / 2, x, y);
15492
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15485
15493
  }
15486
15494
  drawOffset(ctx, size, x, y, offset) {
15487
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15495
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15488
15496
  }
15489
15497
  }
15490
15498
  var triangleRight = new TriangleRightSymbol();
@@ -15498,10 +15506,10 @@
15498
15506
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15499
15507
  }
15500
15508
  draw(ctx, size, x, y) {
15501
- return trianglDownOffset(ctx, size / 2, x, y);
15509
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15502
15510
  }
15503
15511
  drawOffset(ctx, size, x, y, offset) {
15504
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15512
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15505
15513
  }
15506
15514
  }
15507
15515
  var triangleDown = new TriangleDownSymbol();
@@ -15516,10 +15524,10 @@
15516
15524
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15517
15525
  }
15518
15526
  draw(ctx, size, x, y) {
15519
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15527
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15520
15528
  }
15521
15529
  drawOffset(ctx, size, x, y, offset) {
15522
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15530
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15523
15531
  }
15524
15532
  }
15525
15533
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15533,10 +15541,10 @@
15533
15541
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15534
15542
  }
15535
15543
  draw(ctx, size, transX, transY) {
15536
- return arrow2Left(ctx, size / 4, transX, transY);
15544
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15537
15545
  }
15538
15546
  drawOffset(ctx, size, transX, transY, offset) {
15539
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15547
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15540
15548
  }
15541
15549
  }
15542
15550
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15550,10 +15558,10 @@
15550
15558
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15551
15559
  }
15552
15560
  draw(ctx, size, transX, transY) {
15553
- return arrow2Right(ctx, size / 4, transX, transY);
15561
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15554
15562
  }
15555
15563
  drawOffset(ctx, size, transX, transY, offset) {
15556
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15564
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15557
15565
  }
15558
15566
  }
15559
15567
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15567,10 +15575,10 @@
15567
15575
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15568
15576
  }
15569
15577
  draw(ctx, size, transX, transY) {
15570
- return arrow2Up(ctx, size / 4, transX, transY);
15578
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15571
15579
  }
15572
15580
  drawOffset(ctx, size, transX, transY, offset) {
15573
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15581
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15574
15582
  }
15575
15583
  }
15576
15584
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15584,10 +15592,10 @@
15584
15592
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15585
15593
  }
15586
15594
  draw(ctx, size, transX, transY) {
15587
- return arrow2Down(ctx, size / 4, transX, transY);
15595
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15588
15596
  }
15589
15597
  drawOffset(ctx, size, transX, transY, offset) {
15590
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15598
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15591
15599
  }
15592
15600
  }
15593
15601
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15600,13 +15608,13 @@
15600
15608
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15601
15609
  }
15602
15610
  draw(ctx, size, x, y, z) {
15603
- return lineV(ctx, size / 2, x, y);
15611
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15604
15612
  }
15605
15613
  drawOffset(ctx, size, x, y, offset, z) {
15606
- return lineV(ctx, size / 2 + offset, x, y);
15614
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15607
15615
  }
15608
15616
  drawToSvgPath(size, x, y, z) {
15609
- const r = size / 2;
15617
+ const r = this.parseSize(size) / 2;
15610
15618
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15611
15619
  }
15612
15620
  }
@@ -15620,13 +15628,13 @@
15620
15628
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15621
15629
  }
15622
15630
  draw(ctx, size, x, y, z) {
15623
- return lineH(ctx, size / 2, x, y);
15631
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15624
15632
  }
15625
15633
  drawOffset(ctx, size, x, y, offset, z) {
15626
- return lineH(ctx, size / 2 + offset, x, y);
15634
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15627
15635
  }
15628
15636
  drawToSvgPath(size, x, y, z) {
15629
- const r = size / 2;
15637
+ const r = this.parseSize(size) / 2;
15630
15638
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15631
15639
  }
15632
15640
  }
@@ -15640,13 +15648,13 @@
15640
15648
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15641
15649
  }
15642
15650
  draw(ctx, size, x, y, z) {
15643
- return close(ctx, size / 2, x, y);
15651
+ return close(ctx, this.parseSize(size) / 2, x, y);
15644
15652
  }
15645
15653
  drawOffset(ctx, size, x, y, offset, z) {
15646
- return close(ctx, size / 2 + offset, x, y);
15654
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15647
15655
  }
15648
15656
  drawToSvgPath(size, x, y, z) {
15649
- const r = size / 2;
15657
+ const r = this.parseSize(size) / 2;
15650
15658
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15651
15659
  }
15652
15660
  }
@@ -15680,15 +15688,18 @@
15680
15688
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15681
15689
  }
15682
15690
  drawOffset(ctx, size, x, y, offset, z, cb) {
15683
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15691
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15684
15692
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15685
15693
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15686
15694
  }
15687
15695
  draw(ctx, size, x, y, z, cb) {
15688
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15696
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15697
+ }
15698
+ parseSize(size) {
15699
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15689
15700
  }
15690
15701
  bounds(size, bounds) {
15691
- if (this.isSvg) {
15702
+ if (size = this.parseSize(size), this.isSvg) {
15692
15703
  if (!this.svgCache) return;
15693
15704
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15694
15705
  let {
@@ -16371,7 +16382,11 @@
16371
16382
  case "sub":
16372
16383
  baseline += this.descent / 2;
16373
16384
  }
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();
16385
+ "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);
16386
+ const {
16387
+ lineWidth = 1
16388
+ } = this.character;
16389
+ 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
16390
  }
16376
16391
  getWidthWithEllips(direction) {
16377
16392
  let text = this.text;
@@ -16594,12 +16609,18 @@
16594
16609
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16595
16610
  }
16596
16611
  }
16597
- this.paragraphs.map((paragraph, index) => {
16612
+ this.paragraphs.forEach((paragraph, index) => {
16598
16613
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
16599
16614
  x: x + paragraph._x,
16600
16615
  y: y + paragraph._y
16601
16616
  }), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
16602
- paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16617
+ const b = {
16618
+ x1: this.left,
16619
+ y1: this.top,
16620
+ x2: this.left + this.actualWidth,
16621
+ y2: this.top + this.height
16622
+ };
16623
+ applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16603
16624
  });
16604
16625
  }
16605
16626
  getWidthWithEllips(ellipsis) {
@@ -16622,7 +16643,7 @@
16622
16643
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16623
16644
  }
16624
16645
  let width = 0;
16625
- return this.paragraphs.map((paragraph, index) => {
16646
+ return this.paragraphs.forEach((paragraph, index) => {
16626
16647
  width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
16627
16648
  }), width;
16628
16649
  }
@@ -28614,7 +28635,7 @@
28614
28635
 
28615
28636
  const roughModule = _roughModule;
28616
28637
 
28617
- const version = "0.20.15";
28638
+ const version = "0.20.16";
28618
28639
  preLoadAllModule();
28619
28640
  if (isBrowserEnv()) {
28620
28641
  loadBrowserEnv(container);