@visactor/vrender-components 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.
Files changed (56) hide show
  1. package/cjs/axis/type.d.ts +2 -2
  2. package/cjs/axis/type.js.map +1 -1
  3. package/cjs/data-zoom/type.d.ts +1 -1
  4. package/cjs/data-zoom/type.js.map +1 -1
  5. package/cjs/index.d.ts +1 -1
  6. package/cjs/index.js +1 -1
  7. package/cjs/index.js.map +1 -1
  8. package/cjs/interface.js.map +1 -1
  9. package/cjs/label/base.js +12 -7
  10. package/cjs/label/base.js.map +1 -1
  11. package/cjs/label/overlap/place.d.ts +6 -1
  12. package/cjs/label/overlap/place.js +4 -4
  13. package/cjs/label/overlap/place.js.map +1 -1
  14. package/cjs/label/overlap/shiftY.d.ts +10 -4
  15. package/cjs/label/overlap/shiftY.js +103 -27
  16. package/cjs/label/overlap/shiftY.js.map +1 -1
  17. package/cjs/legend/color/type.d.ts +2 -2
  18. package/cjs/legend/color/type.js.map +1 -1
  19. package/cjs/legend/discrete/type.d.ts +1 -1
  20. package/cjs/legend/discrete/type.js.map +1 -1
  21. package/cjs/marker/type.d.ts +2 -2
  22. package/cjs/marker/type.js.map +1 -1
  23. package/cjs/player/type/discrete-player.d.ts +3 -3
  24. package/cjs/player/type/discrete-player.js.map +1 -1
  25. package/cjs/player/type/index.d.ts +2 -2
  26. package/cjs/player/type/index.js.map +1 -1
  27. package/cjs/timeline/type.js.map +1 -1
  28. package/dist/index.es.js +866 -725
  29. package/es/axis/type.d.ts +2 -2
  30. package/es/axis/type.js.map +1 -1
  31. package/es/data-zoom/type.d.ts +1 -1
  32. package/es/data-zoom/type.js.map +1 -1
  33. package/es/index.d.ts +1 -1
  34. package/es/index.js +1 -1
  35. package/es/index.js.map +1 -1
  36. package/es/interface.js.map +1 -1
  37. package/es/label/base.js +12 -7
  38. package/es/label/base.js.map +1 -1
  39. package/es/label/overlap/place.d.ts +6 -1
  40. package/es/label/overlap/place.js +4 -4
  41. package/es/label/overlap/place.js.map +1 -1
  42. package/es/label/overlap/shiftY.d.ts +10 -4
  43. package/es/label/overlap/shiftY.js +99 -24
  44. package/es/label/overlap/shiftY.js.map +1 -1
  45. package/es/legend/color/type.d.ts +2 -2
  46. package/es/legend/color/type.js.map +1 -1
  47. package/es/legend/discrete/type.d.ts +1 -1
  48. package/es/legend/discrete/type.js.map +1 -1
  49. package/es/marker/type.d.ts +2 -2
  50. package/es/marker/type.js.map +1 -1
  51. package/es/player/type/discrete-player.d.ts +3 -3
  52. package/es/player/type/discrete-player.js.map +1 -1
  53. package/es/player/type/index.d.ts +2 -2
  54. package/es/player/type/index.js.map +1 -1
  55. package/es/timeline/type.js.map +1 -1
  56. package/package.json +7 -6
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pi, isArray, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
1
+ import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, Point, PointService, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, pi, isArray, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, cos, sin, pointAt, isNumber, getDecimalPlaces, isNil, Color, OBBBounds, has, normalTransform, isValidUrl, isBase64, acos, sqrt, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, Bounds, getRectIntersect, isRectIntersect, isPlainObject, merge, clamp, clampRange, normalizePadding, debounce, throttle, hexToRgb, crossProduct, isValid, isEmpty, rectInsideAnotherRect, radianToDegree, getAngleByPoint, polarToCartesian, array, isValidNumber, calculateAnchorOfBounds, computeQuadrant, isGreater, isLess, normalizeAngle, flattenArray, cloneDeep, get, last, isRotateAABBIntersect, mixin, isEqual, interpolateString, minInArray, maxInArray, binaryFuzzySearchInNumberRange, polygonContainPoint } from '@visactor/vutils';
2
2
  import { isContinuous, isDiscrete, LinearScale } from '@visactor/vscale';
3
3
 
4
4
  class Generator {
@@ -2231,6 +2231,292 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
2231
2231
  class Application {}
2232
2232
  const application = new Application();
2233
2233
 
2234
+ const parse = function () {
2235
+ const tokens = {
2236
+ linearGradient: /^(linear\-gradient)/i,
2237
+ radialGradient: /^(radial\-gradient)/i,
2238
+ conicGradient: /^(conic\-gradient)/i,
2239
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
2240
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
2241
+ positionKeywords: /^(left|center|right|top|bottom)/i,
2242
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
2243
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
2244
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
2245
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
2246
+ fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
2247
+ startCall: /^\(/,
2248
+ endCall: /^\)/,
2249
+ comma: /^,/,
2250
+ hexColor: /(^\#[0-9a-fA-F]+)/,
2251
+ literalColor: /^([a-zA-Z]+)/,
2252
+ rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
2253
+ rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
2254
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
2255
+ };
2256
+ let input = "";
2257
+ function error(msg) {
2258
+ const err = new Error(input + ": " + msg);
2259
+ throw err.source = input, err;
2260
+ }
2261
+ function getAST() {
2262
+ const ast = matchListing(matchDefinition);
2263
+ return input.length > 0 && error("Invalid input not EOF"), ast;
2264
+ }
2265
+ function matchDefinition() {
2266
+ return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
2267
+ }
2268
+ function matchGradient(gradientType, pattern, orientationMatcher) {
2269
+ return function (pattern, callback) {
2270
+ const captures = scan(pattern);
2271
+ if (captures) {
2272
+ scan(tokens.startCall) || error("Missing (");
2273
+ const result = callback(captures);
2274
+ return scan(tokens.endCall) || error("Missing )"), result;
2275
+ }
2276
+ }(pattern, function (captures) {
2277
+ const orientation = orientationMatcher();
2278
+ return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
2279
+ type: gradientType,
2280
+ orientation: orientation,
2281
+ colorStops: matchListing(matchColorStop)
2282
+ };
2283
+ });
2284
+ }
2285
+ function matchLinearOrientation() {
2286
+ return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
2287
+ }
2288
+ function matchConicalOrientation() {
2289
+ return match("angular", tokens.fromAngleValue, 1);
2290
+ }
2291
+ function matchListRadialOrientations() {
2292
+ let radialOrientations,
2293
+ lookaheadCache,
2294
+ radialOrientation = matchRadialOrientation();
2295
+ return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
2296
+ }
2297
+ function matchRadialOrientation() {
2298
+ let radialType = function () {
2299
+ const circle = match("shape", /^(circle)/i, 0);
2300
+ circle && (circle.style = matchLength() || matchExtentKeyword());
2301
+ return circle;
2302
+ }() || function () {
2303
+ const ellipse = match("shape", /^(ellipse)/i, 0);
2304
+ ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
2305
+ return ellipse;
2306
+ }();
2307
+ if (radialType) radialType.at = matchAtPosition();else {
2308
+ const extent = matchExtentKeyword();
2309
+ if (extent) {
2310
+ radialType = extent;
2311
+ const positionAt = matchAtPosition();
2312
+ positionAt && (radialType.at = positionAt);
2313
+ } else {
2314
+ const defaultPosition = matchPositioning();
2315
+ defaultPosition && (radialType = {
2316
+ type: "default-radial",
2317
+ at: defaultPosition
2318
+ });
2319
+ }
2320
+ }
2321
+ return radialType;
2322
+ }
2323
+ function matchExtentKeyword() {
2324
+ return match("extent-keyword", tokens.extentKeywords, 1);
2325
+ }
2326
+ function matchAtPosition() {
2327
+ if (match("position", /^at/, 0)) {
2328
+ const positioning = matchPositioning();
2329
+ return positioning || error("Missing positioning value"), positioning;
2330
+ }
2331
+ }
2332
+ function matchPositioning() {
2333
+ const location = {
2334
+ x: matchDistance(),
2335
+ y: matchDistance()
2336
+ };
2337
+ if (location.x || location.y) return {
2338
+ type: "position",
2339
+ value: location
2340
+ };
2341
+ }
2342
+ function matchListing(matcher) {
2343
+ let captures = matcher();
2344
+ const result = [];
2345
+ if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
2346
+ return result;
2347
+ }
2348
+ function matchColorStop() {
2349
+ const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
2350
+ return color || error("Expected color definition"), color.length = matchDistance(), color;
2351
+ }
2352
+ function matchDistance() {
2353
+ return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
2354
+ }
2355
+ function matchLength() {
2356
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
2357
+ }
2358
+ function match(type, pattern, captureIndex) {
2359
+ const captures = scan(pattern);
2360
+ if (captures) return {
2361
+ type: type,
2362
+ value: captures[captureIndex]
2363
+ };
2364
+ }
2365
+ function scan(regexp) {
2366
+ const blankCaptures = /^[\n\r\t\s]+/.exec(input);
2367
+ blankCaptures && consume(blankCaptures[0].length);
2368
+ const captures = regexp.exec(input);
2369
+ return captures && consume(captures[0].length), captures;
2370
+ }
2371
+ function consume(size) {
2372
+ input = input.substr(size);
2373
+ }
2374
+ return function (code) {
2375
+ return input = code.toString(), getAST();
2376
+ };
2377
+ }();
2378
+ class GradientParser {
2379
+ static IsGradient(c) {
2380
+ return !("string" == typeof c && !c.includes("gradient"));
2381
+ }
2382
+ static IsGradientStr(c) {
2383
+ return "string" == typeof c && c.includes("gradient");
2384
+ }
2385
+ static Parse(c) {
2386
+ if (GradientParser.IsGradientStr(c)) try {
2387
+ const datum = parse(c)[0];
2388
+ if (datum) {
2389
+ if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
2390
+ if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
2391
+ if ("conic" === datum.type) return GradientParser.ParseConic(datum);
2392
+ }
2393
+ } catch (err) {
2394
+ return c;
2395
+ }
2396
+ return c;
2397
+ }
2398
+ static ParseConic(datum) {
2399
+ const {
2400
+ orientation: orientation,
2401
+ colorStops = []
2402
+ } = datum,
2403
+ halfPi = pi / 2,
2404
+ sa = parseFloat(orientation.value) / 180 * pi - halfPi;
2405
+ return {
2406
+ gradient: "conical",
2407
+ x: .5,
2408
+ y: .5,
2409
+ startAngle: sa,
2410
+ endAngle: sa + pi2,
2411
+ stops: colorStops.map(item => ({
2412
+ color: item.value,
2413
+ offset: parseFloat(item.length.value) / 100
2414
+ }))
2415
+ };
2416
+ }
2417
+ static ParseRadial(datum) {
2418
+ const {
2419
+ colorStops = []
2420
+ } = datum;
2421
+ return {
2422
+ gradient: "radial",
2423
+ x0: .5,
2424
+ y0: .5,
2425
+ x1: .5,
2426
+ y1: .5,
2427
+ r0: 0,
2428
+ r1: 1,
2429
+ stops: colorStops.map(item => ({
2430
+ color: item.value,
2431
+ offset: parseFloat(item.length.value) / 100
2432
+ }))
2433
+ };
2434
+ }
2435
+ static ParseLinear(datum) {
2436
+ const {
2437
+ orientation: orientation,
2438
+ colorStops = []
2439
+ } = datum,
2440
+ halfPi = pi / 2;
2441
+ let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
2442
+ for (; angle < 0;) angle += pi2;
2443
+ for (; angle >= pi2;) angle -= pi2;
2444
+ let x0 = 0,
2445
+ y0 = 0,
2446
+ x1 = 0,
2447
+ y1 = 0;
2448
+ 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)), {
2449
+ gradient: "linear",
2450
+ x0: x0,
2451
+ y0: y0,
2452
+ x1: x1,
2453
+ y1: y1,
2454
+ stops: colorStops.map(item => ({
2455
+ color: item.value,
2456
+ offset: parseFloat(item.length.value) / 100
2457
+ }))
2458
+ };
2459
+ }
2460
+ }
2461
+
2462
+ function getScaledStroke(context, width, dpr) {
2463
+ let strokeWidth = width;
2464
+ const {
2465
+ a: a,
2466
+ b: b,
2467
+ c: c,
2468
+ d: d
2469
+ } = context.currentMatrix,
2470
+ scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
2471
+ scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
2472
+ return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
2473
+ }
2474
+ function createColor(context, c, params) {
2475
+ let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
2476
+ let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
2477
+ if (!c || !0 === c) return "black";
2478
+ let result, color;
2479
+ if (isArray(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
2480
+ if (color = GradientParser.Parse(color), "string" == typeof color) return color;
2481
+ if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
2482
+ const bounds = params.AABBBounds;
2483
+ let w = bounds.x2 - bounds.x1,
2484
+ h = bounds.y2 - bounds.y1,
2485
+ x = bounds.x1 - offsetX,
2486
+ y = bounds.y1 - offsetY;
2487
+ if (params.attribute) {
2488
+ const {
2489
+ scaleX = 1,
2490
+ scaleY = 1
2491
+ } = params.attribute;
2492
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
2493
+ }
2494
+ "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));
2495
+ }
2496
+ return result || "orange";
2497
+ }
2498
+ function createLinearGradient(context, color, x, y, w, h) {
2499
+ var _a, _b, _c, _d;
2500
+ 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);
2501
+ return color.stops.forEach(stop => {
2502
+ canvasGradient.addColorStop(stop.offset, stop.color);
2503
+ }), canvasGradient;
2504
+ }
2505
+ function createRadialGradient(context, color, x, y, w, h) {
2506
+ var _a, _b, _c, _d, _e, _f;
2507
+ 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));
2508
+ return color.stops.forEach(stop => {
2509
+ canvasGradient.addColorStop(stop.offset, stop.color);
2510
+ }), canvasGradient;
2511
+ }
2512
+ function createConicGradient(context, color, x, y, w, h) {
2513
+ var _a, _b;
2514
+ 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);
2515
+ return color.stops.forEach(stop => {
2516
+ canvasGradient.addColorStop(stop.offset, stop.color);
2517
+ }), canvasGradient.GetPattern(w + x, h + y, undefined);
2518
+ }
2519
+
2234
2520
  const DIRECTION_KEY = {
2235
2521
  horizontal: {
2236
2522
  width: "width",
@@ -2282,14 +2568,16 @@ const setTextStyle = (ctx, character) => {
2282
2568
  fontFamily: character.fontFamily || "sans-serif"
2283
2569
  });
2284
2570
  };
2285
- function applyFillStyle(ctx, character) {
2571
+ function applyFillStyle(ctx, character, b) {
2286
2572
  const fillStyle = character && character.fill || defaultFormatting.fill;
2287
2573
  if (!fillStyle) return void (ctx.globalAlpha = 0);
2288
2574
  const {
2289
2575
  fillOpacity = 1,
2290
2576
  opacity = 1
2291
2577
  } = character;
2292
- ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
2578
+ ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
2579
+ AABBBounds: b
2580
+ }) : fillStyle, setTextStyle(ctx, character);
2293
2581
  }
2294
2582
  function applyStrokeStyle(ctx, character) {
2295
2583
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
@@ -6143,662 +6431,376 @@ class DefaultMatrixAllocate {
6143
6431
  return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
6144
6432
  }
6145
6433
  allocateByObj(matrix) {
6146
- if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
6147
- const m = this.pools.pop();
6148
- 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;
6149
- }
6150
- free(d) {
6151
- this.pools.push(d);
6152
- }
6153
- get length() {
6154
- return this.pools.length;
6155
- }
6156
- release() {
6157
- this.pools = [];
6158
- }
6159
- }
6160
- class DefaultMat4Allocate {
6161
- constructor() {
6162
- this.pools = [];
6163
- }
6164
- static identity(out) {
6165
- return identityMat4(out);
6166
- }
6167
- allocate() {
6168
- if (!this.pools.length) return createMat4();
6169
- const m = this.pools.pop();
6170
- return DefaultMat4Allocate.identity(m), m;
6171
- }
6172
- allocateByObj(d) {
6173
- let m;
6174
- m = this.pools.length ? this.pools.pop() : createMat4();
6175
- for (let i = 0; i < m.length; i++) m[i] = d[i];
6176
- return m;
6177
- }
6178
- free(m) {
6179
- m && this.pools.push(m);
6180
- }
6181
- get length() {
6182
- return this.pools.length;
6183
- }
6184
- release() {
6185
- this.pools = [];
6186
- }
6187
- }
6188
- const matrixAllocate = new DefaultMatrixAllocate();
6189
- const mat4Allocate = new DefaultMat4Allocate();
6190
-
6191
- var __decorate$J = undefined && undefined.__decorate || function (decorators, target, key, desc) {
6192
- var d,
6193
- c = arguments.length,
6194
- r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
6195
- 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);
6196
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6197
- },
6198
- __metadata$A = undefined && undefined.__metadata || function (k, v) {
6199
- if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
6200
- },
6201
- __param$x = undefined && undefined.__param || function (paramIndex, decorator) {
6202
- return function (target, key) {
6203
- decorator(target, key, paramIndex);
6204
- };
6205
- };
6206
- function getModelMatrix(out, graphic, theme) {
6207
- var _a;
6208
- const {
6209
- x = theme.x,
6210
- y = theme.y,
6211
- z = theme.z,
6212
- dx = theme.dx,
6213
- dy = theme.dy,
6214
- dz = theme.dz,
6215
- scaleX = theme.scaleX,
6216
- scaleY = theme.scaleY,
6217
- scaleZ = theme.scaleZ,
6218
- alpha = theme.alpha,
6219
- beta = theme.beta,
6220
- angle = theme.angle,
6221
- anchor3d = graphic.attribute.anchor,
6222
- anchor: anchor
6223
- } = graphic.attribute,
6224
- _anchor = [0, 0, 0];
6225
- if (anchor3d) {
6226
- if ("string" == typeof anchor3d[0]) {
6227
- const ratio = parseFloat(anchor3d[0]) / 100,
6228
- bounds = graphic.AABBBounds;
6229
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6230
- } else _anchor[0] = anchor3d[0];
6231
- if ("string" == typeof anchor3d[1]) {
6232
- const ratio = parseFloat(anchor3d[1]) / 100,
6233
- bounds = graphic.AABBBounds;
6234
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6235
- } else _anchor[1] = anchor3d[1];
6236
- _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
6237
- }
6238
- 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) {
6239
- const m = mat4Allocate.allocate(),
6240
- _anchor = [0, 0];
6241
- if (anchor) {
6242
- if ("string" == typeof anchor3d[0]) {
6243
- const ratio = parseFloat(anchor3d[0]) / 100,
6244
- bounds = graphic.AABBBounds;
6245
- _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6246
- } else _anchor[0] = anchor3d[0];
6247
- if ("string" == typeof anchor3d[1]) {
6248
- const ratio = parseFloat(anchor3d[1]) / 100,
6249
- bounds = graphic.AABBBounds;
6250
- _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6251
- } else _anchor[1] = anchor3d[1];
6252
- }
6253
- translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
6254
- }
6255
- }
6256
- function shouldUseMat4(graphic) {
6257
- const {
6258
- alpha: alpha,
6259
- beta: beta
6260
- } = graphic.attribute;
6261
- return alpha || beta;
6262
- }
6263
- let DefaultGraphicService = class {
6264
- constructor(creator) {
6265
- this.creator = creator, this.hooks = {
6266
- onAttributeUpdate: new SyncHook(["graphic"]),
6267
- onSetStage: new SyncHook(["graphic", "stage"]),
6268
- onRemove: new SyncHook(["graphic"]),
6269
- onRelease: new SyncHook(["graphic"]),
6270
- onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
6271
- onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
6272
- beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
6273
- afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
6274
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
6275
- }
6276
- onAttributeUpdate(graphic) {
6277
- this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
6278
- }
6279
- onSetStage(graphic, stage) {
6280
- this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
6281
- }
6282
- onRemove(graphic) {
6283
- this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
6284
- }
6285
- onRelease(graphic) {
6286
- this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
6287
- }
6288
- onAddIncremental(graphic, group, stage) {
6289
- this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
6290
- }
6291
- onClearIncremental(group, stage) {
6292
- this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
6293
- }
6294
- beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
6295
- this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
6296
- }
6297
- afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
6298
- this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
6299
- }
6300
- updatePathProxyAABBBounds(aabbBounds, graphic) {
6301
- const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
6302
- if (!path) return !1;
6303
- const boundsContext = new BoundsContext(aabbBounds);
6304
- return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
6305
- }
6306
- updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
6307
- const {
6308
- textAlign: textAlign,
6309
- textBaseline: textBaseline
6310
- } = attribute;
6311
- if (null != attribute.forceBoundsHeight) {
6312
- const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
6313
- dy = textLayoutOffsetY(textBaseline, h, h);
6314
- aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
6315
- }
6316
- if (null != attribute.forceBoundsWidth) {
6317
- const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
6318
- dx = textDrawOffsetX(textAlign, w);
6319
- aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
6320
- }
6321
- }
6322
- combindShadowAABBBounds(bounds, graphic) {
6323
- if (graphic && graphic.shadowRoot) {
6324
- const b = graphic.shadowRoot.AABBBounds;
6325
- bounds.union(b);
6326
- }
6327
- }
6328
- transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
6329
- if (!aabbBounds.empty()) {
6330
- const {
6331
- scaleX = theme.scaleX,
6332
- scaleY = theme.scaleY,
6333
- stroke = theme.stroke,
6334
- shadowBlur = theme.shadowBlur,
6335
- lineWidth = theme.lineWidth,
6336
- pickStrokeBuffer = theme.pickStrokeBuffer,
6337
- strokeBoundsBuffer = theme.strokeBoundsBuffer
6338
- } = attribute,
6339
- tb1 = this.tempAABBBounds1,
6340
- tb2 = this.tempAABBBounds2;
6341
- if (stroke && lineWidth) {
6342
- const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
6343
- boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
6344
- }
6345
- if (shadowBlur) {
6346
- const {
6347
- shadowOffsetX = theme.shadowOffsetX,
6348
- shadowOffsetY = theme.shadowOffsetY
6349
- } = attribute,
6350
- shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
6351
- boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
6352
- }
6353
- }
6354
- if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
6355
- let updateMatrix = !0;
6356
- const m = graphic.transMatrix;
6357
- 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);
6358
- }
6359
- validCheck(attribute, theme, aabbBounds, graphic) {
6360
- if (!graphic) return !0;
6361
- if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
6362
- if (graphic.shadowRoot) return !0;
6363
- if (!graphic.valid) return aabbBounds.clear(), !1;
6364
- const {
6365
- visible = theme.visible
6366
- } = attribute;
6367
- return !!visible || (aabbBounds.clear(), !1);
6434
+ if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
6435
+ const m = this.pools.pop();
6436
+ 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;
6368
6437
  }
6369
- updateTempAABBBounds(aabbBounds) {
6370
- const tb1 = this.tempAABBBounds1,
6371
- tb2 = this.tempAABBBounds2;
6372
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
6373
- tb1: tb1,
6374
- tb2: tb2
6375
- };
6438
+ free(d) {
6439
+ this.pools.push(d);
6376
6440
  }
6377
- };
6378
- DefaultGraphicService = __decorate$J([injectable(), __param$x(0, inject(GraphicCreator$1)), __metadata$A("design:paramtypes", [Object])], DefaultGraphicService);
6379
-
6380
- const result = {
6381
- x: 0,
6382
- y: 0,
6383
- z: 0,
6384
- lastModelMatrix: null
6385
- };
6386
- class BaseRender {
6387
- init(contributions) {
6388
- 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));
6441
+ get length() {
6442
+ return this.pools.length;
6389
6443
  }
6390
- beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
6391
- this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
6392
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
6393
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
6394
- }
6395
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
6396
- });
6444
+ release() {
6445
+ this.pools = [];
6397
6446
  }
6398
- afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
6399
- this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
6400
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
6401
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
6402
- }
6403
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
6404
- });
6447
+ }
6448
+ class DefaultMat4Allocate {
6449
+ constructor() {
6450
+ this.pools = [];
6405
6451
  }
6406
- valid(graphic, defaultAttribute, fillCb, strokeCb) {
6407
- const {
6408
- fill = defaultAttribute.fill,
6409
- background: background,
6410
- stroke = defaultAttribute.stroke,
6411
- opacity = defaultAttribute.opacity,
6412
- fillOpacity = defaultAttribute.fillOpacity,
6413
- lineWidth = defaultAttribute.lineWidth,
6414
- strokeOpacity = defaultAttribute.strokeOpacity,
6415
- visible = defaultAttribute.visible
6416
- } = graphic.attribute,
6417
- fVisible = fillVisible(opacity, fillOpacity, fill),
6418
- sVisible = strokeVisible(opacity, strokeOpacity),
6419
- doFill = runFill(fill, background),
6420
- doStroke = runStroke(stroke, lineWidth);
6421
- return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
6422
- fVisible: fVisible,
6423
- sVisible: sVisible,
6424
- doFill: doFill,
6425
- doStroke: doStroke
6426
- };
6452
+ static identity(out) {
6453
+ return identityMat4(out);
6427
6454
  }
6428
- transform(graphic, graphicAttribute, context) {
6429
- let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
6430
- const {
6431
- x = graphicAttribute.x,
6432
- y = graphicAttribute.y,
6433
- z = graphicAttribute.z,
6434
- scaleX = graphicAttribute.scaleX,
6435
- scaleY = graphicAttribute.scaleY,
6436
- angle = graphicAttribute.angle,
6437
- postMatrix: postMatrix
6438
- } = graphic.attribute,
6439
- lastModelMatrix = context.modelMatrix,
6440
- camera = context.camera;
6441
- result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
6442
- const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
6443
- onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
6444
- if (shouldTransform3d) {
6445
- const nextModelMatrix = mat4Allocate.allocate(),
6446
- modelMatrix = mat4Allocate.allocate();
6447
- 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);
6448
- }
6449
- if (onlyTranslate && !lastModelMatrix) {
6450
- const point = graphic.getOffsetXY(graphicAttribute);
6451
- result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
6452
- } 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) {
6453
- const point = graphic.getOffsetXY(graphicAttribute);
6454
- result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
6455
- } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
6456
- return result;
6455
+ allocate() {
6456
+ if (!this.pools.length) return createMat4();
6457
+ const m = this.pools.pop();
6458
+ return DefaultMat4Allocate.identity(m), m;
6457
6459
  }
6458
- transformUseContext2d(graphic, graphicAttribute, z, context) {
6459
- const camera = context.camera;
6460
- if (this.camera = camera, camera) {
6461
- const bounds = graphic.AABBBounds,
6462
- width = bounds.x2 - bounds.x1,
6463
- height = bounds.y2 - bounds.y1,
6464
- p1 = context.project(0, 0, z),
6465
- p2 = context.project(width, 0, z),
6466
- p3 = context.project(width, height, z),
6467
- _p1 = {
6468
- x: 0,
6469
- y: 0
6470
- },
6471
- _p2 = {
6472
- x: width,
6473
- y: 0
6474
- },
6475
- _p3 = {
6476
- x: width,
6477
- y: height
6478
- };
6479
- context.camera = null;
6480
- const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
6481
- m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
6482
- m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
6483
- m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
6484
- m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
6485
- 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,
6486
- 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;
6487
- context.setTransform(m11, m12, m21, m22, dx, dy, !0);
6488
- }
6460
+ allocateByObj(d) {
6461
+ let m;
6462
+ m = this.pools.length ? this.pools.pop() : createMat4();
6463
+ for (let i = 0; i < m.length; i++) m[i] = d[i];
6464
+ return m;
6489
6465
  }
6490
- restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
6491
- this.camera && (context.camera = this.camera);
6466
+ free(m) {
6467
+ m && this.pools.push(m);
6492
6468
  }
6493
- transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
6494
- const p = context.project(x, y, z);
6495
- 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();
6469
+ get length() {
6470
+ return this.pools.length;
6496
6471
  }
6497
- _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
6498
- const {
6499
- context: context
6500
- } = drawContext;
6501
- if (!context) return;
6502
- const {
6503
- renderable: renderable
6504
- } = graphic.attribute;
6505
- if (!1 === renderable) return;
6506
- context.highPerformanceSave();
6507
- const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
6508
- {
6509
- x: x,
6510
- y: y,
6511
- z: z,
6512
- lastModelMatrix: lastModelMatrix
6513
- } = data;
6514
- 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();
6472
+ release() {
6473
+ this.pools = [];
6515
6474
  }
6516
6475
  }
6476
+ const matrixAllocate = new DefaultMatrixAllocate();
6477
+ const mat4Allocate = new DefaultMat4Allocate();
6517
6478
 
6518
- const parse = function () {
6519
- const tokens = {
6520
- linearGradient: /^(linear\-gradient)/i,
6521
- radialGradient: /^(radial\-gradient)/i,
6522
- conicGradient: /^(conic\-gradient)/i,
6523
- sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
6524
- extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
6525
- positionKeywords: /^(left|center|right|top|bottom)/i,
6526
- pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
6527
- percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
6528
- emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
6529
- angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
6530
- fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
6531
- startCall: /^\(/,
6532
- endCall: /^\)/,
6533
- comma: /^,/,
6534
- hexColor: /(^\#[0-9a-fA-F]+)/,
6535
- literalColor: /^([a-zA-Z]+)/,
6536
- rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
6537
- rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
6538
- number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
6479
+ var __decorate$J = undefined && undefined.__decorate || function (decorators, target, key, desc) {
6480
+ var d,
6481
+ c = arguments.length,
6482
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
6483
+ 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);
6484
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6485
+ },
6486
+ __metadata$A = undefined && undefined.__metadata || function (k, v) {
6487
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
6488
+ },
6489
+ __param$x = undefined && undefined.__param || function (paramIndex, decorator) {
6490
+ return function (target, key) {
6491
+ decorator(target, key, paramIndex);
6492
+ };
6539
6493
  };
6540
- let input = "";
6541
- function error(msg) {
6542
- const err = new Error(input + ": " + msg);
6543
- throw err.source = input, err;
6544
- }
6545
- function getAST() {
6546
- const ast = matchListing(matchDefinition);
6547
- return input.length > 0 && error("Invalid input not EOF"), ast;
6548
- }
6549
- function matchDefinition() {
6550
- return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
6551
- }
6552
- function matchGradient(gradientType, pattern, orientationMatcher) {
6553
- return function (pattern, callback) {
6554
- const captures = scan(pattern);
6555
- if (captures) {
6556
- scan(tokens.startCall) || error("Missing (");
6557
- const result = callback(captures);
6558
- return scan(tokens.endCall) || error("Missing )"), result;
6559
- }
6560
- }(pattern, function (captures) {
6561
- const orientation = orientationMatcher();
6562
- return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
6563
- type: gradientType,
6564
- orientation: orientation,
6565
- colorStops: matchListing(matchColorStop)
6566
- };
6567
- });
6568
- }
6569
- function matchLinearOrientation() {
6570
- return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
6571
- }
6572
- function matchConicalOrientation() {
6573
- return match("angular", tokens.fromAngleValue, 1);
6574
- }
6575
- function matchListRadialOrientations() {
6576
- let radialOrientations,
6577
- lookaheadCache,
6578
- radialOrientation = matchRadialOrientation();
6579
- return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
6494
+ function getModelMatrix(out, graphic, theme) {
6495
+ var _a;
6496
+ const {
6497
+ x = theme.x,
6498
+ y = theme.y,
6499
+ z = theme.z,
6500
+ dx = theme.dx,
6501
+ dy = theme.dy,
6502
+ dz = theme.dz,
6503
+ scaleX = theme.scaleX,
6504
+ scaleY = theme.scaleY,
6505
+ scaleZ = theme.scaleZ,
6506
+ alpha = theme.alpha,
6507
+ beta = theme.beta,
6508
+ angle = theme.angle,
6509
+ anchor3d = graphic.attribute.anchor,
6510
+ anchor: anchor
6511
+ } = graphic.attribute,
6512
+ _anchor = [0, 0, 0];
6513
+ if (anchor3d) {
6514
+ if ("string" == typeof anchor3d[0]) {
6515
+ const ratio = parseFloat(anchor3d[0]) / 100,
6516
+ bounds = graphic.AABBBounds;
6517
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6518
+ } else _anchor[0] = anchor3d[0];
6519
+ if ("string" == typeof anchor3d[1]) {
6520
+ const ratio = parseFloat(anchor3d[1]) / 100,
6521
+ bounds = graphic.AABBBounds;
6522
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6523
+ } else _anchor[1] = anchor3d[1];
6524
+ _anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
6580
6525
  }
6581
- function matchRadialOrientation() {
6582
- let radialType = function () {
6583
- const circle = match("shape", /^(circle)/i, 0);
6584
- circle && (circle.style = matchLength() || matchExtentKeyword());
6585
- return circle;
6586
- }() || function () {
6587
- const ellipse = match("shape", /^(ellipse)/i, 0);
6588
- ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
6589
- return ellipse;
6590
- }();
6591
- if (radialType) radialType.at = matchAtPosition();else {
6592
- const extent = matchExtentKeyword();
6593
- if (extent) {
6594
- radialType = extent;
6595
- const positionAt = matchAtPosition();
6596
- positionAt && (radialType.at = positionAt);
6597
- } else {
6598
- const defaultPosition = matchPositioning();
6599
- defaultPosition && (radialType = {
6600
- type: "default-radial",
6601
- at: defaultPosition
6602
- });
6603
- }
6526
+ 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) {
6527
+ const m = mat4Allocate.allocate(),
6528
+ _anchor = [0, 0];
6529
+ if (anchor) {
6530
+ if ("string" == typeof anchor3d[0]) {
6531
+ const ratio = parseFloat(anchor3d[0]) / 100,
6532
+ bounds = graphic.AABBBounds;
6533
+ _anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6534
+ } else _anchor[0] = anchor3d[0];
6535
+ if ("string" == typeof anchor3d[1]) {
6536
+ const ratio = parseFloat(anchor3d[1]) / 100,
6537
+ bounds = graphic.AABBBounds;
6538
+ _anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
6539
+ } else _anchor[1] = anchor3d[1];
6604
6540
  }
6605
- return radialType;
6541
+ translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
6606
6542
  }
6607
- function matchExtentKeyword() {
6608
- return match("extent-keyword", tokens.extentKeywords, 1);
6543
+ }
6544
+ function shouldUseMat4(graphic) {
6545
+ const {
6546
+ alpha: alpha,
6547
+ beta: beta
6548
+ } = graphic.attribute;
6549
+ return alpha || beta;
6550
+ }
6551
+ let DefaultGraphicService = class {
6552
+ constructor(creator) {
6553
+ this.creator = creator, this.hooks = {
6554
+ onAttributeUpdate: new SyncHook(["graphic"]),
6555
+ onSetStage: new SyncHook(["graphic", "stage"]),
6556
+ onRemove: new SyncHook(["graphic"]),
6557
+ onRelease: new SyncHook(["graphic"]),
6558
+ onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
6559
+ onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
6560
+ beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
6561
+ afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
6562
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
6609
6563
  }
6610
- function matchAtPosition() {
6611
- if (match("position", /^at/, 0)) {
6612
- const positioning = matchPositioning();
6613
- return positioning || error("Missing positioning value"), positioning;
6614
- }
6564
+ onAttributeUpdate(graphic) {
6565
+ this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
6615
6566
  }
6616
- function matchPositioning() {
6617
- const location = {
6618
- x: matchDistance(),
6619
- y: matchDistance()
6620
- };
6621
- if (location.x || location.y) return {
6622
- type: "position",
6623
- value: location
6624
- };
6567
+ onSetStage(graphic, stage) {
6568
+ this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
6625
6569
  }
6626
- function matchListing(matcher) {
6627
- let captures = matcher();
6628
- const result = [];
6629
- if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
6630
- return result;
6570
+ onRemove(graphic) {
6571
+ this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
6631
6572
  }
6632
- function matchColorStop() {
6633
- const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
6634
- return color || error("Expected color definition"), color.length = matchDistance(), color;
6573
+ onRelease(graphic) {
6574
+ this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
6635
6575
  }
6636
- function matchDistance() {
6637
- return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
6576
+ onAddIncremental(graphic, group, stage) {
6577
+ this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
6638
6578
  }
6639
- function matchLength() {
6640
- return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
6579
+ onClearIncremental(group, stage) {
6580
+ this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
6641
6581
  }
6642
- function match(type, pattern, captureIndex) {
6643
- const captures = scan(pattern);
6644
- if (captures) return {
6645
- type: type,
6646
- value: captures[captureIndex]
6647
- };
6582
+ beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
6583
+ this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
6648
6584
  }
6649
- function scan(regexp) {
6650
- const blankCaptures = /^[\n\r\t\s]+/.exec(input);
6651
- blankCaptures && consume(blankCaptures[0].length);
6652
- const captures = regexp.exec(input);
6653
- return captures && consume(captures[0].length), captures;
6585
+ afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
6586
+ this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
6654
6587
  }
6655
- function consume(size) {
6656
- input = input.substr(size);
6588
+ updatePathProxyAABBBounds(aabbBounds, graphic) {
6589
+ const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
6590
+ if (!path) return !1;
6591
+ const boundsContext = new BoundsContext(aabbBounds);
6592
+ return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
6657
6593
  }
6658
- return function (code) {
6659
- return input = code.toString(), getAST();
6660
- };
6661
- }();
6662
- class GradientParser {
6663
- static IsGradient(c) {
6664
- return !("string" == typeof c && !c.includes("gradient"));
6594
+ updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
6595
+ const {
6596
+ textAlign: textAlign,
6597
+ textBaseline: textBaseline
6598
+ } = attribute;
6599
+ if (null != attribute.forceBoundsHeight) {
6600
+ const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
6601
+ dy = textLayoutOffsetY(textBaseline, h, h);
6602
+ aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
6603
+ }
6604
+ if (null != attribute.forceBoundsWidth) {
6605
+ const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
6606
+ dx = textDrawOffsetX(textAlign, w);
6607
+ aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
6608
+ }
6665
6609
  }
6666
- static IsGradientStr(c) {
6667
- return "string" == typeof c && c.includes("gradient");
6610
+ combindShadowAABBBounds(bounds, graphic) {
6611
+ if (graphic && graphic.shadowRoot) {
6612
+ const b = graphic.shadowRoot.AABBBounds;
6613
+ bounds.union(b);
6614
+ }
6668
6615
  }
6669
- static Parse(c) {
6670
- if (GradientParser.IsGradientStr(c)) try {
6671
- const datum = parse(c)[0];
6672
- if (datum) {
6673
- if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
6674
- if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
6675
- if ("conic" === datum.type) return GradientParser.ParseConic(datum);
6616
+ transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
6617
+ if (!aabbBounds.empty()) {
6618
+ const {
6619
+ scaleX = theme.scaleX,
6620
+ scaleY = theme.scaleY,
6621
+ stroke = theme.stroke,
6622
+ shadowBlur = theme.shadowBlur,
6623
+ lineWidth = theme.lineWidth,
6624
+ pickStrokeBuffer = theme.pickStrokeBuffer,
6625
+ strokeBoundsBuffer = theme.strokeBoundsBuffer
6626
+ } = attribute,
6627
+ tb1 = this.tempAABBBounds1,
6628
+ tb2 = this.tempAABBBounds2;
6629
+ if (stroke && lineWidth) {
6630
+ const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
6631
+ boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
6632
+ }
6633
+ if (shadowBlur) {
6634
+ const {
6635
+ shadowOffsetX = theme.shadowOffsetX,
6636
+ shadowOffsetY = theme.shadowOffsetY
6637
+ } = attribute,
6638
+ shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
6639
+ boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
6676
6640
  }
6677
- } catch (err) {
6678
- return c;
6679
6641
  }
6680
- return c;
6642
+ if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
6643
+ let updateMatrix = !0;
6644
+ const m = graphic.transMatrix;
6645
+ 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);
6681
6646
  }
6682
- static ParseConic(datum) {
6647
+ validCheck(attribute, theme, aabbBounds, graphic) {
6648
+ if (!graphic) return !0;
6649
+ if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
6650
+ if (graphic.shadowRoot) return !0;
6651
+ if (!graphic.valid) return aabbBounds.clear(), !1;
6683
6652
  const {
6684
- orientation: orientation,
6685
- colorStops = []
6686
- } = datum,
6687
- halfPi = pi / 2,
6688
- sa = parseFloat(orientation.value) / 180 * pi - halfPi;
6689
- return {
6690
- gradient: "conical",
6691
- x: .5,
6692
- y: .5,
6693
- startAngle: sa,
6694
- endAngle: sa + pi2,
6695
- stops: colorStops.map(item => ({
6696
- color: item.value,
6697
- offset: parseFloat(item.length.value) / 100
6698
- }))
6653
+ visible = theme.visible
6654
+ } = attribute;
6655
+ return !!visible || (aabbBounds.clear(), !1);
6656
+ }
6657
+ updateTempAABBBounds(aabbBounds) {
6658
+ const tb1 = this.tempAABBBounds1,
6659
+ tb2 = this.tempAABBBounds2;
6660
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
6661
+ tb1: tb1,
6662
+ tb2: tb2
6699
6663
  };
6700
6664
  }
6701
- static ParseRadial(datum) {
6665
+ };
6666
+ DefaultGraphicService = __decorate$J([injectable(), __param$x(0, inject(GraphicCreator$1)), __metadata$A("design:paramtypes", [Object])], DefaultGraphicService);
6667
+
6668
+ const result = {
6669
+ x: 0,
6670
+ y: 0,
6671
+ z: 0,
6672
+ lastModelMatrix: null
6673
+ };
6674
+ class BaseRender {
6675
+ init(contributions) {
6676
+ 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));
6677
+ }
6678
+ beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
6679
+ this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
6680
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
6681
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
6682
+ }
6683
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
6684
+ });
6685
+ }
6686
+ afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
6687
+ this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
6688
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
6689
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
6690
+ }
6691
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
6692
+ });
6693
+ }
6694
+ valid(graphic, defaultAttribute, fillCb, strokeCb) {
6702
6695
  const {
6703
- colorStops = []
6704
- } = datum;
6705
- return {
6706
- gradient: "radial",
6707
- x0: .5,
6708
- y0: .5,
6709
- x1: .5,
6710
- y1: .5,
6711
- r0: 0,
6712
- r1: 1,
6713
- stops: colorStops.map(item => ({
6714
- color: item.value,
6715
- offset: parseFloat(item.length.value) / 100
6716
- }))
6696
+ fill = defaultAttribute.fill,
6697
+ background: background,
6698
+ stroke = defaultAttribute.stroke,
6699
+ opacity = defaultAttribute.opacity,
6700
+ fillOpacity = defaultAttribute.fillOpacity,
6701
+ lineWidth = defaultAttribute.lineWidth,
6702
+ strokeOpacity = defaultAttribute.strokeOpacity,
6703
+ visible = defaultAttribute.visible
6704
+ } = graphic.attribute,
6705
+ fVisible = fillVisible(opacity, fillOpacity, fill),
6706
+ sVisible = strokeVisible(opacity, strokeOpacity),
6707
+ doFill = runFill(fill, background),
6708
+ doStroke = runStroke(stroke, lineWidth);
6709
+ return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
6710
+ fVisible: fVisible,
6711
+ sVisible: sVisible,
6712
+ doFill: doFill,
6713
+ doStroke: doStroke
6717
6714
  };
6718
6715
  }
6719
- static ParseLinear(datum) {
6716
+ transform(graphic, graphicAttribute, context) {
6717
+ let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
6720
6718
  const {
6721
- orientation: orientation,
6722
- colorStops = []
6723
- } = datum,
6724
- halfPi = pi / 2;
6725
- let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
6726
- for (; angle < 0;) angle += pi2;
6727
- for (; angle > pi2;) angle -= pi2;
6728
- let x0 = 0,
6729
- y0 = 0,
6730
- x1 = 0,
6731
- y1 = 0;
6732
- 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)), {
6733
- gradient: "linear",
6734
- x0: x0,
6735
- y0: y0,
6736
- x1: x1,
6737
- y1: y1,
6738
- stops: colorStops.map(item => ({
6739
- color: item.value,
6740
- offset: parseFloat(item.length.value) / 100
6741
- }))
6742
- };
6719
+ x = graphicAttribute.x,
6720
+ y = graphicAttribute.y,
6721
+ z = graphicAttribute.z,
6722
+ scaleX = graphicAttribute.scaleX,
6723
+ scaleY = graphicAttribute.scaleY,
6724
+ angle = graphicAttribute.angle,
6725
+ postMatrix: postMatrix
6726
+ } = graphic.attribute,
6727
+ lastModelMatrix = context.modelMatrix,
6728
+ camera = context.camera;
6729
+ result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
6730
+ const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
6731
+ onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
6732
+ if (shouldTransform3d) {
6733
+ const nextModelMatrix = mat4Allocate.allocate(),
6734
+ modelMatrix = mat4Allocate.allocate();
6735
+ 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);
6736
+ }
6737
+ if (onlyTranslate && !lastModelMatrix) {
6738
+ const point = graphic.getOffsetXY(graphicAttribute);
6739
+ result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
6740
+ } 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) {
6741
+ const point = graphic.getOffsetXY(graphicAttribute);
6742
+ result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
6743
+ } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
6744
+ return result;
6743
6745
  }
6744
- }
6745
-
6746
- function getScaledStroke(context, width, dpr) {
6747
- let strokeWidth = width;
6748
- const {
6749
- a: a,
6750
- b: b,
6751
- c: c,
6752
- d: d
6753
- } = context.currentMatrix,
6754
- scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
6755
- scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
6756
- return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
6757
- }
6758
- function createColor(context, c, params) {
6759
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
6760
- let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
6761
- if (!c || !0 === c) return "black";
6762
- let result, color;
6763
- if (isArray(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
6764
- if (color = GradientParser.Parse(color), "string" == typeof color) return color;
6765
- if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
6766
- const bounds = params.AABBBounds;
6767
- let w = bounds.x2 - bounds.x1,
6768
- h = bounds.y2 - bounds.y1,
6769
- x = bounds.x1 - offsetX,
6770
- y = bounds.y1 - offsetY;
6771
- if (params.attribute) {
6772
- const {
6773
- scaleX = 1,
6774
- scaleY = 1
6775
- } = params.attribute;
6776
- w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
6746
+ transformUseContext2d(graphic, graphicAttribute, z, context) {
6747
+ const camera = context.camera;
6748
+ if (this.camera = camera, camera) {
6749
+ const bounds = graphic.AABBBounds,
6750
+ width = bounds.x2 - bounds.x1,
6751
+ height = bounds.y2 - bounds.y1,
6752
+ p1 = context.project(0, 0, z),
6753
+ p2 = context.project(width, 0, z),
6754
+ p3 = context.project(width, height, z),
6755
+ _p1 = {
6756
+ x: 0,
6757
+ y: 0
6758
+ },
6759
+ _p2 = {
6760
+ x: width,
6761
+ y: 0
6762
+ },
6763
+ _p3 = {
6764
+ x: width,
6765
+ y: height
6766
+ };
6767
+ context.camera = null;
6768
+ const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
6769
+ m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
6770
+ m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
6771
+ m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
6772
+ m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
6773
+ 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,
6774
+ 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;
6775
+ context.setTransform(m11, m12, m21, m22, dx, dy, !0);
6777
6776
  }
6778
- "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));
6779
6777
  }
6780
- return result || "orange";
6781
- }
6782
- function createLinearGradient(context, color, x, y, w, h) {
6783
- var _a, _b, _c, _d;
6784
- 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);
6785
- return color.stops.forEach(stop => {
6786
- canvasGradient.addColorStop(stop.offset, stop.color);
6787
- }), canvasGradient;
6788
- }
6789
- function createRadialGradient(context, color, x, y, w, h) {
6790
- var _a, _b, _c, _d, _e, _f;
6791
- 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));
6792
- return color.stops.forEach(stop => {
6793
- canvasGradient.addColorStop(stop.offset, stop.color);
6794
- }), canvasGradient;
6795
- }
6796
- function createConicGradient(context, color, x, y, w, h) {
6797
- var _a, _b;
6798
- 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);
6799
- return color.stops.forEach(stop => {
6800
- canvasGradient.addColorStop(stop.offset, stop.color);
6801
- }), canvasGradient.GetPattern(w + x, h + y, undefined);
6778
+ restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
6779
+ this.camera && (context.camera = this.camera);
6780
+ }
6781
+ transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
6782
+ const p = context.project(x, y, z);
6783
+ 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();
6784
+ }
6785
+ _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
6786
+ const {
6787
+ context: context
6788
+ } = drawContext;
6789
+ if (!context) return;
6790
+ const {
6791
+ renderable: renderable
6792
+ } = graphic.attribute;
6793
+ if (!1 === renderable) return;
6794
+ context.highPerformanceSave();
6795
+ const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
6796
+ {
6797
+ x: x,
6798
+ y: y,
6799
+ z: z,
6800
+ lastModelMatrix: lastModelMatrix
6801
+ } = data;
6802
+ 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();
6803
+ }
6802
6804
  }
6803
6805
 
6804
6806
  var __decorate$I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -9197,7 +9199,10 @@ class ShadowRootDrawItemInterceptorContribution {
9197
9199
  const {
9198
9200
  context: context
9199
9201
  } = drawContext;
9200
- if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
9202
+ context.highPerformanceSave();
9203
+ const t1 = graphic.parent.globalTransMatrix,
9204
+ t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
9205
+ if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
9201
9206
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
9202
9207
  const m = graphic.globalTransMatrix.getInverse();
9203
9208
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -10217,6 +10222,9 @@ class BaseSymbol {
10217
10222
  bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
10218
10223
  } else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
10219
10224
  }
10225
+ parseSize(size) {
10226
+ return isNumber(size) ? size : Math.min(size[0], size[1]);
10227
+ }
10220
10228
  }
10221
10229
 
10222
10230
  function circle(ctx, r, x, y, z) {
@@ -10227,13 +10235,13 @@ class CircleSymbol extends BaseSymbol {
10227
10235
  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";
10228
10236
  }
10229
10237
  draw(ctx, size, x, y, z) {
10230
- return circle(ctx, size / 2, x, y, z);
10238
+ return circle(ctx, this.parseSize(size) / 2, x, y, z);
10231
10239
  }
10232
10240
  drawOffset(ctx, size, x, y, offset, z) {
10233
- return circle(ctx, size / 2 + offset, x, y, z);
10241
+ return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10234
10242
  }
10235
10243
  drawToSvgPath(size, x, y, z) {
10236
- const r = size / 2;
10244
+ const r = this.parseSize(size) / 2;
10237
10245
  return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
10238
10246
  }
10239
10247
  }
@@ -10250,10 +10258,10 @@ class CrossSymbol extends BaseSymbol {
10250
10258
  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";
10251
10259
  }
10252
10260
  draw(ctx, size, x, y, z) {
10253
- return cross(ctx, size / 6, x, y, z);
10261
+ return cross(ctx, this.parseSize(size) / 6, x, y, z);
10254
10262
  }
10255
10263
  drawOffset(ctx, size, x, y, offset, z) {
10256
- return crossOffset(ctx, size / 6, x, y, offset, z);
10264
+ return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
10257
10265
  }
10258
10266
  }
10259
10267
  var cross$1 = new CrossSymbol();
@@ -10266,13 +10274,13 @@ class DiamondSymbol extends BaseSymbol {
10266
10274
  super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
10267
10275
  }
10268
10276
  draw(ctx, size, x, y, z) {
10269
- return diamond(ctx, size / 2, x, y, z);
10277
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10270
10278
  }
10271
10279
  drawFitDir(ctx, size, x, y, z) {
10272
- return diamond(ctx, size / 2, x, y, z);
10280
+ return diamond(ctx, this.parseSize(size) / 2, x, y, z);
10273
10281
  }
10274
10282
  drawOffset(ctx, size, x, y, offset, z) {
10275
- return diamond(ctx, size / 2 + offset, x, y, z);
10283
+ return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
10276
10284
  }
10277
10285
  }
10278
10286
  var diamond$1 = new DiamondSymbol();
@@ -10286,10 +10294,10 @@ class SquareSymbol extends BaseSymbol {
10286
10294
  super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
10287
10295
  }
10288
10296
  draw(ctx, size, x, y) {
10289
- return square(ctx, size / 2, x, y);
10297
+ return square(ctx, this.parseSize(size) / 2, x, y);
10290
10298
  }
10291
10299
  drawOffset(ctx, size, x, y, offset) {
10292
- return square(ctx, size / 2 + offset, x, y);
10300
+ return square(ctx, this.parseSize(size) / 2 + offset, x, y);
10293
10301
  }
10294
10302
  }
10295
10303
  var square$1 = new SquareSymbol();
@@ -10303,10 +10311,10 @@ class TriangleUpSymbol extends BaseSymbol {
10303
10311
  super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
10304
10312
  }
10305
10313
  draw(ctx, size, x, y) {
10306
- return trianglUpOffset(ctx, size / 2, x, y);
10314
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
10307
10315
  }
10308
10316
  drawOffset(ctx, size, x, y, offset) {
10309
- return trianglUpOffset(ctx, size / 2, x, y, offset);
10317
+ return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10310
10318
  }
10311
10319
  }
10312
10320
  var triangleUp = new TriangleUpSymbol();
@@ -10338,10 +10346,10 @@ class StarSymbol extends BaseSymbol {
10338
10346
  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";
10339
10347
  }
10340
10348
  draw(ctx, size, transX, transY) {
10341
- return star(ctx, size / 2, transX, transY);
10349
+ return star(ctx, this.parseSize(size) / 2, transX, transY);
10342
10350
  }
10343
10351
  drawOffset(ctx, size, transX, transY, offset) {
10344
- return star(ctx, size / 2 + offset, transX, transY);
10352
+ return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10345
10353
  }
10346
10354
  }
10347
10355
  var star$1 = new StarSymbol();
@@ -10359,10 +10367,10 @@ class ArrowSymbol extends BaseSymbol {
10359
10367
  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";
10360
10368
  }
10361
10369
  draw(ctx, size, transX, transY) {
10362
- return arrow(ctx, size / 2, transX, transY);
10370
+ return arrow(ctx, this.parseSize(size) / 2, transX, transY);
10363
10371
  }
10364
10372
  drawOffset(ctx, size, transX, transY, offset) {
10365
- return arrow(ctx, size / 2 + offset, transX, transY);
10373
+ return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10366
10374
  }
10367
10375
  }
10368
10376
  var arrow$1 = new ArrowSymbol();
@@ -10376,10 +10384,10 @@ class WedgeSymbol extends BaseSymbol {
10376
10384
  super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
10377
10385
  }
10378
10386
  draw(ctx, size, transX, transY) {
10379
- return wedge(ctx, size / 2, transX, transY);
10387
+ return wedge(ctx, this.parseSize(size) / 2, transX, transY);
10380
10388
  }
10381
10389
  drawOffset(ctx, size, transX, transY, offset) {
10382
- return wedge(ctx, size / 2 + offset, transX, transY);
10390
+ return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10383
10391
  }
10384
10392
  }
10385
10393
  var wedge$1 = new WedgeSymbol();
@@ -10392,10 +10400,10 @@ class StrokeSymbol extends BaseSymbol {
10392
10400
  super(...arguments), this.type = "stroke", this.pathStr = "";
10393
10401
  }
10394
10402
  draw(ctx, size, transX, transY) {
10395
- return stroke(ctx, size / 2, transX, transY);
10403
+ return stroke(ctx, this.parseSize(size) / 2, transX, transY);
10396
10404
  }
10397
10405
  drawOffset(ctx, size, transX, transY, offset) {
10398
- return stroke(ctx, size / 2 + offset, transX, transY);
10406
+ return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10399
10407
  }
10400
10408
  }
10401
10409
  var stroke$1 = new StrokeSymbol();
@@ -10417,10 +10425,10 @@ class WyeSymbol extends BaseSymbol {
10417
10425
  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";
10418
10426
  }
10419
10427
  draw(ctx, size, transX, transY) {
10420
- return wye(ctx, size / 2, transX, transY);
10428
+ return wye(ctx, this.parseSize(size) / 2, transX, transY);
10421
10429
  }
10422
10430
  drawOffset(ctx, size, transX, transY, offset) {
10423
- return wye(ctx, size / 2 + offset, transX, transY);
10431
+ return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
10424
10432
  }
10425
10433
  }
10426
10434
  var wye$1 = new WyeSymbol();
@@ -10433,10 +10441,10 @@ class TriangleLeftSymbol extends BaseSymbol {
10433
10441
  super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
10434
10442
  }
10435
10443
  draw(ctx, size, x, y) {
10436
- return trianglLeftOffset(ctx, size / 2, x, y, 0);
10444
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
10437
10445
  }
10438
10446
  drawOffset(ctx, size, x, y, offset) {
10439
- return trianglLeftOffset(ctx, size / 2, x, y, offset);
10447
+ return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10440
10448
  }
10441
10449
  }
10442
10450
  var triangleLeft = new TriangleLeftSymbol();
@@ -10450,10 +10458,10 @@ class TriangleRightSymbol extends BaseSymbol {
10450
10458
  super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
10451
10459
  }
10452
10460
  draw(ctx, size, x, y) {
10453
- return trianglRightOffset(ctx, size / 2, x, y);
10461
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
10454
10462
  }
10455
10463
  drawOffset(ctx, size, x, y, offset) {
10456
- return trianglRightOffset(ctx, size / 2, x, y, offset);
10464
+ return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10457
10465
  }
10458
10466
  }
10459
10467
  var triangleRight = new TriangleRightSymbol();
@@ -10467,10 +10475,10 @@ class TriangleDownSymbol extends BaseSymbol {
10467
10475
  super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
10468
10476
  }
10469
10477
  draw(ctx, size, x, y) {
10470
- return trianglDownOffset(ctx, size / 2, x, y);
10478
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
10471
10479
  }
10472
10480
  drawOffset(ctx, size, x, y, offset) {
10473
- return trianglDownOffset(ctx, size / 2, x, y, offset);
10481
+ return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
10474
10482
  }
10475
10483
  }
10476
10484
  var triangleDown = new TriangleDownSymbol();
@@ -10485,10 +10493,10 @@ class ThinTriangleSymbol extends BaseSymbol {
10485
10493
  super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
10486
10494
  }
10487
10495
  draw(ctx, size, x, y) {
10488
- return thinTriangle(ctx, size / 2 / sqrt3, x, y);
10496
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
10489
10497
  }
10490
10498
  drawOffset(ctx, size, x, y, offset) {
10491
- return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
10499
+ return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
10492
10500
  }
10493
10501
  }
10494
10502
  var thinTriangle$1 = new ThinTriangleSymbol();
@@ -10502,10 +10510,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
10502
10510
  super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
10503
10511
  }
10504
10512
  draw(ctx, size, transX, transY) {
10505
- return arrow2Left(ctx, size / 4, transX, transY);
10513
+ return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
10506
10514
  }
10507
10515
  drawOffset(ctx, size, transX, transY, offset) {
10508
- return arrow2Left(ctx, size / 4 + offset, transX, transY);
10516
+ return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10509
10517
  }
10510
10518
  }
10511
10519
  var arrow2Left$1 = new Arrow2LeftSymbol();
@@ -10519,10 +10527,10 @@ class Arrow2RightSymbol extends BaseSymbol {
10519
10527
  super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
10520
10528
  }
10521
10529
  draw(ctx, size, transX, transY) {
10522
- return arrow2Right(ctx, size / 4, transX, transY);
10530
+ return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
10523
10531
  }
10524
10532
  drawOffset(ctx, size, transX, transY, offset) {
10525
- return arrow2Right(ctx, size / 4 + offset, transX, transY);
10533
+ return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10526
10534
  }
10527
10535
  }
10528
10536
  var arrow2Right$1 = new Arrow2RightSymbol();
@@ -10536,10 +10544,10 @@ class Arrow2UpSymbol extends BaseSymbol {
10536
10544
  super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
10537
10545
  }
10538
10546
  draw(ctx, size, transX, transY) {
10539
- return arrow2Up(ctx, size / 4, transX, transY);
10547
+ return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
10540
10548
  }
10541
10549
  drawOffset(ctx, size, transX, transY, offset) {
10542
- return arrow2Up(ctx, size / 4 + offset, transX, transY);
10550
+ return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10543
10551
  }
10544
10552
  }
10545
10553
  var arrow2Up$1 = new Arrow2UpSymbol();
@@ -10553,10 +10561,10 @@ class Arrow2DownSymbol extends BaseSymbol {
10553
10561
  super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
10554
10562
  }
10555
10563
  draw(ctx, size, transX, transY) {
10556
- return arrow2Down(ctx, size / 4, transX, transY);
10564
+ return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
10557
10565
  }
10558
10566
  drawOffset(ctx, size, transX, transY, offset) {
10559
- return arrow2Down(ctx, size / 4 + offset, transX, transY);
10567
+ return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
10560
10568
  }
10561
10569
  }
10562
10570
  var arrow2Down$1 = new Arrow2DownSymbol();
@@ -10569,13 +10577,13 @@ class LineVSymbol extends BaseSymbol {
10569
10577
  super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
10570
10578
  }
10571
10579
  draw(ctx, size, x, y, z) {
10572
- return lineV(ctx, size / 2, x, y);
10580
+ return lineV(ctx, this.parseSize(size) / 2, x, y);
10573
10581
  }
10574
10582
  drawOffset(ctx, size, x, y, offset, z) {
10575
- return lineV(ctx, size / 2 + offset, x, y);
10583
+ return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
10576
10584
  }
10577
10585
  drawToSvgPath(size, x, y, z) {
10578
- const r = size / 2;
10586
+ const r = this.parseSize(size) / 2;
10579
10587
  return `M ${x}, ${y - r} L ${x},${y + r}`;
10580
10588
  }
10581
10589
  }
@@ -10589,13 +10597,13 @@ class LineHSymbol extends BaseSymbol {
10589
10597
  super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
10590
10598
  }
10591
10599
  draw(ctx, size, x, y, z) {
10592
- return lineH(ctx, size / 2, x, y);
10600
+ return lineH(ctx, this.parseSize(size) / 2, x, y);
10593
10601
  }
10594
10602
  drawOffset(ctx, size, x, y, offset, z) {
10595
- return lineH(ctx, size / 2 + offset, x, y);
10603
+ return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
10596
10604
  }
10597
10605
  drawToSvgPath(size, x, y, z) {
10598
- const r = size / 2;
10606
+ const r = this.parseSize(size) / 2;
10599
10607
  return `M ${x - r}, ${y} L ${x + r},${y}`;
10600
10608
  }
10601
10609
  }
@@ -10609,13 +10617,13 @@ class CloseSymbol extends BaseSymbol {
10609
10617
  super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
10610
10618
  }
10611
10619
  draw(ctx, size, x, y, z) {
10612
- return close(ctx, size / 2, x, y);
10620
+ return close(ctx, this.parseSize(size) / 2, x, y);
10613
10621
  }
10614
10622
  drawOffset(ctx, size, x, y, offset, z) {
10615
- return close(ctx, size / 2 + offset, x, y);
10623
+ return close(ctx, this.parseSize(size) / 2 + offset, x, y);
10616
10624
  }
10617
10625
  drawToSvgPath(size, x, y, z) {
10618
- const r = size / 2;
10626
+ const r = this.parseSize(size) / 2;
10619
10627
  return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
10620
10628
  }
10621
10629
  }
@@ -10649,15 +10657,18 @@ class CustomSymbolClass {
10649
10657
  this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
10650
10658
  }
10651
10659
  drawOffset(ctx, size, x, y, offset, z, cb) {
10652
- return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10660
+ return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
10653
10661
  ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
10654
10662
  }), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
10655
10663
  }
10656
10664
  draw(ctx, size, x, y, z, cb) {
10657
- return this.drawOffset(ctx, size, x, y, 0, z, cb);
10665
+ return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
10666
+ }
10667
+ parseSize(size) {
10668
+ return isNumber(size) ? size : Math.min(size[0], size[1]);
10658
10669
  }
10659
10670
  bounds(size, bounds) {
10660
- if (this.isSvg) {
10671
+ if (size = this.parseSize(size), this.isSvg) {
10661
10672
  if (!this.svgCache) return;
10662
10673
  return bounds.clear(), void this.svgCache.forEach(_ref => {
10663
10674
  let {
@@ -11161,7 +11172,11 @@ class Paragraph {
11161
11172
  case "sub":
11162
11173
  baseline += this.descent / 2;
11163
11174
  }
11164
- "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();
11175
+ "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);
11176
+ const {
11177
+ lineWidth = 1
11178
+ } = this.character;
11179
+ 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();
11165
11180
  }
11166
11181
  getWidthWithEllips(direction) {
11167
11182
  let text = this.text;
@@ -11384,12 +11399,18 @@ class Line {
11384
11399
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
11385
11400
  }
11386
11401
  }
11387
- this.paragraphs.map((paragraph, index) => {
11402
+ this.paragraphs.forEach((paragraph, index) => {
11388
11403
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
11389
11404
  x: x + paragraph._x,
11390
11405
  y: y + paragraph._y
11391
11406
  }), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
11392
- paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
11407
+ const b = {
11408
+ x1: this.left,
11409
+ y1: this.top,
11410
+ x2: this.left + this.actualWidth,
11411
+ y2: this.top + this.height
11412
+ };
11413
+ applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
11393
11414
  });
11394
11415
  }
11395
11416
  getWidthWithEllips(ellipsis) {
@@ -11412,7 +11433,7 @@ class Line {
11412
11433
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
11413
11434
  }
11414
11435
  let width = 0;
11415
- return this.paragraphs.map((paragraph, index) => {
11436
+ return this.paragraphs.forEach((paragraph, index) => {
11416
11437
  width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
11417
11438
  }), width;
11418
11439
  }
@@ -15996,24 +16017,29 @@ function defaultLabelPosition(type) {
15996
16017
  return DefaultPositions;
15997
16018
  }
15998
16019
  }
15999
- function clampText(text, width, height) {
16020
+ function clampText(text, width, height, padding = {}) {
16000
16021
  const { x1, x2, y1, y2 } = text.AABBBounds;
16022
+ const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
16001
16023
  const minX = Math.min(x1, x2);
16002
16024
  const maxX = Math.max(x1, x2);
16003
16025
  const minY = Math.min(y1, y2);
16004
16026
  const maxY = Math.max(y1, y2);
16027
+ const minXWithPadding = 0 - left;
16028
+ const maxXWithPadding = width + right;
16029
+ const minYWithPadding = 0 - top;
16030
+ const maxYWithPadding = height + bottom;
16005
16031
  let dx = 0;
16006
16032
  let dy = 0;
16007
- if (minX < 0 && maxX - minX <= width) {
16033
+ if (minX < minXWithPadding && maxX - minX <= width) {
16008
16034
  dx = -minX;
16009
16035
  }
16010
- else if (maxX > width && minX - (maxX - width) >= 0) {
16036
+ else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
16011
16037
  dx = width - maxX;
16012
16038
  }
16013
- if (minY < 0 && maxY - minY <= height) {
16039
+ if (minY < minYWithPadding && maxY - minY <= height) {
16014
16040
  dy = -minY;
16015
16041
  }
16016
- else if (maxY > height && minY - (maxY - height) >= 0) {
16042
+ else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
16017
16043
  dy = height - maxY;
16018
16044
  }
16019
16045
  return { dx, dy };
@@ -16313,69 +16339,177 @@ function loadLabelComponent() {
16313
16339
  registerLine();
16314
16340
  }
16315
16341
 
16316
- function shiftY(texts, option = {}) {
16317
- const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE } = option;
16342
+ const isIntersect = (top, bottom) => {
16343
+ return Math.ceil(top) > Math.floor(bottom);
16344
+ };
16345
+ const isXIntersect = ([a, b], [c, d]) => {
16346
+ return d > a && b > c;
16347
+ };
16348
+ function getIntersectionLength(range1, range2) {
16349
+ const [start1, end1] = range1;
16350
+ const [start2, end2] = range2;
16351
+ const start = Math.max(start1, start2);
16352
+ const end = Math.min(end1, end2);
16353
+ return Math.max(0, end - start);
16354
+ }
16355
+ function shiftY(texts, option) {
16356
+ const { maxY = Number.MAX_VALUE, labelling, globalShiftY = { enable: true, maxIterations: 10, maxError: 0.1, padding: 1 } } = option;
16318
16357
  const n = texts.length;
16319
16358
  if (n <= 1) {
16320
16359
  return texts;
16321
16360
  }
16322
- const isIntersect = ([a, b], [c, d]) => {
16323
- return d > a && b > c;
16324
- };
16361
+ const xMap = new Map();
16325
16362
  const textInformation = new Map();
16326
- const getY0 = (text) => textInformation.get(text).y0;
16327
- const getY = (text) => textInformation.get(text).y;
16363
+ const getY1Initial = (text) => textInformation.get(text).y1Initial;
16328
16364
  const getHeight = (text) => textInformation.get(text).height;
16365
+ const getY1 = (text) => textInformation.get(text).y1;
16366
+ const getY = (text) => textInformation.get(text).y;
16367
+ const getX = (text) => textInformation.get(text).x;
16329
16368
  const getX1 = (text) => textInformation.get(text).x1;
16330
16369
  const getX2 = (text) => textInformation.get(text).x2;
16331
- const setY = (text, y) => {
16332
- textInformation.get(text).y = y;
16370
+ const getAdjustAttempts = (text) => textInformation.get(text).attempts;
16371
+ const setY1 = (text, y) => {
16372
+ textInformation.get(text).y1 = y;
16373
+ };
16374
+ const setAdjustAttempts = (text, attempts) => {
16375
+ textInformation.get(text).attempts = attempts;
16333
16376
  };
16377
+ function adjustPositionInOneGroup(texts) {
16378
+ if (texts.length === 1) {
16379
+ return;
16380
+ }
16381
+ for (let i = texts.length - 1; i > 0; i--) {
16382
+ const curText = texts[i];
16383
+ const upperText = texts[i - 1];
16384
+ const lowerText = texts[i + 1];
16385
+ if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
16386
+ const { y } = labelling(curText);
16387
+ if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
16388
+ if (y + getHeight(curText) / 2 <= maxY) {
16389
+ setY1(curText, getY1(curText) + y - getY(curText));
16390
+ }
16391
+ }
16392
+ }
16393
+ }
16394
+ }
16395
+ texts.sort((a, b) => a.attribute.x - b.attribute.x);
16334
16396
  for (const text of texts) {
16335
16397
  const { y1, y2, x1, x2 } = text.AABBBounds;
16336
- textInformation.set(text, { y0: y1, y: y1, height: y2 - y1, x1, x2 });
16398
+ const { x, y } = text.attribute;
16399
+ textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x, attempts: 0 });
16400
+ let hasRange = false;
16401
+ for (const [range, xGroupTexts] of xMap) {
16402
+ const { start, end } = range;
16403
+ if (x1 >= start && x2 <= end) {
16404
+ xGroupTexts.push(text);
16405
+ hasRange = true;
16406
+ }
16407
+ else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
16408
+ const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16409
+ xGroupTexts.push(text);
16410
+ xMap.set(newRange, xGroupTexts);
16411
+ xMap.delete(range);
16412
+ hasRange = true;
16413
+ }
16414
+ else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
16415
+ const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
16416
+ xGroupTexts.push(text);
16417
+ xMap.set(newRange, xGroupTexts);
16418
+ xMap.delete(range);
16419
+ hasRange = true;
16420
+ }
16421
+ if (hasRange) {
16422
+ break;
16423
+ }
16424
+ }
16425
+ if (!hasRange) {
16426
+ xMap.set({ start: x1, end: x2 }, [text]);
16427
+ }
16337
16428
  }
16338
- for (let iter = 0; iter < maxIterations; iter++) {
16339
- texts.sort((a, b) => getY(a) - getY(b));
16340
- let error = 0;
16341
- for (let i = 0; i < n - 1; i++) {
16342
- const curText = texts[i];
16343
- let j = i + 1;
16344
- let nextText;
16345
- while ((nextText = texts[j]) &&
16346
- !isIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16347
- j += 1;
16348
- }
16349
- if (nextText) {
16350
- const y0 = getY(curText);
16351
- const h0 = getHeight(curText);
16352
- const y1 = getY(nextText);
16353
- const delta = y1 - (y0 + h0);
16354
- if (delta < padding) {
16355
- const newDelta = (padding - delta) / 2;
16356
- error = Math.max(error, newDelta);
16357
- if (y1 + newDelta + getHeight(nextText) > maxY) {
16358
- setY(curText, y0 - (padding - delta));
16359
- }
16360
- else if (y0 - newDelta < 0) {
16361
- setY(nextText, y1 + (padding - delta));
16362
- }
16363
- else {
16364
- setY(curText, y0 - newDelta);
16365
- setY(nextText, y1 + newDelta);
16429
+ for (const xTexts of xMap.values()) {
16430
+ xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
16431
+ adjustPositionInOneGroup(xTexts);
16432
+ }
16433
+ if (globalShiftY.enable !== false) {
16434
+ const { maxIterations = 10, maxError = 0.1, padding = 1, maxAttempts = 1000, deltaYTolerance = Number.MAX_VALUE } = globalShiftY;
16435
+ for (let iter = 0; iter < maxIterations; iter++) {
16436
+ texts.sort((a, b) => getY1(a) - getY1(b));
16437
+ let error = 0;
16438
+ for (let i = 0; i < n - 1; i++) {
16439
+ const curText = texts[i];
16440
+ if (getAdjustAttempts(curText) >= maxAttempts) {
16441
+ continue;
16442
+ }
16443
+ let j = i + 1;
16444
+ let nextText;
16445
+ while ((nextText = texts[j]) &&
16446
+ !isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16447
+ j += 1;
16448
+ }
16449
+ if (nextText) {
16450
+ const y1 = getY1(curText);
16451
+ const h0 = getHeight(curText);
16452
+ const nextY1 = getY1(nextText);
16453
+ const delta = nextY1 - (y1 + h0);
16454
+ if (delta < padding) {
16455
+ const newDelta = (padding - delta) / 2;
16456
+ error = Math.max(error, newDelta);
16457
+ if (y1 + newDelta + getHeight(nextText) > maxY) {
16458
+ const newY1 = y1 - (padding - delta);
16459
+ const curTextDelta = getY1Initial(curText) - newY1;
16460
+ if (Math.abs(curTextDelta) <= deltaYTolerance) {
16461
+ setY1(curText, newY1);
16462
+ setAdjustAttempts(curText, getAdjustAttempts(curText) + 1);
16463
+ }
16464
+ }
16465
+ else if (y1 - newDelta < 0) {
16466
+ const newY1 = nextY1 + (padding - delta);
16467
+ const nextTextDelta = getY1Initial(nextText) - newY1;
16468
+ if (Math.abs(nextTextDelta) <= deltaYTolerance) {
16469
+ setY1(nextText, newY1);
16470
+ setAdjustAttempts(nextText, getAdjustAttempts(nextText) + 1);
16471
+ }
16472
+ }
16473
+ else {
16474
+ const newCurY1 = y1 - newDelta;
16475
+ const curTextDelta = getY1Initial(curText) - newCurY1;
16476
+ const newNextY1 = nextY1 + newDelta;
16477
+ const nextTextDelta = getY1Initial(nextText) - newNextY1;
16478
+ if (Math.abs(curTextDelta) <= deltaYTolerance && Math.abs(nextTextDelta) <= deltaYTolerance) {
16479
+ setY1(curText, newCurY1);
16480
+ setY1(nextText, newNextY1);
16481
+ setAdjustAttempts(curText, getAdjustAttempts(curText) + 1);
16482
+ setAdjustAttempts(nextText, getAdjustAttempts(nextText) + 1);
16483
+ }
16484
+ }
16366
16485
  }
16367
16486
  }
16368
16487
  }
16369
- }
16370
- if (error < maxError) {
16371
- break;
16488
+ if (error < maxError) {
16489
+ break;
16490
+ }
16372
16491
  }
16373
16492
  }
16374
16493
  for (const text of texts) {
16375
- const finalY = text.attribute.y + getY(text) - getY0(text);
16494
+ const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
16376
16495
  text.setAttribute('y', finalY);
16377
16496
  }
16378
- return texts;
16497
+ const result = [];
16498
+ texts.sort((a, b) => a.attribute.x - b.attribute.x);
16499
+ let start = 0;
16500
+ let end = texts.length - 1;
16501
+ while (start <= end) {
16502
+ if (start === end) {
16503
+ result.push(texts[start]);
16504
+ }
16505
+ else {
16506
+ result.push(texts[start]);
16507
+ result.push(texts[end]);
16508
+ }
16509
+ start++;
16510
+ end--;
16511
+ }
16512
+ return result;
16379
16513
  }
16380
16514
 
16381
16515
  loadLabelComponent();
@@ -16721,18 +16855,25 @@ class LabelBase extends AbstractComponent {
16721
16855
  if (clampForce) {
16722
16856
  for (let i = 0; i < result.length; i++) {
16723
16857
  const text = labels[i];
16724
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
16858
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
16725
16859
  if (dx !== 0 || dy !== 0) {
16726
16860
  text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
16861
+ text._isClamped = true;
16727
16862
  }
16728
16863
  }
16729
16864
  }
16730
- result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy));
16865
+ result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
16866
+ const baseMark = this.getRelatedGraphic(text.attribute);
16867
+ const graphicBound = this._isCollectionBase
16868
+ ? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
16869
+ : this.getGraphicBounds(baseMark, text);
16870
+ return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
16871
+ } }));
16731
16872
  for (let i = 0; i < result.length; i++) {
16732
16873
  const text = result[i];
16733
16874
  const bounds = text.AABBBounds;
16734
16875
  const range = boundToRange(bmpTool, bounds, true);
16735
- if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
16876
+ if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
16736
16877
  bitmap.setRange(range);
16737
16878
  }
16738
16879
  else {
@@ -16805,7 +16946,7 @@ class LabelBase extends AbstractComponent {
16805
16946
  }
16806
16947
  }
16807
16948
  if (!hasPlace && clampForce) {
16808
- const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
16949
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
16809
16950
  if (dx === 0 && dy === 0) {
16810
16951
  if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
16811
16952
  bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
@@ -29555,6 +29696,6 @@ EmptyTip.defaultAttributes = {
29555
29696
  }
29556
29697
  };
29557
29698
 
29558
- const version = "0.20.15";
29699
+ const version = "0.20.16";
29559
29700
 
29560
29701
  export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };