@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.es.js CHANGED
@@ -4143,6 +4143,292 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
4143
4143
  class Application {}
4144
4144
  const application = new Application();
4145
4145
 
4146
+ const parse = function () {
4147
+ const tokens = {
4148
+ linearGradient: /^(linear\-gradient)/i,
4149
+ radialGradient: /^(radial\-gradient)/i,
4150
+ conicGradient: /^(conic\-gradient)/i,
4151
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
4152
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
4153
+ positionKeywords: /^(left|center|right|top|bottom)/i,
4154
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
4155
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
4156
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
4157
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4158
+ fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4159
+ startCall: /^\(/,
4160
+ endCall: /^\)/,
4161
+ comma: /^,/,
4162
+ hexColor: /(^\#[0-9a-fA-F]+)/,
4163
+ literalColor: /^([a-zA-Z]+)/,
4164
+ rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
4165
+ rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
4166
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
4167
+ };
4168
+ let input = "";
4169
+ function error(msg) {
4170
+ const err = new Error(input + ": " + msg);
4171
+ throw err.source = input, err;
4172
+ }
4173
+ function getAST() {
4174
+ const ast = matchListing(matchDefinition);
4175
+ return input.length > 0 && error("Invalid input not EOF"), ast;
4176
+ }
4177
+ function matchDefinition() {
4178
+ return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
4179
+ }
4180
+ function matchGradient(gradientType, pattern, orientationMatcher) {
4181
+ return function (pattern, callback) {
4182
+ const captures = scan(pattern);
4183
+ if (captures) {
4184
+ scan(tokens.startCall) || error("Missing (");
4185
+ const result = callback(captures);
4186
+ return scan(tokens.endCall) || error("Missing )"), result;
4187
+ }
4188
+ }(pattern, function (captures) {
4189
+ const orientation = orientationMatcher();
4190
+ return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
4191
+ type: gradientType,
4192
+ orientation: orientation,
4193
+ colorStops: matchListing(matchColorStop)
4194
+ };
4195
+ });
4196
+ }
4197
+ function matchLinearOrientation() {
4198
+ return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
4199
+ }
4200
+ function matchConicalOrientation() {
4201
+ return match("angular", tokens.fromAngleValue, 1);
4202
+ }
4203
+ function matchListRadialOrientations() {
4204
+ let radialOrientations,
4205
+ lookaheadCache,
4206
+ radialOrientation = matchRadialOrientation();
4207
+ return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
4208
+ }
4209
+ function matchRadialOrientation() {
4210
+ let radialType = function () {
4211
+ const circle = match("shape", /^(circle)/i, 0);
4212
+ circle && (circle.style = matchLength() || matchExtentKeyword());
4213
+ return circle;
4214
+ }() || function () {
4215
+ const ellipse = match("shape", /^(ellipse)/i, 0);
4216
+ ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
4217
+ return ellipse;
4218
+ }();
4219
+ if (radialType) radialType.at = matchAtPosition();else {
4220
+ const extent = matchExtentKeyword();
4221
+ if (extent) {
4222
+ radialType = extent;
4223
+ const positionAt = matchAtPosition();
4224
+ positionAt && (radialType.at = positionAt);
4225
+ } else {
4226
+ const defaultPosition = matchPositioning();
4227
+ defaultPosition && (radialType = {
4228
+ type: "default-radial",
4229
+ at: defaultPosition
4230
+ });
4231
+ }
4232
+ }
4233
+ return radialType;
4234
+ }
4235
+ function matchExtentKeyword() {
4236
+ return match("extent-keyword", tokens.extentKeywords, 1);
4237
+ }
4238
+ function matchAtPosition() {
4239
+ if (match("position", /^at/, 0)) {
4240
+ const positioning = matchPositioning();
4241
+ return positioning || error("Missing positioning value"), positioning;
4242
+ }
4243
+ }
4244
+ function matchPositioning() {
4245
+ const location = {
4246
+ x: matchDistance(),
4247
+ y: matchDistance()
4248
+ };
4249
+ if (location.x || location.y) return {
4250
+ type: "position",
4251
+ value: location
4252
+ };
4253
+ }
4254
+ function matchListing(matcher) {
4255
+ let captures = matcher();
4256
+ const result = [];
4257
+ if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
4258
+ return result;
4259
+ }
4260
+ function matchColorStop() {
4261
+ const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
4262
+ return color || error("Expected color definition"), color.length = matchDistance(), color;
4263
+ }
4264
+ function matchDistance() {
4265
+ return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
4266
+ }
4267
+ function matchLength() {
4268
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
4269
+ }
4270
+ function match(type, pattern, captureIndex) {
4271
+ const captures = scan(pattern);
4272
+ if (captures) return {
4273
+ type: type,
4274
+ value: captures[captureIndex]
4275
+ };
4276
+ }
4277
+ function scan(regexp) {
4278
+ const blankCaptures = /^[\n\r\t\s]+/.exec(input);
4279
+ blankCaptures && consume(blankCaptures[0].length);
4280
+ const captures = regexp.exec(input);
4281
+ return captures && consume(captures[0].length), captures;
4282
+ }
4283
+ function consume(size) {
4284
+ input = input.substr(size);
4285
+ }
4286
+ return function (code) {
4287
+ return input = code.toString(), getAST();
4288
+ };
4289
+ }();
4290
+ class GradientParser {
4291
+ static IsGradient(c) {
4292
+ return !("string" == typeof c && !c.includes("gradient"));
4293
+ }
4294
+ static IsGradientStr(c) {
4295
+ return "string" == typeof c && c.includes("gradient");
4296
+ }
4297
+ static Parse(c) {
4298
+ if (GradientParser.IsGradientStr(c)) try {
4299
+ const datum = parse(c)[0];
4300
+ if (datum) {
4301
+ if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
4302
+ if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
4303
+ if ("conic" === datum.type) return GradientParser.ParseConic(datum);
4304
+ }
4305
+ } catch (err) {
4306
+ return c;
4307
+ }
4308
+ return c;
4309
+ }
4310
+ static ParseConic(datum) {
4311
+ const {
4312
+ orientation: orientation,
4313
+ colorStops = []
4314
+ } = datum,
4315
+ halfPi = pi / 2,
4316
+ sa = parseFloat(orientation.value) / 180 * pi - halfPi;
4317
+ return {
4318
+ gradient: "conical",
4319
+ x: .5,
4320
+ y: .5,
4321
+ startAngle: sa,
4322
+ endAngle: sa + pi2,
4323
+ stops: colorStops.map(item => ({
4324
+ color: item.value,
4325
+ offset: parseFloat(item.length.value) / 100
4326
+ }))
4327
+ };
4328
+ }
4329
+ static ParseRadial(datum) {
4330
+ const {
4331
+ colorStops = []
4332
+ } = datum;
4333
+ return {
4334
+ gradient: "radial",
4335
+ x0: .5,
4336
+ y0: .5,
4337
+ x1: .5,
4338
+ y1: .5,
4339
+ r0: 0,
4340
+ r1: 1,
4341
+ stops: colorStops.map(item => ({
4342
+ color: item.value,
4343
+ offset: parseFloat(item.length.value) / 100
4344
+ }))
4345
+ };
4346
+ }
4347
+ static ParseLinear(datum) {
4348
+ const {
4349
+ orientation: orientation,
4350
+ colorStops = []
4351
+ } = datum,
4352
+ halfPi = pi / 2;
4353
+ let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
4354
+ for (; angle < 0;) angle += pi2;
4355
+ for (; angle >= pi2;) angle -= pi2;
4356
+ let x0 = 0,
4357
+ y0 = 0,
4358
+ x1 = 0,
4359
+ y1 = 0;
4360
+ 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)), {
4361
+ gradient: "linear",
4362
+ x0: x0,
4363
+ y0: y0,
4364
+ x1: x1,
4365
+ y1: y1,
4366
+ stops: colorStops.map(item => ({
4367
+ color: item.value,
4368
+ offset: parseFloat(item.length.value) / 100
4369
+ }))
4370
+ };
4371
+ }
4372
+ }
4373
+
4374
+ function getScaledStroke(context, width, dpr) {
4375
+ let strokeWidth = width;
4376
+ const {
4377
+ a: a,
4378
+ b: b,
4379
+ c: c,
4380
+ d: d
4381
+ } = context.currentMatrix,
4382
+ scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
4383
+ scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
4384
+ return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
4385
+ }
4386
+ function createColor(context, c, params) {
4387
+ let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4388
+ let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4389
+ if (!c || !0 === c) return "black";
4390
+ let result, color;
4391
+ if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
4392
+ if (color = GradientParser.Parse(color), "string" == typeof color) return color;
4393
+ if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
4394
+ const bounds = params.AABBBounds;
4395
+ let w = bounds.x2 - bounds.x1,
4396
+ h = bounds.y2 - bounds.y1,
4397
+ x = bounds.x1 - offsetX,
4398
+ y = bounds.y1 - offsetY;
4399
+ if (params.attribute) {
4400
+ const {
4401
+ scaleX = 1,
4402
+ scaleY = 1
4403
+ } = params.attribute;
4404
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
4405
+ }
4406
+ "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));
4407
+ }
4408
+ return result || "orange";
4409
+ }
4410
+ function createLinearGradient(context, color, x, y, w, h) {
4411
+ var _a, _b, _c, _d;
4412
+ 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);
4413
+ return color.stops.forEach(stop => {
4414
+ canvasGradient.addColorStop(stop.offset, stop.color);
4415
+ }), canvasGradient;
4416
+ }
4417
+ function createRadialGradient(context, color, x, y, w, h) {
4418
+ var _a, _b, _c, _d, _e, _f;
4419
+ 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));
4420
+ return color.stops.forEach(stop => {
4421
+ canvasGradient.addColorStop(stop.offset, stop.color);
4422
+ }), canvasGradient;
4423
+ }
4424
+ function createConicGradient(context, color, x, y, w, h) {
4425
+ var _a, _b;
4426
+ 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);
4427
+ return color.stops.forEach(stop => {
4428
+ canvasGradient.addColorStop(stop.offset, stop.color);
4429
+ }), canvasGradient.GetPattern(w + x, h + y, undefined);
4430
+ }
4431
+
4146
4432
  const DIRECTION_KEY = {
4147
4433
  horizontal: {
4148
4434
  width: "width",
@@ -4194,14 +4480,16 @@ const setTextStyle = (ctx, character) => {
4194
4480
  fontFamily: character.fontFamily || "sans-serif"
4195
4481
  });
4196
4482
  };
4197
- function applyFillStyle(ctx, character) {
4483
+ function applyFillStyle(ctx, character, b) {
4198
4484
  const fillStyle = character && character.fill || defaultFormatting.fill;
4199
4485
  if (!fillStyle) return void (ctx.globalAlpha = 0);
4200
4486
  const {
4201
4487
  fillOpacity = 1,
4202
4488
  opacity = 1
4203
4489
  } = character;
4204
- ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
4490
+ ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
4491
+ AABBBounds: b
4492
+ }) : fillStyle, setTextStyle(ctx, character);
4205
4493
  }
4206
4494
  function applyStrokeStyle(ctx, character) {
4207
4495
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
@@ -11113,697 +11401,411 @@ class DefaultMatrixAllocate {
11113
11401
  allocate(a, b, c, d, e, f) {
11114
11402
  if (!this.pools.length) return new Matrix(a, b, c, d, e, f);
11115
11403
  const m = this.pools.pop();
11116
- return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
11117
- }
11118
- allocateByObj(matrix) {
11119
- if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
11120
- const m = this.pools.pop();
11121
- 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;
11122
- }
11123
- free(d) {
11124
- this.pools.push(d);
11125
- }
11126
- get length() {
11127
- return this.pools.length;
11128
- }
11129
- release() {
11130
- this.pools = [];
11131
- }
11132
- }
11133
- class DefaultMat4Allocate {
11134
- constructor() {
11135
- this.pools = [];
11136
- }
11137
- static identity(out) {
11138
- return identityMat4(out);
11139
- }
11140
- allocate() {
11141
- if (!this.pools.length) return createMat4();
11142
- const m = this.pools.pop();
11143
- return DefaultMat4Allocate.identity(m), m;
11144
- }
11145
- allocateByObj(d) {
11146
- let m;
11147
- m = this.pools.length ? this.pools.pop() : createMat4();
11148
- for (let i = 0; i < m.length; i++) m[i] = d[i];
11149
- return m;
11150
- }
11151
- free(m) {
11152
- m && this.pools.push(m);
11153
- }
11154
- get length() {
11155
- return this.pools.length;
11156
- }
11157
- release() {
11158
- this.pools = [];
11159
- }
11160
- }
11161
- const matrixAllocate = new DefaultMatrixAllocate();
11162
- const mat4Allocate = new DefaultMat4Allocate();
11163
-
11164
- var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
11165
- var d,
11166
- c = arguments.length,
11167
- r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
11168
- 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);
11169
- return c > 3 && r && Object.defineProperty(target, key, r), r;
11170
- },
11171
- __metadata$1d = undefined && undefined.__metadata || function (k, v) {
11172
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11173
- },
11174
- __param$R = undefined && undefined.__param || function (paramIndex, decorator) {
11175
- return function (target, key) {
11176
- decorator(target, key, paramIndex);
11177
- };
11178
- };
11179
- function getExtraModelMatrix(dx, dy, graphic) {
11180
- const {
11181
- alpha: alpha,
11182
- beta: beta
11183
- } = graphic.attribute;
11184
- if (!alpha && !beta) return null;
11185
- const {
11186
- anchor3d = graphic.attribute.anchor
11187
- } = graphic.attribute,
11188
- _anchor = [0, 0];
11189
- if (anchor3d) {
11190
- if ("string" == typeof anchor3d[0]) {
11191
- const ratio = parseFloat(anchor3d[0]) / 100,
11192
- bounds = graphic.AABBBounds;
11193
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11194
- } else _anchor[0] = anchor3d[0];
11195
- if ("string" == typeof anchor3d[1]) {
11196
- const ratio = parseFloat(anchor3d[1]) / 100,
11197
- bounds = graphic.AABBBounds;
11198
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11199
- } else _anchor[1] = anchor3d[1];
11200
- }
11201
- if ("text" === graphic.type) {
11202
- const {
11203
- textAlign: textAlign
11204
- } = graphic.attribute;
11205
- _anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
11206
- }
11207
- _anchor[0] += dx, _anchor[1] += dy;
11208
- const modelMatrix = mat4Allocate.allocate();
11209
- 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;
11210
- }
11211
- function getModelMatrix(out, graphic, theme) {
11212
- var _a;
11213
- const {
11214
- x = theme.x,
11215
- y = theme.y,
11216
- z = theme.z,
11217
- dx = theme.dx,
11218
- dy = theme.dy,
11219
- dz = theme.dz,
11220
- scaleX = theme.scaleX,
11221
- scaleY = theme.scaleY,
11222
- scaleZ = theme.scaleZ,
11223
- alpha = theme.alpha,
11224
- beta = theme.beta,
11225
- angle = theme.angle,
11226
- anchor3d = graphic.attribute.anchor,
11227
- anchor: anchor
11228
- } = graphic.attribute,
11229
- _anchor = [0, 0, 0];
11230
- if (anchor3d) {
11231
- if ("string" == typeof anchor3d[0]) {
11232
- const ratio = parseFloat(anchor3d[0]) / 100,
11233
- bounds = graphic.AABBBounds;
11234
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11235
- } else _anchor[0] = anchor3d[0];
11236
- if ("string" == typeof anchor3d[1]) {
11237
- const ratio = parseFloat(anchor3d[1]) / 100,
11238
- bounds = graphic.AABBBounds;
11239
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11240
- } else _anchor[1] = anchor3d[1];
11241
- _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
11242
- }
11243
- 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) {
11244
- const m = mat4Allocate.allocate(),
11245
- _anchor = [0, 0];
11246
- if (anchor) {
11247
- if ("string" == typeof anchor3d[0]) {
11248
- const ratio = parseFloat(anchor3d[0]) / 100,
11249
- bounds = graphic.AABBBounds;
11250
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11251
- } else _anchor[0] = anchor3d[0];
11252
- if ("string" == typeof anchor3d[1]) {
11253
- const ratio = parseFloat(anchor3d[1]) / 100,
11254
- bounds = graphic.AABBBounds;
11255
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11256
- } else _anchor[1] = anchor3d[1];
11257
- }
11258
- translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
11259
- }
11260
- }
11261
- function shouldUseMat4(graphic) {
11262
- const {
11263
- alpha: alpha,
11264
- beta: beta
11265
- } = graphic.attribute;
11266
- return alpha || beta;
11267
- }
11268
- let DefaultGraphicService = class {
11269
- constructor(creator) {
11270
- this.creator = creator, this.hooks = {
11271
- onAttributeUpdate: new SyncHook(["graphic"]),
11272
- onSetStage: new SyncHook(["graphic", "stage"]),
11273
- onRemove: new SyncHook(["graphic"]),
11274
- onRelease: new SyncHook(["graphic"]),
11275
- onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
11276
- onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
11277
- beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
11278
- afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
11279
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
11280
- }
11281
- onAttributeUpdate(graphic) {
11282
- this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
11283
- }
11284
- onSetStage(graphic, stage) {
11285
- this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
11286
- }
11287
- onRemove(graphic) {
11288
- this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
11289
- }
11290
- onRelease(graphic) {
11291
- this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
11292
- }
11293
- onAddIncremental(graphic, group, stage) {
11294
- this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
11295
- }
11296
- onClearIncremental(group, stage) {
11297
- this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
11298
- }
11299
- beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
11300
- this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
11301
- }
11302
- afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
11303
- this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
11304
- }
11305
- updatePathProxyAABBBounds(aabbBounds, graphic) {
11306
- const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
11307
- if (!path) return !1;
11308
- const boundsContext = new BoundsContext(aabbBounds);
11309
- return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
11310
- }
11311
- updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
11312
- const {
11313
- textAlign: textAlign,
11314
- textBaseline: textBaseline
11315
- } = attribute;
11316
- if (null != attribute.forceBoundsHeight) {
11317
- const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
11318
- dy = textLayoutOffsetY(textBaseline, h, h);
11319
- aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
11320
- }
11321
- if (null != attribute.forceBoundsWidth) {
11322
- const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
11323
- dx = textDrawOffsetX(textAlign, w);
11324
- aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
11325
- }
11326
- }
11327
- combindShadowAABBBounds(bounds, graphic) {
11328
- if (graphic && graphic.shadowRoot) {
11329
- const b = graphic.shadowRoot.AABBBounds;
11330
- bounds.union(b);
11331
- }
11332
- }
11333
- transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
11334
- if (!aabbBounds.empty()) {
11335
- const {
11336
- scaleX = theme.scaleX,
11337
- scaleY = theme.scaleY,
11338
- stroke = theme.stroke,
11339
- shadowBlur = theme.shadowBlur,
11340
- lineWidth = theme.lineWidth,
11341
- pickStrokeBuffer = theme.pickStrokeBuffer,
11342
- strokeBoundsBuffer = theme.strokeBoundsBuffer
11343
- } = attribute,
11344
- tb1 = this.tempAABBBounds1,
11345
- tb2 = this.tempAABBBounds2;
11346
- if (stroke && lineWidth) {
11347
- const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
11348
- boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
11349
- }
11350
- if (shadowBlur) {
11351
- const {
11352
- shadowOffsetX = theme.shadowOffsetX,
11353
- shadowOffsetY = theme.shadowOffsetY
11354
- } = attribute,
11355
- shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
11356
- boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
11357
- }
11358
- }
11359
- if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
11360
- let updateMatrix = !0;
11361
- const m = graphic.transMatrix;
11362
- 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);
11404
+ return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
11363
11405
  }
11364
- validCheck(attribute, theme, aabbBounds, graphic) {
11365
- if (!graphic) return !0;
11366
- if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
11367
- if (graphic.shadowRoot) return !0;
11368
- if (!graphic.valid) return aabbBounds.clear(), !1;
11369
- const {
11370
- visible = theme.visible
11371
- } = attribute;
11372
- return !!visible || (aabbBounds.clear(), !1);
11406
+ allocateByObj(matrix) {
11407
+ if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
11408
+ const m = this.pools.pop();
11409
+ 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;
11373
11410
  }
11374
- updateTempAABBBounds(aabbBounds) {
11375
- const tb1 = this.tempAABBBounds1,
11376
- tb2 = this.tempAABBBounds2;
11377
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
11378
- tb1: tb1,
11379
- tb2: tb2
11380
- };
11411
+ free(d) {
11412
+ this.pools.push(d);
11381
11413
  }
11382
- };
11383
- DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], DefaultGraphicService);
11384
-
11385
- const result = {
11386
- x: 0,
11387
- y: 0,
11388
- z: 0,
11389
- lastModelMatrix: null
11390
- };
11391
- class BaseRender {
11392
- init(contributions) {
11393
- 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 === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
11414
+ get length() {
11415
+ return this.pools.length;
11394
11416
  }
11395
- beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11396
- this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
11397
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11398
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11399
- }
11400
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11401
- });
11417
+ release() {
11418
+ this.pools = [];
11402
11419
  }
11403
- afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11404
- this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
11405
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11406
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11407
- }
11408
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11409
- });
11420
+ }
11421
+ class DefaultMat4Allocate {
11422
+ constructor() {
11423
+ this.pools = [];
11410
11424
  }
11411
- valid(graphic, defaultAttribute, fillCb, strokeCb) {
11412
- const {
11413
- fill = defaultAttribute.fill,
11414
- background: background,
11415
- stroke = defaultAttribute.stroke,
11416
- opacity = defaultAttribute.opacity,
11417
- fillOpacity = defaultAttribute.fillOpacity,
11418
- lineWidth = defaultAttribute.lineWidth,
11419
- strokeOpacity = defaultAttribute.strokeOpacity,
11420
- visible = defaultAttribute.visible
11421
- } = graphic.attribute,
11422
- fVisible = fillVisible(opacity, fillOpacity, fill),
11423
- sVisible = strokeVisible(opacity, strokeOpacity),
11424
- doFill = runFill(fill, background),
11425
- doStroke = runStroke(stroke, lineWidth);
11426
- return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
11427
- fVisible: fVisible,
11428
- sVisible: sVisible,
11429
- doFill: doFill,
11430
- doStroke: doStroke
11431
- };
11425
+ static identity(out) {
11426
+ return identityMat4(out);
11432
11427
  }
11433
- transform(graphic, graphicAttribute, context) {
11434
- let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
11435
- const {
11436
- x = graphicAttribute.x,
11437
- y = graphicAttribute.y,
11438
- z = graphicAttribute.z,
11439
- scaleX = graphicAttribute.scaleX,
11440
- scaleY = graphicAttribute.scaleY,
11441
- angle = graphicAttribute.angle,
11442
- postMatrix: postMatrix
11443
- } = graphic.attribute,
11444
- lastModelMatrix = context.modelMatrix,
11445
- camera = context.camera;
11446
- result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
11447
- const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
11448
- onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
11449
- if (shouldTransform3d) {
11450
- const nextModelMatrix = mat4Allocate.allocate(),
11451
- modelMatrix = mat4Allocate.allocate();
11452
- 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);
11453
- }
11454
- if (onlyTranslate && !lastModelMatrix) {
11455
- const point = graphic.getOffsetXY(graphicAttribute);
11456
- result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
11457
- } 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) {
11458
- const point = graphic.getOffsetXY(graphicAttribute);
11459
- result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
11460
- } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
11461
- return result;
11428
+ allocate() {
11429
+ if (!this.pools.length) return createMat4();
11430
+ const m = this.pools.pop();
11431
+ return DefaultMat4Allocate.identity(m), m;
11462
11432
  }
11463
- transformUseContext2d(graphic, graphicAttribute, z, context) {
11464
- const camera = context.camera;
11465
- if (this.camera = camera, camera) {
11466
- const bounds = graphic.AABBBounds,
11467
- width = bounds.x2 - bounds.x1,
11468
- height = bounds.y2 - bounds.y1,
11469
- p1 = context.project(0, 0, z),
11470
- p2 = context.project(width, 0, z),
11471
- p3 = context.project(width, height, z),
11472
- _p1 = {
11473
- x: 0,
11474
- y: 0
11475
- },
11476
- _p2 = {
11477
- x: width,
11478
- y: 0
11479
- },
11480
- _p3 = {
11481
- x: width,
11482
- y: height
11483
- };
11484
- context.camera = null;
11485
- const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
11486
- m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
11487
- m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
11488
- m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
11489
- m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
11490
- 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,
11491
- 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;
11492
- context.setTransform(m11, m12, m21, m22, dx, dy, !0);
11493
- }
11433
+ allocateByObj(d) {
11434
+ let m;
11435
+ m = this.pools.length ? this.pools.pop() : createMat4();
11436
+ for (let i = 0; i < m.length; i++) m[i] = d[i];
11437
+ return m;
11494
11438
  }
11495
- restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11496
- this.camera && (context.camera = this.camera);
11439
+ free(m) {
11440
+ m && this.pools.push(m);
11497
11441
  }
11498
- transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
11499
- const p = context.project(x, y, z);
11500
- 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();
11442
+ get length() {
11443
+ return this.pools.length;
11501
11444
  }
11502
- _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11503
- const {
11504
- context: context
11505
- } = drawContext;
11506
- if (!context) return;
11445
+ release() {
11446
+ this.pools = [];
11447
+ }
11448
+ }
11449
+ const matrixAllocate = new DefaultMatrixAllocate();
11450
+ const mat4Allocate = new DefaultMat4Allocate();
11451
+
11452
+ var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
11453
+ var d,
11454
+ c = arguments.length,
11455
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
11456
+ 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);
11457
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11458
+ },
11459
+ __metadata$1d = undefined && undefined.__metadata || function (k, v) {
11460
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
11461
+ },
11462
+ __param$R = undefined && undefined.__param || function (paramIndex, decorator) {
11463
+ return function (target, key) {
11464
+ decorator(target, key, paramIndex);
11465
+ };
11466
+ };
11467
+ function getExtraModelMatrix(dx, dy, graphic) {
11468
+ const {
11469
+ alpha: alpha,
11470
+ beta: beta
11471
+ } = graphic.attribute;
11472
+ if (!alpha && !beta) return null;
11473
+ const {
11474
+ anchor3d = graphic.attribute.anchor
11475
+ } = graphic.attribute,
11476
+ _anchor = [0, 0];
11477
+ if (anchor3d) {
11478
+ if ("string" == typeof anchor3d[0]) {
11479
+ const ratio = parseFloat(anchor3d[0]) / 100,
11480
+ bounds = graphic.AABBBounds;
11481
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11482
+ } else _anchor[0] = anchor3d[0];
11483
+ if ("string" == typeof anchor3d[1]) {
11484
+ const ratio = parseFloat(anchor3d[1]) / 100,
11485
+ bounds = graphic.AABBBounds;
11486
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11487
+ } else _anchor[1] = anchor3d[1];
11488
+ }
11489
+ if ("text" === graphic.type) {
11507
11490
  const {
11508
- renderable: renderable
11491
+ textAlign: textAlign
11509
11492
  } = graphic.attribute;
11510
- if (!1 === renderable) return;
11511
- context.highPerformanceSave();
11512
- const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
11513
- {
11514
- x: x,
11515
- y: y,
11516
- z: z,
11517
- lastModelMatrix: lastModelMatrix
11518
- } = data;
11519
- 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();
11493
+ _anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
11494
+ }
11495
+ _anchor[0] += dx, _anchor[1] += dy;
11496
+ const modelMatrix = mat4Allocate.allocate();
11497
+ 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;
11498
+ }
11499
+ function getModelMatrix(out, graphic, theme) {
11500
+ var _a;
11501
+ const {
11502
+ x = theme.x,
11503
+ y = theme.y,
11504
+ z = theme.z,
11505
+ dx = theme.dx,
11506
+ dy = theme.dy,
11507
+ dz = theme.dz,
11508
+ scaleX = theme.scaleX,
11509
+ scaleY = theme.scaleY,
11510
+ scaleZ = theme.scaleZ,
11511
+ alpha = theme.alpha,
11512
+ beta = theme.beta,
11513
+ angle = theme.angle,
11514
+ anchor3d = graphic.attribute.anchor,
11515
+ anchor: anchor
11516
+ } = graphic.attribute,
11517
+ _anchor = [0, 0, 0];
11518
+ if (anchor3d) {
11519
+ if ("string" == typeof anchor3d[0]) {
11520
+ const ratio = parseFloat(anchor3d[0]) / 100,
11521
+ bounds = graphic.AABBBounds;
11522
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11523
+ } else _anchor[0] = anchor3d[0];
11524
+ if ("string" == typeof anchor3d[1]) {
11525
+ const ratio = parseFloat(anchor3d[1]) / 100,
11526
+ bounds = graphic.AABBBounds;
11527
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11528
+ } else _anchor[1] = anchor3d[1];
11529
+ _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
11520
11530
  }
11521
- }
11522
-
11523
- const parse = function () {
11524
- const tokens = {
11525
- linearGradient: /^(linear\-gradient)/i,
11526
- radialGradient: /^(radial\-gradient)/i,
11527
- conicGradient: /^(conic\-gradient)/i,
11528
- sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
11529
- extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
11530
- positionKeywords: /^(left|center|right|top|bottom)/i,
11531
- pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
11532
- percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
11533
- emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
11534
- angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
11535
- fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
11536
- startCall: /^\(/,
11537
- endCall: /^\)/,
11538
- comma: /^,/,
11539
- hexColor: /(^\#[0-9a-fA-F]+)/,
11540
- literalColor: /^([a-zA-Z]+)/,
11541
- rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
11542
- rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
11543
- number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
11544
- };
11545
- let input = "";
11546
- function error(msg) {
11547
- const err = new Error(input + ": " + msg);
11548
- throw err.source = input, err;
11531
+ 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) {
11532
+ const m = mat4Allocate.allocate(),
11533
+ _anchor = [0, 0];
11534
+ if (anchor) {
11535
+ if ("string" == typeof anchor3d[0]) {
11536
+ const ratio = parseFloat(anchor3d[0]) / 100,
11537
+ bounds = graphic.AABBBounds;
11538
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11539
+ } else _anchor[0] = anchor3d[0];
11540
+ if ("string" == typeof anchor3d[1]) {
11541
+ const ratio = parseFloat(anchor3d[1]) / 100,
11542
+ bounds = graphic.AABBBounds;
11543
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
11544
+ } else _anchor[1] = anchor3d[1];
11545
+ }
11546
+ translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
11549
11547
  }
11550
- function getAST() {
11551
- const ast = matchListing(matchDefinition);
11552
- return input.length > 0 && error("Invalid input not EOF"), ast;
11548
+ }
11549
+ function shouldUseMat4(graphic) {
11550
+ const {
11551
+ alpha: alpha,
11552
+ beta: beta
11553
+ } = graphic.attribute;
11554
+ return alpha || beta;
11555
+ }
11556
+ let DefaultGraphicService = class {
11557
+ constructor(creator) {
11558
+ this.creator = creator, this.hooks = {
11559
+ onAttributeUpdate: new SyncHook(["graphic"]),
11560
+ onSetStage: new SyncHook(["graphic", "stage"]),
11561
+ onRemove: new SyncHook(["graphic"]),
11562
+ onRelease: new SyncHook(["graphic"]),
11563
+ onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
11564
+ onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
11565
+ beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
11566
+ afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
11567
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
11553
11568
  }
11554
- function matchDefinition() {
11555
- return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
11569
+ onAttributeUpdate(graphic) {
11570
+ this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
11556
11571
  }
11557
- function matchGradient(gradientType, pattern, orientationMatcher) {
11558
- return function (pattern, callback) {
11559
- const captures = scan(pattern);
11560
- if (captures) {
11561
- scan(tokens.startCall) || error("Missing (");
11562
- const result = callback(captures);
11563
- return scan(tokens.endCall) || error("Missing )"), result;
11564
- }
11565
- }(pattern, function (captures) {
11566
- const orientation = orientationMatcher();
11567
- return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
11568
- type: gradientType,
11569
- orientation: orientation,
11570
- colorStops: matchListing(matchColorStop)
11571
- };
11572
- });
11572
+ onSetStage(graphic, stage) {
11573
+ this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
11573
11574
  }
11574
- function matchLinearOrientation() {
11575
- return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
11575
+ onRemove(graphic) {
11576
+ this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
11576
11577
  }
11577
- function matchConicalOrientation() {
11578
- return match("angular", tokens.fromAngleValue, 1);
11578
+ onRelease(graphic) {
11579
+ this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
11579
11580
  }
11580
- function matchListRadialOrientations() {
11581
- let radialOrientations,
11582
- lookaheadCache,
11583
- radialOrientation = matchRadialOrientation();
11584
- return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
11581
+ onAddIncremental(graphic, group, stage) {
11582
+ this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
11585
11583
  }
11586
- function matchRadialOrientation() {
11587
- let radialType = function () {
11588
- const circle = match("shape", /^(circle)/i, 0);
11589
- circle && (circle.style = matchLength() || matchExtentKeyword());
11590
- return circle;
11591
- }() || function () {
11592
- const ellipse = match("shape", /^(ellipse)/i, 0);
11593
- ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
11594
- return ellipse;
11595
- }();
11596
- if (radialType) radialType.at = matchAtPosition();else {
11597
- const extent = matchExtentKeyword();
11598
- if (extent) {
11599
- radialType = extent;
11600
- const positionAt = matchAtPosition();
11601
- positionAt && (radialType.at = positionAt);
11602
- } else {
11603
- const defaultPosition = matchPositioning();
11604
- defaultPosition && (radialType = {
11605
- type: "default-radial",
11606
- at: defaultPosition
11607
- });
11608
- }
11609
- }
11610
- return radialType;
11584
+ onClearIncremental(group, stage) {
11585
+ this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
11611
11586
  }
11612
- function matchExtentKeyword() {
11613
- return match("extent-keyword", tokens.extentKeywords, 1);
11587
+ beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
11588
+ this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
11614
11589
  }
11615
- function matchAtPosition() {
11616
- if (match("position", /^at/, 0)) {
11617
- const positioning = matchPositioning();
11618
- return positioning || error("Missing positioning value"), positioning;
11619
- }
11590
+ afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
11591
+ this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
11620
11592
  }
11621
- function matchPositioning() {
11622
- const location = {
11623
- x: matchDistance(),
11624
- y: matchDistance()
11625
- };
11626
- if (location.x || location.y) return {
11627
- type: "position",
11628
- value: location
11629
- };
11593
+ updatePathProxyAABBBounds(aabbBounds, graphic) {
11594
+ const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
11595
+ if (!path) return !1;
11596
+ const boundsContext = new BoundsContext(aabbBounds);
11597
+ return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
11630
11598
  }
11631
- function matchListing(matcher) {
11632
- let captures = matcher();
11633
- const result = [];
11634
- if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
11635
- return result;
11599
+ updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
11600
+ const {
11601
+ textAlign: textAlign,
11602
+ textBaseline: textBaseline
11603
+ } = attribute;
11604
+ if (null != attribute.forceBoundsHeight) {
11605
+ const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
11606
+ dy = textLayoutOffsetY(textBaseline, h, h);
11607
+ aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
11608
+ }
11609
+ if (null != attribute.forceBoundsWidth) {
11610
+ const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
11611
+ dx = textDrawOffsetX(textAlign, w);
11612
+ aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
11613
+ }
11636
11614
  }
11637
- function matchColorStop() {
11638
- const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
11639
- return color || error("Expected color definition"), color.length = matchDistance(), color;
11615
+ combindShadowAABBBounds(bounds, graphic) {
11616
+ if (graphic && graphic.shadowRoot) {
11617
+ const b = graphic.shadowRoot.AABBBounds;
11618
+ bounds.union(b);
11619
+ }
11640
11620
  }
11641
- function matchDistance() {
11642
- return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
11621
+ transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
11622
+ if (!aabbBounds.empty()) {
11623
+ const {
11624
+ scaleX = theme.scaleX,
11625
+ scaleY = theme.scaleY,
11626
+ stroke = theme.stroke,
11627
+ shadowBlur = theme.shadowBlur,
11628
+ lineWidth = theme.lineWidth,
11629
+ pickStrokeBuffer = theme.pickStrokeBuffer,
11630
+ strokeBoundsBuffer = theme.strokeBoundsBuffer
11631
+ } = attribute,
11632
+ tb1 = this.tempAABBBounds1,
11633
+ tb2 = this.tempAABBBounds2;
11634
+ if (stroke && lineWidth) {
11635
+ const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
11636
+ boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
11637
+ }
11638
+ if (shadowBlur) {
11639
+ const {
11640
+ shadowOffsetX = theme.shadowOffsetX,
11641
+ shadowOffsetY = theme.shadowOffsetY
11642
+ } = attribute,
11643
+ shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
11644
+ boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
11645
+ }
11646
+ }
11647
+ if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
11648
+ let updateMatrix = !0;
11649
+ const m = graphic.transMatrix;
11650
+ 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);
11643
11651
  }
11644
- function matchLength() {
11645
- return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
11652
+ validCheck(attribute, theme, aabbBounds, graphic) {
11653
+ if (!graphic) return !0;
11654
+ if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
11655
+ if (graphic.shadowRoot) return !0;
11656
+ if (!graphic.valid) return aabbBounds.clear(), !1;
11657
+ const {
11658
+ visible = theme.visible
11659
+ } = attribute;
11660
+ return !!visible || (aabbBounds.clear(), !1);
11646
11661
  }
11647
- function match(type, pattern, captureIndex) {
11648
- const captures = scan(pattern);
11649
- if (captures) return {
11650
- type: type,
11651
- value: captures[captureIndex]
11662
+ updateTempAABBBounds(aabbBounds) {
11663
+ const tb1 = this.tempAABBBounds1,
11664
+ tb2 = this.tempAABBBounds2;
11665
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
11666
+ tb1: tb1,
11667
+ tb2: tb2
11652
11668
  };
11653
11669
  }
11654
- function scan(regexp) {
11655
- const blankCaptures = /^[\n\r\t\s]+/.exec(input);
11656
- blankCaptures && consume(blankCaptures[0].length);
11657
- const captures = regexp.exec(input);
11658
- return captures && consume(captures[0].length), captures;
11659
- }
11660
- function consume(size) {
11661
- input = input.substr(size);
11662
- }
11663
- return function (code) {
11664
- return input = code.toString(), getAST();
11665
- };
11666
- }();
11667
- class GradientParser {
11668
- static IsGradient(c) {
11669
- return !("string" == typeof c && !c.includes("gradient"));
11670
- }
11671
- static IsGradientStr(c) {
11672
- return "string" == typeof c && c.includes("gradient");
11670
+ };
11671
+ DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], DefaultGraphicService);
11672
+
11673
+ const result = {
11674
+ x: 0,
11675
+ y: 0,
11676
+ z: 0,
11677
+ lastModelMatrix: null
11678
+ };
11679
+ class BaseRender {
11680
+ init(contributions) {
11681
+ 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 === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
11673
11682
  }
11674
- static Parse(c) {
11675
- if (GradientParser.IsGradientStr(c)) try {
11676
- const datum = parse(c)[0];
11677
- if (datum) {
11678
- if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
11679
- if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
11680
- if ("conic" === datum.type) return GradientParser.ParseConic(datum);
11683
+ beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11684
+ this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
11685
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11686
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11681
11687
  }
11682
- } catch (err) {
11683
- return c;
11684
- }
11685
- return c;
11688
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11689
+ });
11686
11690
  }
11687
- static ParseConic(datum) {
11688
- const {
11689
- orientation: orientation,
11690
- colorStops = []
11691
- } = datum,
11692
- halfPi = pi / 2,
11693
- sa = parseFloat(orientation.value) / 180 * pi - halfPi;
11694
- return {
11695
- gradient: "conical",
11696
- x: .5,
11697
- y: .5,
11698
- startAngle: sa,
11699
- endAngle: sa + pi2,
11700
- stops: colorStops.map(item => ({
11701
- color: item.value,
11702
- offset: parseFloat(item.length.value) / 100
11703
- }))
11704
- };
11691
+ afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
11692
+ this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
11693
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
11694
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
11695
+ }
11696
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
11697
+ });
11705
11698
  }
11706
- static ParseRadial(datum) {
11699
+ valid(graphic, defaultAttribute, fillCb, strokeCb) {
11707
11700
  const {
11708
- colorStops = []
11709
- } = datum;
11710
- return {
11711
- gradient: "radial",
11712
- x0: .5,
11713
- y0: .5,
11714
- x1: .5,
11715
- y1: .5,
11716
- r0: 0,
11717
- r1: 1,
11718
- stops: colorStops.map(item => ({
11719
- color: item.value,
11720
- offset: parseFloat(item.length.value) / 100
11721
- }))
11701
+ fill = defaultAttribute.fill,
11702
+ background: background,
11703
+ stroke = defaultAttribute.stroke,
11704
+ opacity = defaultAttribute.opacity,
11705
+ fillOpacity = defaultAttribute.fillOpacity,
11706
+ lineWidth = defaultAttribute.lineWidth,
11707
+ strokeOpacity = defaultAttribute.strokeOpacity,
11708
+ visible = defaultAttribute.visible
11709
+ } = graphic.attribute,
11710
+ fVisible = fillVisible(opacity, fillOpacity, fill),
11711
+ sVisible = strokeVisible(opacity, strokeOpacity),
11712
+ doFill = runFill(fill, background),
11713
+ doStroke = runStroke(stroke, lineWidth);
11714
+ return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
11715
+ fVisible: fVisible,
11716
+ sVisible: sVisible,
11717
+ doFill: doFill,
11718
+ doStroke: doStroke
11722
11719
  };
11723
11720
  }
11724
- static ParseLinear(datum) {
11721
+ transform(graphic, graphicAttribute, context) {
11722
+ let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
11725
11723
  const {
11726
- orientation: orientation,
11727
- colorStops = []
11728
- } = datum,
11729
- halfPi = pi / 2;
11730
- let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
11731
- for (; angle < 0;) angle += pi2;
11732
- for (; angle > pi2;) angle -= pi2;
11733
- let x0 = 0,
11734
- y0 = 0,
11735
- x1 = 0,
11736
- y1 = 0;
11737
- 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)), {
11738
- gradient: "linear",
11739
- x0: x0,
11740
- y0: y0,
11741
- x1: x1,
11742
- y1: y1,
11743
- stops: colorStops.map(item => ({
11744
- color: item.value,
11745
- offset: parseFloat(item.length.value) / 100
11746
- }))
11747
- };
11724
+ x = graphicAttribute.x,
11725
+ y = graphicAttribute.y,
11726
+ z = graphicAttribute.z,
11727
+ scaleX = graphicAttribute.scaleX,
11728
+ scaleY = graphicAttribute.scaleY,
11729
+ angle = graphicAttribute.angle,
11730
+ postMatrix: postMatrix
11731
+ } = graphic.attribute,
11732
+ lastModelMatrix = context.modelMatrix,
11733
+ camera = context.camera;
11734
+ result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
11735
+ const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
11736
+ onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
11737
+ if (shouldTransform3d) {
11738
+ const nextModelMatrix = mat4Allocate.allocate(),
11739
+ modelMatrix = mat4Allocate.allocate();
11740
+ 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);
11741
+ }
11742
+ if (onlyTranslate && !lastModelMatrix) {
11743
+ const point = graphic.getOffsetXY(graphicAttribute);
11744
+ result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
11745
+ } 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) {
11746
+ const point = graphic.getOffsetXY(graphicAttribute);
11747
+ result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
11748
+ } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
11749
+ return result;
11748
11750
  }
11749
- }
11750
-
11751
- function getScaledStroke(context, width, dpr) {
11752
- let strokeWidth = width;
11753
- const {
11754
- a: a,
11755
- b: b,
11756
- c: c,
11757
- d: d
11758
- } = context.currentMatrix,
11759
- scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
11760
- scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
11761
- return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
11762
- }
11763
- function createColor(context, c, params) {
11764
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
11765
- let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
11766
- if (!c || !0 === c) return "black";
11767
- let result, color;
11768
- if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
11769
- if (color = GradientParser.Parse(color), "string" == typeof color) return color;
11770
- if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
11771
- const bounds = params.AABBBounds;
11772
- let w = bounds.x2 - bounds.x1,
11773
- h = bounds.y2 - bounds.y1,
11774
- x = bounds.x1 - offsetX,
11775
- y = bounds.y1 - offsetY;
11776
- if (params.attribute) {
11777
- const {
11778
- scaleX = 1,
11779
- scaleY = 1
11780
- } = params.attribute;
11781
- w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
11751
+ transformUseContext2d(graphic, graphicAttribute, z, context) {
11752
+ const camera = context.camera;
11753
+ if (this.camera = camera, camera) {
11754
+ const bounds = graphic.AABBBounds,
11755
+ width = bounds.x2 - bounds.x1,
11756
+ height = bounds.y2 - bounds.y1,
11757
+ p1 = context.project(0, 0, z),
11758
+ p2 = context.project(width, 0, z),
11759
+ p3 = context.project(width, height, z),
11760
+ _p1 = {
11761
+ x: 0,
11762
+ y: 0
11763
+ },
11764
+ _p2 = {
11765
+ x: width,
11766
+ y: 0
11767
+ },
11768
+ _p3 = {
11769
+ x: width,
11770
+ y: height
11771
+ };
11772
+ context.camera = null;
11773
+ const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
11774
+ m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
11775
+ m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
11776
+ m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
11777
+ m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
11778
+ 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,
11779
+ 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;
11780
+ context.setTransform(m11, m12, m21, m22, dx, dy, !0);
11782
11781
  }
11783
- "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));
11784
11782
  }
11785
- return result || "orange";
11786
- }
11787
- function createLinearGradient(context, color, x, y, w, h) {
11788
- var _a, _b, _c, _d;
11789
- 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);
11790
- return color.stops.forEach(stop => {
11791
- canvasGradient.addColorStop(stop.offset, stop.color);
11792
- }), canvasGradient;
11793
- }
11794
- function createRadialGradient(context, color, x, y, w, h) {
11795
- var _a, _b, _c, _d, _e, _f;
11796
- 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));
11797
- return color.stops.forEach(stop => {
11798
- canvasGradient.addColorStop(stop.offset, stop.color);
11799
- }), canvasGradient;
11800
- }
11801
- function createConicGradient(context, color, x, y, w, h) {
11802
- var _a, _b;
11803
- 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);
11804
- return color.stops.forEach(stop => {
11805
- canvasGradient.addColorStop(stop.offset, stop.color);
11806
- }), canvasGradient.GetPattern(w + x, h + y, undefined);
11783
+ restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
11784
+ this.camera && (context.camera = this.camera);
11785
+ }
11786
+ transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
11787
+ const p = context.project(x, y, z);
11788
+ 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();
11789
+ }
11790
+ _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
11791
+ const {
11792
+ context: context
11793
+ } = drawContext;
11794
+ if (!context) return;
11795
+ const {
11796
+ renderable: renderable
11797
+ } = graphic.attribute;
11798
+ if (!1 === renderable) return;
11799
+ context.highPerformanceSave();
11800
+ const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
11801
+ {
11802
+ x: x,
11803
+ y: y,
11804
+ z: z,
11805
+ lastModelMatrix: lastModelMatrix
11806
+ } = data;
11807
+ 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();
11808
+ }
11807
11809
  }
11808
11810
 
11809
11811
  var __decorate$1A = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -14219,7 +14221,10 @@ class ShadowRootDrawItemInterceptorContribution {
14219
14221
  const {
14220
14222
  context: context
14221
14223
  } = drawContext;
14222
- if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14224
+ context.highPerformanceSave();
14225
+ const t1 = graphic.parent.globalTransMatrix,
14226
+ t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
14227
+ if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
14223
14228
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
14224
14229
  const m = graphic.globalTransMatrix.getInverse();
14225
14230
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -15242,6 +15247,9 @@ class BaseSymbol {
15242
15247
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
15243
15248
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
15244
15249
  }
15250
+ parseSize(size) {
15251
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15252
+ }
15245
15253
  }
15246
15254
 
15247
15255
  function circle(ctx, r, x, y, z) {
@@ -15252,13 +15260,13 @@ class CircleSymbol extends BaseSymbol {
15252
15260
  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";
15253
15261
  }
15254
15262
  draw(ctx, size, x, y, z) {
15255
- return circle(ctx, size / 2, x, y, z);
15263
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
15256
15264
  }
15257
15265
  drawOffset(ctx, size, x, y, offset, z) {
15258
- return circle(ctx, size / 2 + offset, x, y, z);
15266
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15259
15267
  }
15260
15268
  drawToSvgPath(size, x, y, z) {
15261
- const r = size / 2;
15269
+ const r = this.parseSize(size) / 2;
15262
15270
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
15263
15271
  }
15264
15272
  }
@@ -15275,10 +15283,10 @@ class CrossSymbol extends BaseSymbol {
15275
15283
  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";
15276
15284
  }
15277
15285
  draw(ctx, size, x, y, z) {
15278
- return cross(ctx, size / 6, x, y, z);
15286
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
15279
15287
  }
15280
15288
  drawOffset(ctx, size, x, y, offset, z) {
15281
- return crossOffset(ctx, size / 6, x, y, offset, z);
15289
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
15282
15290
  }
15283
15291
  }
15284
15292
  var cross$1 = new CrossSymbol();
@@ -15291,13 +15299,13 @@ class DiamondSymbol extends BaseSymbol {
15291
15299
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
15292
15300
  }
15293
15301
  draw(ctx, size, x, y, z) {
15294
- return diamond(ctx, size / 2, x, y, z);
15302
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15295
15303
  }
15296
15304
  drawFitDir(ctx, size, x, y, z) {
15297
- return diamond(ctx, size / 2, x, y, z);
15305
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
15298
15306
  }
15299
15307
  drawOffset(ctx, size, x, y, offset, z) {
15300
- return diamond(ctx, size / 2 + offset, x, y, z);
15308
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
15301
15309
  }
15302
15310
  }
15303
15311
  var diamond$1 = new DiamondSymbol();
@@ -15311,10 +15319,10 @@ class SquareSymbol extends BaseSymbol {
15311
15319
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
15312
15320
  }
15313
15321
  draw(ctx, size, x, y) {
15314
- return square(ctx, size / 2, x, y);
15322
+ return square(ctx, this.parseSize(size) / 2, x, y);
15315
15323
  }
15316
15324
  drawOffset(ctx, size, x, y, offset) {
15317
- return square(ctx, size / 2 + offset, x, y);
15325
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
15318
15326
  }
15319
15327
  }
15320
15328
  var square$1 = new SquareSymbol();
@@ -15328,10 +15336,10 @@ class TriangleUpSymbol extends BaseSymbol {
15328
15336
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
15329
15337
  }
15330
15338
  draw(ctx, size, x, y) {
15331
- return trianglUpOffset(ctx, size / 2, x, y);
15339
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
15332
15340
  }
15333
15341
  drawOffset(ctx, size, x, y, offset) {
15334
- return trianglUpOffset(ctx, size / 2, x, y, offset);
15342
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15335
15343
  }
15336
15344
  }
15337
15345
  var triangleUp = new TriangleUpSymbol();
@@ -15363,10 +15371,10 @@ class StarSymbol extends BaseSymbol {
15363
15371
  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";
15364
15372
  }
15365
15373
  draw(ctx, size, transX, transY) {
15366
- return star(ctx, size / 2, transX, transY);
15374
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
15367
15375
  }
15368
15376
  drawOffset(ctx, size, transX, transY, offset) {
15369
- return star(ctx, size / 2 + offset, transX, transY);
15377
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15370
15378
  }
15371
15379
  }
15372
15380
  var star$1 = new StarSymbol();
@@ -15384,10 +15392,10 @@ class ArrowSymbol extends BaseSymbol {
15384
15392
  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";
15385
15393
  }
15386
15394
  draw(ctx, size, transX, transY) {
15387
- return arrow(ctx, size / 2, transX, transY);
15395
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
15388
15396
  }
15389
15397
  drawOffset(ctx, size, transX, transY, offset) {
15390
- return arrow(ctx, size / 2 + offset, transX, transY);
15398
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15391
15399
  }
15392
15400
  }
15393
15401
  var arrow$1 = new ArrowSymbol();
@@ -15401,10 +15409,10 @@ class WedgeSymbol extends BaseSymbol {
15401
15409
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
15402
15410
  }
15403
15411
  draw(ctx, size, transX, transY) {
15404
- return wedge(ctx, size / 2, transX, transY);
15412
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
15405
15413
  }
15406
15414
  drawOffset(ctx, size, transX, transY, offset) {
15407
- return wedge(ctx, size / 2 + offset, transX, transY);
15415
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15408
15416
  }
15409
15417
  }
15410
15418
  var wedge$1 = new WedgeSymbol();
@@ -15417,10 +15425,10 @@ class StrokeSymbol extends BaseSymbol {
15417
15425
  super(...arguments), this.type = "stroke", this.pathStr = "";
15418
15426
  }
15419
15427
  draw(ctx, size, transX, transY) {
15420
- return stroke(ctx, size / 2, transX, transY);
15428
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
15421
15429
  }
15422
15430
  drawOffset(ctx, size, transX, transY, offset) {
15423
- return stroke(ctx, size / 2 + offset, transX, transY);
15431
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15424
15432
  }
15425
15433
  }
15426
15434
  var stroke$1 = new StrokeSymbol();
@@ -15442,10 +15450,10 @@ class WyeSymbol extends BaseSymbol {
15442
15450
  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";
15443
15451
  }
15444
15452
  draw(ctx, size, transX, transY) {
15445
- return wye(ctx, size / 2, transX, transY);
15453
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
15446
15454
  }
15447
15455
  drawOffset(ctx, size, transX, transY, offset) {
15448
- return wye(ctx, size / 2 + offset, transX, transY);
15456
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
15449
15457
  }
15450
15458
  }
15451
15459
  var wye$1 = new WyeSymbol();
@@ -15458,10 +15466,10 @@ class TriangleLeftSymbol extends BaseSymbol {
15458
15466
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
15459
15467
  }
15460
15468
  draw(ctx, size, x, y) {
15461
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
15469
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
15462
15470
  }
15463
15471
  drawOffset(ctx, size, x, y, offset) {
15464
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
15472
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15465
15473
  }
15466
15474
  }
15467
15475
  var triangleLeft = new TriangleLeftSymbol();
@@ -15475,10 +15483,10 @@ class TriangleRightSymbol extends BaseSymbol {
15475
15483
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
15476
15484
  }
15477
15485
  draw(ctx, size, x, y) {
15478
- return trianglRightOffset(ctx, size / 2, x, y);
15486
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
15479
15487
  }
15480
15488
  drawOffset(ctx, size, x, y, offset) {
15481
- return trianglRightOffset(ctx, size / 2, x, y, offset);
15489
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15482
15490
  }
15483
15491
  }
15484
15492
  var triangleRight = new TriangleRightSymbol();
@@ -15492,10 +15500,10 @@ class TriangleDownSymbol extends BaseSymbol {
15492
15500
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
15493
15501
  }
15494
15502
  draw(ctx, size, x, y) {
15495
- return trianglDownOffset(ctx, size / 2, x, y);
15503
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
15496
15504
  }
15497
15505
  drawOffset(ctx, size, x, y, offset) {
15498
- return trianglDownOffset(ctx, size / 2, x, y, offset);
15506
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
15499
15507
  }
15500
15508
  }
15501
15509
  var triangleDown = new TriangleDownSymbol();
@@ -15510,10 +15518,10 @@ class ThinTriangleSymbol extends BaseSymbol {
15510
15518
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
15511
15519
  }
15512
15520
  draw(ctx, size, x, y) {
15513
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
15521
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
15514
15522
  }
15515
15523
  drawOffset(ctx, size, x, y, offset) {
15516
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
15524
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
15517
15525
  }
15518
15526
  }
15519
15527
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -15527,10 +15535,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
15527
15535
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
15528
15536
  }
15529
15537
  draw(ctx, size, transX, transY) {
15530
- return arrow2Left(ctx, size / 4, transX, transY);
15538
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
15531
15539
  }
15532
15540
  drawOffset(ctx, size, transX, transY, offset) {
15533
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
15541
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15534
15542
  }
15535
15543
  }
15536
15544
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -15544,10 +15552,10 @@ class Arrow2RightSymbol extends BaseSymbol {
15544
15552
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
15545
15553
  }
15546
15554
  draw(ctx, size, transX, transY) {
15547
- return arrow2Right(ctx, size / 4, transX, transY);
15555
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
15548
15556
  }
15549
15557
  drawOffset(ctx, size, transX, transY, offset) {
15550
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
15558
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15551
15559
  }
15552
15560
  }
15553
15561
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -15561,10 +15569,10 @@ class Arrow2UpSymbol extends BaseSymbol {
15561
15569
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
15562
15570
  }
15563
15571
  draw(ctx, size, transX, transY) {
15564
- return arrow2Up(ctx, size / 4, transX, transY);
15572
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
15565
15573
  }
15566
15574
  drawOffset(ctx, size, transX, transY, offset) {
15567
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
15575
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15568
15576
  }
15569
15577
  }
15570
15578
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -15578,10 +15586,10 @@ class Arrow2DownSymbol extends BaseSymbol {
15578
15586
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
15579
15587
  }
15580
15588
  draw(ctx, size, transX, transY) {
15581
- return arrow2Down(ctx, size / 4, transX, transY);
15589
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
15582
15590
  }
15583
15591
  drawOffset(ctx, size, transX, transY, offset) {
15584
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
15592
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
15585
15593
  }
15586
15594
  }
15587
15595
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -15594,13 +15602,13 @@ class LineVSymbol extends BaseSymbol {
15594
15602
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
15595
15603
  }
15596
15604
  draw(ctx, size, x, y, z) {
15597
- return lineV(ctx, size / 2, x, y);
15605
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
15598
15606
  }
15599
15607
  drawOffset(ctx, size, x, y, offset, z) {
15600
- return lineV(ctx, size / 2 + offset, x, y);
15608
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
15601
15609
  }
15602
15610
  drawToSvgPath(size, x, y, z) {
15603
- const r = size / 2;
15611
+ const r = this.parseSize(size) / 2;
15604
15612
  return `M ${x}, ${y - r} L ${x},${y + r}`;
15605
15613
  }
15606
15614
  }
@@ -15614,13 +15622,13 @@ class LineHSymbol extends BaseSymbol {
15614
15622
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
15615
15623
  }
15616
15624
  draw(ctx, size, x, y, z) {
15617
- return lineH(ctx, size / 2, x, y);
15625
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
15618
15626
  }
15619
15627
  drawOffset(ctx, size, x, y, offset, z) {
15620
- return lineH(ctx, size / 2 + offset, x, y);
15628
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
15621
15629
  }
15622
15630
  drawToSvgPath(size, x, y, z) {
15623
- const r = size / 2;
15631
+ const r = this.parseSize(size) / 2;
15624
15632
  return `M ${x - r}, ${y} L ${x + r},${y}`;
15625
15633
  }
15626
15634
  }
@@ -15634,13 +15642,13 @@ class CloseSymbol extends BaseSymbol {
15634
15642
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
15635
15643
  }
15636
15644
  draw(ctx, size, x, y, z) {
15637
- return close(ctx, size / 2, x, y);
15645
+ return close(ctx, this.parseSize(size) / 2, x, y);
15638
15646
  }
15639
15647
  drawOffset(ctx, size, x, y, offset, z) {
15640
- return close(ctx, size / 2 + offset, x, y);
15648
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
15641
15649
  }
15642
15650
  drawToSvgPath(size, x, y, z) {
15643
- const r = size / 2;
15651
+ const r = this.parseSize(size) / 2;
15644
15652
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
15645
15653
  }
15646
15654
  }
@@ -15674,15 +15682,18 @@ class CustomSymbolClass {
15674
15682
  this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
15675
15683
  }
15676
15684
  drawOffset(ctx, size, x, y, offset, z, cb) {
15677
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15685
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
15678
15686
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
15679
15687
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
15680
15688
  }
15681
15689
  draw(ctx, size, x, y, z, cb) {
15682
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
15690
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
15691
+ }
15692
+ parseSize(size) {
15693
+ return isNumber$1(size) ? size : Math.min(size[0], size[1]);
15683
15694
  }
15684
15695
  bounds(size, bounds) {
15685
- if (this.isSvg) {
15696
+ if (size = this.parseSize(size), this.isSvg) {
15686
15697
  if (!this.svgCache) return;
15687
15698
  return bounds.clear(), void this.svgCache.forEach(_ref => {
15688
15699
  let {
@@ -16365,7 +16376,11 @@ class Paragraph {
16365
16376
  case "sub":
16366
16377
  baseline += this.descent / 2;
16367
16378
  }
16368
- "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();
16379
+ "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);
16380
+ const {
16381
+ lineWidth = 1
16382
+ } = this.character;
16383
+ 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();
16369
16384
  }
16370
16385
  getWidthWithEllips(direction) {
16371
16386
  let text = this.text;
@@ -16588,12 +16603,18 @@ class Line {
16588
16603
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16589
16604
  }
16590
16605
  }
16591
- this.paragraphs.map((paragraph, index) => {
16606
+ this.paragraphs.forEach((paragraph, index) => {
16592
16607
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
16593
16608
  x: x + paragraph._x,
16594
16609
  y: y + paragraph._y
16595
16610
  }), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
16596
- paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16611
+ const b = {
16612
+ x1: this.left,
16613
+ y1: this.top,
16614
+ x2: this.left + this.actualWidth,
16615
+ y2: this.top + this.height
16616
+ };
16617
+ applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
16597
16618
  });
16598
16619
  }
16599
16620
  getWidthWithEllips(ellipsis) {
@@ -16616,7 +16637,7 @@ class Line {
16616
16637
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
16617
16638
  }
16618
16639
  let width = 0;
16619
- return this.paragraphs.map((paragraph, index) => {
16640
+ return this.paragraphs.forEach((paragraph, index) => {
16620
16641
  width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
16621
16642
  }), width;
16622
16643
  }
@@ -28608,7 +28629,7 @@ const registerWrapText = _registerWrapText;
28608
28629
 
28609
28630
  const roughModule = _roughModule;
28610
28631
 
28611
- const version = "0.20.15";
28632
+ const version = "0.20.16";
28612
28633
  preLoadAllModule();
28613
28634
  if (isBrowserEnv()) {
28614
28635
  loadBrowserEnv(container);