@visactor/vrender-components 0.20.14 → 0.20.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/type.d.ts +2 -2
- package/cjs/axis/type.js.map +1 -1
- package/cjs/data-zoom/type.d.ts +1 -1
- package/cjs/data-zoom/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/label/base.js +12 -7
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +6 -1
- package/cjs/label/overlap/place.js +4 -4
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/shiftY.d.ts +10 -4
- package/cjs/label/overlap/shiftY.js +103 -27
- package/cjs/label/overlap/shiftY.js.map +1 -1
- package/cjs/legend/color/type.d.ts +2 -2
- package/cjs/legend/color/type.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +1 -1
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/marker/type.d.ts +2 -2
- package/cjs/marker/type.js.map +1 -1
- package/cjs/player/type/discrete-player.d.ts +3 -3
- package/cjs/player/type/discrete-player.js.map +1 -1
- package/cjs/player/type/index.d.ts +2 -2
- package/cjs/player/type/index.js.map +1 -1
- package/cjs/timeline/type.js.map +1 -1
- package/dist/index.es.js +890 -740
- package/es/axis/type.d.ts +2 -2
- package/es/axis/type.js.map +1 -1
- package/es/data-zoom/type.d.ts +1 -1
- package/es/data-zoom/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interface.js.map +1 -1
- package/es/label/base.js +12 -7
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +6 -1
- package/es/label/overlap/place.js +4 -4
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/shiftY.d.ts +10 -4
- package/es/label/overlap/shiftY.js +99 -24
- package/es/label/overlap/shiftY.js.map +1 -1
- package/es/legend/color/type.d.ts +2 -2
- package/es/legend/color/type.js.map +1 -1
- package/es/legend/discrete/type.d.ts +1 -1
- package/es/legend/discrete/type.js.map +1 -1
- package/es/marker/type.d.ts +2 -2
- package/es/marker/type.js.map +1 -1
- package/es/player/type/discrete-player.d.ts +3 -3
- package/es/player/type/discrete-player.js.map +1 -1
- package/es/player/type/index.d.ts +2 -2
- package/es/player/type/index.js.map +1 -1
- package/es/timeline/type.js.map +1 -1
- 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,
|
|
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 {
|
|
@@ -2086,7 +2086,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2086
2086
|
globalZIndex: 1,
|
|
2087
2087
|
globalCompositeOperation: "",
|
|
2088
2088
|
overflow: "hidden",
|
|
2089
|
-
shadowPickMode: "graphic"
|
|
2089
|
+
shadowPickMode: "graphic",
|
|
2090
|
+
keepStrokeScale: !1
|
|
2090
2091
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2091
2092
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2092
2093
|
startAngle: 0,
|
|
@@ -2230,6 +2231,292 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
|
|
|
2230
2231
|
class Application {}
|
|
2231
2232
|
const application = new Application();
|
|
2232
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
|
+
|
|
2233
2520
|
const DIRECTION_KEY = {
|
|
2234
2521
|
horizontal: {
|
|
2235
2522
|
width: "width",
|
|
@@ -2281,14 +2568,16 @@ const setTextStyle = (ctx, character) => {
|
|
|
2281
2568
|
fontFamily: character.fontFamily || "sans-serif"
|
|
2282
2569
|
});
|
|
2283
2570
|
};
|
|
2284
|
-
function applyFillStyle(ctx, character) {
|
|
2571
|
+
function applyFillStyle(ctx, character, b) {
|
|
2285
2572
|
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
2286
2573
|
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
2287
2574
|
const {
|
|
2288
2575
|
fillOpacity = 1,
|
|
2289
2576
|
opacity = 1
|
|
2290
2577
|
} = character;
|
|
2291
|
-
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle =
|
|
2578
|
+
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
|
|
2579
|
+
AABBBounds: b
|
|
2580
|
+
}) : fillStyle, setTextStyle(ctx, character);
|
|
2292
2581
|
}
|
|
2293
2582
|
function applyStrokeStyle(ctx, character) {
|
|
2294
2583
|
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
@@ -6144,660 +6433,374 @@ class DefaultMatrixAllocate {
|
|
|
6144
6433
|
allocateByObj(matrix) {
|
|
6145
6434
|
if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
|
|
6146
6435
|
const m = this.pools.pop();
|
|
6147
|
-
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;
|
|
6148
|
-
}
|
|
6149
|
-
free(d) {
|
|
6150
|
-
this.pools.push(d);
|
|
6151
|
-
}
|
|
6152
|
-
get length() {
|
|
6153
|
-
return this.pools.length;
|
|
6154
|
-
}
|
|
6155
|
-
release() {
|
|
6156
|
-
this.pools = [];
|
|
6157
|
-
}
|
|
6158
|
-
}
|
|
6159
|
-
class DefaultMat4Allocate {
|
|
6160
|
-
constructor() {
|
|
6161
|
-
this.pools = [];
|
|
6162
|
-
}
|
|
6163
|
-
static identity(out) {
|
|
6164
|
-
return identityMat4(out);
|
|
6165
|
-
}
|
|
6166
|
-
allocate() {
|
|
6167
|
-
if (!this.pools.length) return createMat4();
|
|
6168
|
-
const m = this.pools.pop();
|
|
6169
|
-
return DefaultMat4Allocate.identity(m), m;
|
|
6170
|
-
}
|
|
6171
|
-
allocateByObj(d) {
|
|
6172
|
-
let m;
|
|
6173
|
-
m = this.pools.length ? this.pools.pop() : createMat4();
|
|
6174
|
-
for (let i = 0; i < m.length; i++) m[i] = d[i];
|
|
6175
|
-
return m;
|
|
6176
|
-
}
|
|
6177
|
-
free(m) {
|
|
6178
|
-
m && this.pools.push(m);
|
|
6179
|
-
}
|
|
6180
|
-
get length() {
|
|
6181
|
-
return this.pools.length;
|
|
6182
|
-
}
|
|
6183
|
-
release() {
|
|
6184
|
-
this.pools = [];
|
|
6185
|
-
}
|
|
6186
|
-
}
|
|
6187
|
-
const matrixAllocate = new DefaultMatrixAllocate();
|
|
6188
|
-
const mat4Allocate = new DefaultMat4Allocate();
|
|
6189
|
-
|
|
6190
|
-
var __decorate$J = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
6191
|
-
var d,
|
|
6192
|
-
c = arguments.length,
|
|
6193
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
6194
|
-
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);
|
|
6195
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6196
|
-
},
|
|
6197
|
-
__metadata$A = undefined && undefined.__metadata || function (k, v) {
|
|
6198
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
6199
|
-
},
|
|
6200
|
-
__param$x = undefined && undefined.__param || function (paramIndex, decorator) {
|
|
6201
|
-
return function (target, key) {
|
|
6202
|
-
decorator(target, key, paramIndex);
|
|
6203
|
-
};
|
|
6204
|
-
};
|
|
6205
|
-
function getModelMatrix(out, graphic, theme) {
|
|
6206
|
-
var _a;
|
|
6207
|
-
const {
|
|
6208
|
-
x = theme.x,
|
|
6209
|
-
y = theme.y,
|
|
6210
|
-
z = theme.z,
|
|
6211
|
-
dx = theme.dx,
|
|
6212
|
-
dy = theme.dy,
|
|
6213
|
-
dz = theme.dz,
|
|
6214
|
-
scaleX = theme.scaleX,
|
|
6215
|
-
scaleY = theme.scaleY,
|
|
6216
|
-
scaleZ = theme.scaleZ,
|
|
6217
|
-
alpha = theme.alpha,
|
|
6218
|
-
beta = theme.beta,
|
|
6219
|
-
angle = theme.angle,
|
|
6220
|
-
anchor3d = graphic.attribute.anchor,
|
|
6221
|
-
anchor: anchor
|
|
6222
|
-
} = graphic.attribute,
|
|
6223
|
-
_anchor = [0, 0, 0];
|
|
6224
|
-
if (anchor3d) {
|
|
6225
|
-
if ("string" == typeof anchor3d[0]) {
|
|
6226
|
-
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
6227
|
-
bounds = graphic.AABBBounds;
|
|
6228
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
6229
|
-
} else _anchor[0] = anchor3d[0];
|
|
6230
|
-
if ("string" == typeof anchor3d[1]) {
|
|
6231
|
-
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
6232
|
-
bounds = graphic.AABBBounds;
|
|
6233
|
-
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
6234
|
-
} else _anchor[1] = anchor3d[1];
|
|
6235
|
-
_anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
|
|
6236
|
-
}
|
|
6237
|
-
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) {
|
|
6238
|
-
const m = mat4Allocate.allocate(),
|
|
6239
|
-
_anchor = [0, 0];
|
|
6240
|
-
if (anchor) {
|
|
6241
|
-
if ("string" == typeof anchor3d[0]) {
|
|
6242
|
-
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
6243
|
-
bounds = graphic.AABBBounds;
|
|
6244
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
6245
|
-
} else _anchor[0] = anchor3d[0];
|
|
6246
|
-
if ("string" == typeof anchor3d[1]) {
|
|
6247
|
-
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
6248
|
-
bounds = graphic.AABBBounds;
|
|
6249
|
-
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
6250
|
-
} else _anchor[1] = anchor3d[1];
|
|
6251
|
-
}
|
|
6252
|
-
translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
|
|
6253
|
-
}
|
|
6254
|
-
}
|
|
6255
|
-
function shouldUseMat4(graphic) {
|
|
6256
|
-
const {
|
|
6257
|
-
alpha: alpha,
|
|
6258
|
-
beta: beta
|
|
6259
|
-
} = graphic.attribute;
|
|
6260
|
-
return alpha || beta;
|
|
6261
|
-
}
|
|
6262
|
-
let DefaultGraphicService = class {
|
|
6263
|
-
constructor(creator) {
|
|
6264
|
-
this.creator = creator, this.hooks = {
|
|
6265
|
-
onAttributeUpdate: new SyncHook(["graphic"]),
|
|
6266
|
-
onSetStage: new SyncHook(["graphic", "stage"]),
|
|
6267
|
-
onRemove: new SyncHook(["graphic"]),
|
|
6268
|
-
onRelease: new SyncHook(["graphic"]),
|
|
6269
|
-
onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
6270
|
-
onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
6271
|
-
beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
|
|
6272
|
-
afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
|
|
6273
|
-
}, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
|
|
6274
|
-
}
|
|
6275
|
-
onAttributeUpdate(graphic) {
|
|
6276
|
-
this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
|
|
6277
|
-
}
|
|
6278
|
-
onSetStage(graphic, stage) {
|
|
6279
|
-
this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
|
|
6280
|
-
}
|
|
6281
|
-
onRemove(graphic) {
|
|
6282
|
-
this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
|
|
6283
|
-
}
|
|
6284
|
-
onRelease(graphic) {
|
|
6285
|
-
this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
|
|
6286
|
-
}
|
|
6287
|
-
onAddIncremental(graphic, group, stage) {
|
|
6288
|
-
this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
|
|
6289
|
-
}
|
|
6290
|
-
onClearIncremental(group, stage) {
|
|
6291
|
-
this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
|
|
6292
|
-
}
|
|
6293
|
-
beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
|
|
6294
|
-
this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
|
|
6295
|
-
}
|
|
6296
|
-
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
6297
|
-
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
6298
|
-
}
|
|
6299
|
-
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
6300
|
-
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
6301
|
-
if (!path) return !1;
|
|
6302
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
6303
|
-
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
6304
|
-
}
|
|
6305
|
-
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
6306
|
-
const {
|
|
6307
|
-
textAlign: textAlign,
|
|
6308
|
-
textBaseline: textBaseline
|
|
6309
|
-
} = attribute;
|
|
6310
|
-
if (null != attribute.forceBoundsHeight) {
|
|
6311
|
-
const h = isNumber(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
6312
|
-
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
6313
|
-
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
6314
|
-
}
|
|
6315
|
-
if (null != attribute.forceBoundsWidth) {
|
|
6316
|
-
const w = isNumber(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
6317
|
-
dx = textDrawOffsetX(textAlign, w);
|
|
6318
|
-
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
6319
|
-
}
|
|
6320
|
-
}
|
|
6321
|
-
combindShadowAABBBounds(bounds, graphic) {
|
|
6322
|
-
if (graphic && graphic.shadowRoot) {
|
|
6323
|
-
const b = graphic.shadowRoot.AABBBounds;
|
|
6324
|
-
bounds.union(b);
|
|
6325
|
-
}
|
|
6326
|
-
}
|
|
6327
|
-
transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
|
|
6328
|
-
if (!aabbBounds.empty()) {
|
|
6329
|
-
const {
|
|
6330
|
-
scaleX = theme.scaleX,
|
|
6331
|
-
scaleY = theme.scaleY,
|
|
6332
|
-
stroke = theme.stroke,
|
|
6333
|
-
shadowBlur = theme.shadowBlur,
|
|
6334
|
-
lineWidth = theme.lineWidth,
|
|
6335
|
-
pickStrokeBuffer = theme.pickStrokeBuffer,
|
|
6336
|
-
strokeBoundsBuffer = theme.strokeBoundsBuffer
|
|
6337
|
-
} = attribute,
|
|
6338
|
-
tb1 = this.tempAABBBounds1,
|
|
6339
|
-
tb2 = this.tempAABBBounds2;
|
|
6340
|
-
if (stroke && lineWidth) {
|
|
6341
|
-
const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
|
|
6342
|
-
boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
6343
|
-
}
|
|
6344
|
-
if (shadowBlur) {
|
|
6345
|
-
const {
|
|
6346
|
-
shadowOffsetX = theme.shadowOffsetX,
|
|
6347
|
-
shadowOffsetY = theme.shadowOffsetY
|
|
6348
|
-
} = attribute,
|
|
6349
|
-
shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
|
|
6350
|
-
boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
|
|
6351
|
-
}
|
|
6352
|
-
}
|
|
6353
|
-
if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
|
|
6354
|
-
let updateMatrix = !0;
|
|
6355
|
-
const m = graphic.transMatrix;
|
|
6356
|
-
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);
|
|
6357
|
-
}
|
|
6358
|
-
validCheck(attribute, theme, aabbBounds, graphic) {
|
|
6359
|
-
if (!graphic) return !0;
|
|
6360
|
-
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
6361
|
-
if (graphic.shadowRoot) return !0;
|
|
6362
|
-
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
6363
|
-
const {
|
|
6364
|
-
visible = theme.visible
|
|
6365
|
-
} = attribute;
|
|
6366
|
-
return !!visible || (aabbBounds.clear(), !1);
|
|
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;
|
|
6367
6437
|
}
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
tb2 = this.tempAABBBounds2;
|
|
6371
|
-
return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
|
|
6372
|
-
tb1: tb1,
|
|
6373
|
-
tb2: tb2
|
|
6374
|
-
};
|
|
6438
|
+
free(d) {
|
|
6439
|
+
this.pools.push(d);
|
|
6375
6440
|
}
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
const result = {
|
|
6380
|
-
x: 0,
|
|
6381
|
-
y: 0,
|
|
6382
|
-
z: 0,
|
|
6383
|
-
lastModelMatrix: null
|
|
6384
|
-
};
|
|
6385
|
-
class BaseRender {
|
|
6386
|
-
init(contributions) {
|
|
6387
|
-
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;
|
|
6388
6443
|
}
|
|
6389
|
-
|
|
6390
|
-
this.
|
|
6391
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
6392
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
6393
|
-
}
|
|
6394
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
6395
|
-
});
|
|
6444
|
+
release() {
|
|
6445
|
+
this.pools = [];
|
|
6396
6446
|
}
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
}
|
|
6402
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
6403
|
-
});
|
|
6447
|
+
}
|
|
6448
|
+
class DefaultMat4Allocate {
|
|
6449
|
+
constructor() {
|
|
6450
|
+
this.pools = [];
|
|
6404
6451
|
}
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
fill = defaultAttribute.fill,
|
|
6408
|
-
background: background,
|
|
6409
|
-
stroke = defaultAttribute.stroke,
|
|
6410
|
-
opacity = defaultAttribute.opacity,
|
|
6411
|
-
fillOpacity = defaultAttribute.fillOpacity,
|
|
6412
|
-
lineWidth = defaultAttribute.lineWidth,
|
|
6413
|
-
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
6414
|
-
visible = defaultAttribute.visible
|
|
6415
|
-
} = graphic.attribute,
|
|
6416
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
6417
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
6418
|
-
doFill = runFill(fill, background),
|
|
6419
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
6420
|
-
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
6421
|
-
fVisible: fVisible,
|
|
6422
|
-
sVisible: sVisible,
|
|
6423
|
-
doFill: doFill,
|
|
6424
|
-
doStroke: doStroke
|
|
6425
|
-
};
|
|
6452
|
+
static identity(out) {
|
|
6453
|
+
return identityMat4(out);
|
|
6426
6454
|
}
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
const
|
|
6430
|
-
|
|
6431
|
-
y = graphicAttribute.y,
|
|
6432
|
-
z = graphicAttribute.z,
|
|
6433
|
-
scaleX = graphicAttribute.scaleX,
|
|
6434
|
-
scaleY = graphicAttribute.scaleY,
|
|
6435
|
-
angle = graphicAttribute.angle,
|
|
6436
|
-
postMatrix: postMatrix
|
|
6437
|
-
} = graphic.attribute,
|
|
6438
|
-
lastModelMatrix = context.modelMatrix,
|
|
6439
|
-
camera = context.camera;
|
|
6440
|
-
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
6441
|
-
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
6442
|
-
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
6443
|
-
if (shouldTransform3d) {
|
|
6444
|
-
const nextModelMatrix = mat4Allocate.allocate(),
|
|
6445
|
-
modelMatrix = mat4Allocate.allocate();
|
|
6446
|
-
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);
|
|
6447
|
-
}
|
|
6448
|
-
if (onlyTranslate && !lastModelMatrix) {
|
|
6449
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
6450
|
-
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
6451
|
-
} 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) {
|
|
6452
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
6453
|
-
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
6454
|
-
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
6455
|
-
return result;
|
|
6455
|
+
allocate() {
|
|
6456
|
+
if (!this.pools.length) return createMat4();
|
|
6457
|
+
const m = this.pools.pop();
|
|
6458
|
+
return DefaultMat4Allocate.identity(m), m;
|
|
6456
6459
|
}
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
height = bounds.y2 - bounds.y1,
|
|
6463
|
-
p1 = context.project(0, 0, z),
|
|
6464
|
-
p2 = context.project(width, 0, z),
|
|
6465
|
-
p3 = context.project(width, height, z),
|
|
6466
|
-
_p1 = {
|
|
6467
|
-
x: 0,
|
|
6468
|
-
y: 0
|
|
6469
|
-
},
|
|
6470
|
-
_p2 = {
|
|
6471
|
-
x: width,
|
|
6472
|
-
y: 0
|
|
6473
|
-
},
|
|
6474
|
-
_p3 = {
|
|
6475
|
-
x: width,
|
|
6476
|
-
y: height
|
|
6477
|
-
};
|
|
6478
|
-
context.camera = null;
|
|
6479
|
-
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
6480
|
-
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
6481
|
-
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
6482
|
-
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
6483
|
-
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
6484
|
-
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,
|
|
6485
|
-
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;
|
|
6486
|
-
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
6487
|
-
}
|
|
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;
|
|
6488
6465
|
}
|
|
6489
|
-
|
|
6490
|
-
|
|
6466
|
+
free(m) {
|
|
6467
|
+
m && this.pools.push(m);
|
|
6491
6468
|
}
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
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;
|
|
6495
6471
|
}
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
context: context
|
|
6499
|
-
} = drawContext;
|
|
6500
|
-
if (!context) return;
|
|
6501
|
-
const {
|
|
6502
|
-
renderable: renderable
|
|
6503
|
-
} = graphic.attribute;
|
|
6504
|
-
if (!1 === renderable) return;
|
|
6505
|
-
context.highPerformanceSave();
|
|
6506
|
-
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
6507
|
-
{
|
|
6508
|
-
x: x,
|
|
6509
|
-
y: y,
|
|
6510
|
-
z: z,
|
|
6511
|
-
lastModelMatrix: lastModelMatrix
|
|
6512
|
-
} = data;
|
|
6513
|
-
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 = [];
|
|
6514
6474
|
}
|
|
6515
6475
|
}
|
|
6476
|
+
const matrixAllocate = new DefaultMatrixAllocate();
|
|
6477
|
+
const mat4Allocate = new DefaultMat4Allocate();
|
|
6516
6478
|
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
endCall: /^\)/,
|
|
6532
|
-
comma: /^,/,
|
|
6533
|
-
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
6534
|
-
literalColor: /^([a-zA-Z]+)/,
|
|
6535
|
-
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
6536
|
-
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
6537
|
-
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
|
+
};
|
|
6538
6493
|
};
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
const
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
}
|
|
6571
|
-
function matchConicalOrientation() {
|
|
6572
|
-
return match("angular", tokens.fromAngleValue, 1);
|
|
6573
|
-
}
|
|
6574
|
-
function matchListRadialOrientations() {
|
|
6575
|
-
let radialOrientations,
|
|
6576
|
-
lookaheadCache,
|
|
6577
|
-
radialOrientation = matchRadialOrientation();
|
|
6578
|
-
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;
|
|
6579
6525
|
}
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
const positionAt = matchAtPosition();
|
|
6595
|
-
positionAt && (radialType.at = positionAt);
|
|
6596
|
-
} else {
|
|
6597
|
-
const defaultPosition = matchPositioning();
|
|
6598
|
-
defaultPosition && (radialType = {
|
|
6599
|
-
type: "default-radial",
|
|
6600
|
-
at: defaultPosition
|
|
6601
|
-
});
|
|
6602
|
-
}
|
|
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];
|
|
6603
6540
|
}
|
|
6604
|
-
|
|
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);
|
|
6605
6542
|
}
|
|
6606
|
-
|
|
6607
|
-
|
|
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();
|
|
6608
6563
|
}
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
const positioning = matchPositioning();
|
|
6612
|
-
return positioning || error("Missing positioning value"), positioning;
|
|
6613
|
-
}
|
|
6564
|
+
onAttributeUpdate(graphic) {
|
|
6565
|
+
this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
|
|
6614
6566
|
}
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
x: matchDistance(),
|
|
6618
|
-
y: matchDistance()
|
|
6619
|
-
};
|
|
6620
|
-
if (location.x || location.y) return {
|
|
6621
|
-
type: "position",
|
|
6622
|
-
value: location
|
|
6623
|
-
};
|
|
6567
|
+
onSetStage(graphic, stage) {
|
|
6568
|
+
this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
|
|
6624
6569
|
}
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
const result = [];
|
|
6628
|
-
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
6629
|
-
return result;
|
|
6570
|
+
onRemove(graphic) {
|
|
6571
|
+
this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
|
|
6630
6572
|
}
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
6573
|
+
onRelease(graphic) {
|
|
6574
|
+
this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
|
|
6634
6575
|
}
|
|
6635
|
-
|
|
6636
|
-
|
|
6576
|
+
onAddIncremental(graphic, group, stage) {
|
|
6577
|
+
this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
|
|
6637
6578
|
}
|
|
6638
|
-
|
|
6639
|
-
|
|
6579
|
+
onClearIncremental(group, stage) {
|
|
6580
|
+
this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
|
|
6640
6581
|
}
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
if (captures) return {
|
|
6644
|
-
type: type,
|
|
6645
|
-
value: captures[captureIndex]
|
|
6646
|
-
};
|
|
6582
|
+
beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
|
|
6583
|
+
this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
|
|
6647
6584
|
}
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
blankCaptures && consume(blankCaptures[0].length);
|
|
6651
|
-
const captures = regexp.exec(input);
|
|
6652
|
-
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);
|
|
6653
6587
|
}
|
|
6654
|
-
|
|
6655
|
-
|
|
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;
|
|
6656
6593
|
}
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
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
|
+
}
|
|
6664
6609
|
}
|
|
6665
|
-
|
|
6666
|
-
|
|
6610
|
+
combindShadowAABBBounds(bounds, graphic) {
|
|
6611
|
+
if (graphic && graphic.shadowRoot) {
|
|
6612
|
+
const b = graphic.shadowRoot.AABBBounds;
|
|
6613
|
+
bounds.union(b);
|
|
6614
|
+
}
|
|
6667
6615
|
}
|
|
6668
|
-
|
|
6669
|
-
if (
|
|
6670
|
-
const
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
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);
|
|
6675
6640
|
}
|
|
6676
|
-
} catch (err) {
|
|
6677
|
-
return c;
|
|
6678
6641
|
}
|
|
6679
|
-
return
|
|
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);
|
|
6680
6646
|
}
|
|
6681
|
-
|
|
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;
|
|
6682
6652
|
const {
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
endAngle: sa + pi2,
|
|
6694
|
-
stops: colorStops.map(item => ({
|
|
6695
|
-
color: item.value,
|
|
6696
|
-
offset: parseFloat(item.length.value) / 100
|
|
6697
|
-
}))
|
|
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
|
|
6698
6663
|
};
|
|
6699
6664
|
}
|
|
6700
|
-
|
|
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) {
|
|
6701
6695
|
const {
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
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
|
|
6716
6714
|
};
|
|
6717
6715
|
}
|
|
6718
|
-
|
|
6716
|
+
transform(graphic, graphicAttribute, context) {
|
|
6717
|
+
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
6719
6718
|
const {
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
};
|
|
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;
|
|
6742
6745
|
}
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
scaleY = 1
|
|
6774
|
-
} = params.attribute;
|
|
6775
|
-
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);
|
|
6776
6776
|
}
|
|
6777
|
-
"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));
|
|
6778
6777
|
}
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
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
|
+
}
|
|
6801
6804
|
}
|
|
6802
6805
|
|
|
6803
6806
|
var __decorate$I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
@@ -7024,7 +7027,8 @@ class DefaultArcRenderContribution {
|
|
|
7024
7027
|
x: originX = arcAttribute.x,
|
|
7025
7028
|
y: originY = arcAttribute.y,
|
|
7026
7029
|
scaleX = arcAttribute.scaleX,
|
|
7027
|
-
scaleY = arcAttribute.scaleY
|
|
7030
|
+
scaleY = arcAttribute.scaleY,
|
|
7031
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
7028
7032
|
} = arc.attribute;
|
|
7029
7033
|
let {
|
|
7030
7034
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -7036,7 +7040,7 @@ class DefaultArcRenderContribution {
|
|
|
7036
7040
|
{
|
|
7037
7041
|
distance = arcAttribute[key].distance
|
|
7038
7042
|
} = borderStyle,
|
|
7039
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7043
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7040
7044
|
deltaAngle = distance / outerRadius,
|
|
7041
7045
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7042
7046
|
if (arc.setAttributes({
|
|
@@ -7081,14 +7085,15 @@ class DefaultCircleRenderContribution {
|
|
|
7081
7085
|
x: originX = circleAttribute.x,
|
|
7082
7086
|
y: originY = circleAttribute.y,
|
|
7083
7087
|
scaleX = circleAttribute.scaleX,
|
|
7084
|
-
scaleY = circleAttribute.scaleY
|
|
7088
|
+
scaleY = circleAttribute.scaleY,
|
|
7089
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
7085
7090
|
} = circle.attribute,
|
|
7086
7091
|
renderBorder = (borderStyle, key) => {
|
|
7087
7092
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7088
7093
|
{
|
|
7089
7094
|
distance = circleAttribute[key].distance
|
|
7090
7095
|
} = borderStyle,
|
|
7091
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7096
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7092
7097
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7093
7098
|
if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
|
|
7094
7099
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -7207,7 +7212,8 @@ class DefaultRectRenderContribution {
|
|
|
7207
7212
|
scaleX = rectAttribute.scaleX,
|
|
7208
7213
|
scaleY = rectAttribute.scaleY,
|
|
7209
7214
|
x1: x1,
|
|
7210
|
-
y1: y1
|
|
7215
|
+
y1: y1,
|
|
7216
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
7211
7217
|
} = rect.attribute;
|
|
7212
7218
|
let {
|
|
7213
7219
|
width: width,
|
|
@@ -7220,7 +7226,7 @@ class DefaultRectRenderContribution {
|
|
|
7220
7226
|
{
|
|
7221
7227
|
distance = rectAttribute[key].distance
|
|
7222
7228
|
} = borderStyle,
|
|
7223
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7229
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7224
7230
|
nextX = x + sign * d,
|
|
7225
7231
|
nextY = y + sign * d,
|
|
7226
7232
|
dw = 2 * d;
|
|
@@ -7377,14 +7383,15 @@ class DefaultSymbolRenderContribution {
|
|
|
7377
7383
|
x: originX = symbolAttribute.x,
|
|
7378
7384
|
y: originY = symbolAttribute.y,
|
|
7379
7385
|
scaleX = symbolAttribute.scaleX,
|
|
7380
|
-
scaleY = symbolAttribute.scaleY
|
|
7386
|
+
scaleY = symbolAttribute.scaleY,
|
|
7387
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
7381
7388
|
} = symbol.attribute,
|
|
7382
7389
|
renderBorder = (borderStyle, key) => {
|
|
7383
7390
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7384
7391
|
{
|
|
7385
7392
|
distance = symbolAttribute[key].distance
|
|
7386
7393
|
} = borderStyle,
|
|
7387
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7394
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7388
7395
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7389
7396
|
if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
|
|
7390
7397
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -9192,7 +9199,10 @@ class ShadowRootDrawItemInterceptorContribution {
|
|
|
9192
9199
|
const {
|
|
9193
9200
|
context: context
|
|
9194
9201
|
} = drawContext;
|
|
9195
|
-
|
|
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) {
|
|
9196
9206
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
9197
9207
|
const m = graphic.globalTransMatrix.getInverse();
|
|
9198
9208
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
|
|
@@ -10212,6 +10222,9 @@ class BaseSymbol {
|
|
|
10212
10222
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
10213
10223
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
10214
10224
|
}
|
|
10225
|
+
parseSize(size) {
|
|
10226
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10227
|
+
}
|
|
10215
10228
|
}
|
|
10216
10229
|
|
|
10217
10230
|
function circle(ctx, r, x, y, z) {
|
|
@@ -10222,13 +10235,13 @@ class CircleSymbol extends BaseSymbol {
|
|
|
10222
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";
|
|
10223
10236
|
}
|
|
10224
10237
|
draw(ctx, size, x, y, z) {
|
|
10225
|
-
return circle(ctx, size / 2, x, y, z);
|
|
10238
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10226
10239
|
}
|
|
10227
10240
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10228
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
10241
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10229
10242
|
}
|
|
10230
10243
|
drawToSvgPath(size, x, y, z) {
|
|
10231
|
-
const r = size / 2;
|
|
10244
|
+
const r = this.parseSize(size) / 2;
|
|
10232
10245
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
10233
10246
|
}
|
|
10234
10247
|
}
|
|
@@ -10245,10 +10258,10 @@ class CrossSymbol extends BaseSymbol {
|
|
|
10245
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";
|
|
10246
10259
|
}
|
|
10247
10260
|
draw(ctx, size, x, y, z) {
|
|
10248
|
-
return cross(ctx, size / 6, x, y, z);
|
|
10261
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
10249
10262
|
}
|
|
10250
10263
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10251
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
10264
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
10252
10265
|
}
|
|
10253
10266
|
}
|
|
10254
10267
|
var cross$1 = new CrossSymbol();
|
|
@@ -10261,13 +10274,13 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
10261
10274
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
10262
10275
|
}
|
|
10263
10276
|
draw(ctx, size, x, y, z) {
|
|
10264
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10277
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10265
10278
|
}
|
|
10266
10279
|
drawFitDir(ctx, size, x, y, z) {
|
|
10267
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10280
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10268
10281
|
}
|
|
10269
10282
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10270
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
10283
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10271
10284
|
}
|
|
10272
10285
|
}
|
|
10273
10286
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -10281,10 +10294,10 @@ class SquareSymbol extends BaseSymbol {
|
|
|
10281
10294
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
10282
10295
|
}
|
|
10283
10296
|
draw(ctx, size, x, y) {
|
|
10284
|
-
return square(ctx, size / 2, x, y);
|
|
10297
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
10285
10298
|
}
|
|
10286
10299
|
drawOffset(ctx, size, x, y, offset) {
|
|
10287
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
10300
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10288
10301
|
}
|
|
10289
10302
|
}
|
|
10290
10303
|
var square$1 = new SquareSymbol();
|
|
@@ -10298,10 +10311,10 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
10298
10311
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
10299
10312
|
}
|
|
10300
10313
|
draw(ctx, size, x, y) {
|
|
10301
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
10314
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10302
10315
|
}
|
|
10303
10316
|
drawOffset(ctx, size, x, y, offset) {
|
|
10304
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
10317
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10305
10318
|
}
|
|
10306
10319
|
}
|
|
10307
10320
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -10333,10 +10346,10 @@ class StarSymbol extends BaseSymbol {
|
|
|
10333
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";
|
|
10334
10347
|
}
|
|
10335
10348
|
draw(ctx, size, transX, transY) {
|
|
10336
|
-
return star(ctx, size / 2, transX, transY);
|
|
10349
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10337
10350
|
}
|
|
10338
10351
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10339
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
10352
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10340
10353
|
}
|
|
10341
10354
|
}
|
|
10342
10355
|
var star$1 = new StarSymbol();
|
|
@@ -10354,10 +10367,10 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
10354
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";
|
|
10355
10368
|
}
|
|
10356
10369
|
draw(ctx, size, transX, transY) {
|
|
10357
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
10370
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10358
10371
|
}
|
|
10359
10372
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10360
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
10373
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10361
10374
|
}
|
|
10362
10375
|
}
|
|
10363
10376
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -10371,10 +10384,10 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
10371
10384
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
10372
10385
|
}
|
|
10373
10386
|
draw(ctx, size, transX, transY) {
|
|
10374
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
10387
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10375
10388
|
}
|
|
10376
10389
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10377
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
10390
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10378
10391
|
}
|
|
10379
10392
|
}
|
|
10380
10393
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -10387,10 +10400,10 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
10387
10400
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
10388
10401
|
}
|
|
10389
10402
|
draw(ctx, size, transX, transY) {
|
|
10390
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
10403
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10391
10404
|
}
|
|
10392
10405
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10393
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
10406
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10394
10407
|
}
|
|
10395
10408
|
}
|
|
10396
10409
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -10412,10 +10425,10 @@ class WyeSymbol extends BaseSymbol {
|
|
|
10412
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";
|
|
10413
10426
|
}
|
|
10414
10427
|
draw(ctx, size, transX, transY) {
|
|
10415
|
-
return wye(ctx, size / 2, transX, transY);
|
|
10428
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10416
10429
|
}
|
|
10417
10430
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10418
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
10431
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10419
10432
|
}
|
|
10420
10433
|
}
|
|
10421
10434
|
var wye$1 = new WyeSymbol();
|
|
@@ -10428,10 +10441,10 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
10428
10441
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
10429
10442
|
}
|
|
10430
10443
|
draw(ctx, size, x, y) {
|
|
10431
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
10444
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
10432
10445
|
}
|
|
10433
10446
|
drawOffset(ctx, size, x, y, offset) {
|
|
10434
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
10447
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10435
10448
|
}
|
|
10436
10449
|
}
|
|
10437
10450
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -10445,10 +10458,10 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
10445
10458
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
10446
10459
|
}
|
|
10447
10460
|
draw(ctx, size, x, y) {
|
|
10448
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
10461
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10449
10462
|
}
|
|
10450
10463
|
drawOffset(ctx, size, x, y, offset) {
|
|
10451
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
10464
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10452
10465
|
}
|
|
10453
10466
|
}
|
|
10454
10467
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -10462,10 +10475,10 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
10462
10475
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
10463
10476
|
}
|
|
10464
10477
|
draw(ctx, size, x, y) {
|
|
10465
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
10478
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10466
10479
|
}
|
|
10467
10480
|
drawOffset(ctx, size, x, y, offset) {
|
|
10468
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
10481
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10469
10482
|
}
|
|
10470
10483
|
}
|
|
10471
10484
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -10480,10 +10493,10 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
10480
10493
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
10481
10494
|
}
|
|
10482
10495
|
draw(ctx, size, x, y) {
|
|
10483
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
10496
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
10484
10497
|
}
|
|
10485
10498
|
drawOffset(ctx, size, x, y, offset) {
|
|
10486
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
10499
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
10487
10500
|
}
|
|
10488
10501
|
}
|
|
10489
10502
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -10497,10 +10510,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
10497
10510
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
10498
10511
|
}
|
|
10499
10512
|
draw(ctx, size, transX, transY) {
|
|
10500
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
10513
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10501
10514
|
}
|
|
10502
10515
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10503
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
10516
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10504
10517
|
}
|
|
10505
10518
|
}
|
|
10506
10519
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -10514,10 +10527,10 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
10514
10527
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
10515
10528
|
}
|
|
10516
10529
|
draw(ctx, size, transX, transY) {
|
|
10517
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
10530
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10518
10531
|
}
|
|
10519
10532
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10520
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
10533
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10521
10534
|
}
|
|
10522
10535
|
}
|
|
10523
10536
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -10531,10 +10544,10 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
10531
10544
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
10532
10545
|
}
|
|
10533
10546
|
draw(ctx, size, transX, transY) {
|
|
10534
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
10547
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10535
10548
|
}
|
|
10536
10549
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10537
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
10550
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10538
10551
|
}
|
|
10539
10552
|
}
|
|
10540
10553
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -10548,10 +10561,10 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
10548
10561
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
10549
10562
|
}
|
|
10550
10563
|
draw(ctx, size, transX, transY) {
|
|
10551
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
10564
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10552
10565
|
}
|
|
10553
10566
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10554
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
10567
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10555
10568
|
}
|
|
10556
10569
|
}
|
|
10557
10570
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -10564,13 +10577,13 @@ class LineVSymbol extends BaseSymbol {
|
|
|
10564
10577
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
10565
10578
|
}
|
|
10566
10579
|
draw(ctx, size, x, y, z) {
|
|
10567
|
-
return lineV(ctx, size / 2, x, y);
|
|
10580
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
10568
10581
|
}
|
|
10569
10582
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10570
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
10583
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10571
10584
|
}
|
|
10572
10585
|
drawToSvgPath(size, x, y, z) {
|
|
10573
|
-
const r = size / 2;
|
|
10586
|
+
const r = this.parseSize(size) / 2;
|
|
10574
10587
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
10575
10588
|
}
|
|
10576
10589
|
}
|
|
@@ -10584,13 +10597,13 @@ class LineHSymbol extends BaseSymbol {
|
|
|
10584
10597
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
10585
10598
|
}
|
|
10586
10599
|
draw(ctx, size, x, y, z) {
|
|
10587
|
-
return lineH(ctx, size / 2, x, y);
|
|
10600
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
10588
10601
|
}
|
|
10589
10602
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10590
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
10603
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10591
10604
|
}
|
|
10592
10605
|
drawToSvgPath(size, x, y, z) {
|
|
10593
|
-
const r = size / 2;
|
|
10606
|
+
const r = this.parseSize(size) / 2;
|
|
10594
10607
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
10595
10608
|
}
|
|
10596
10609
|
}
|
|
@@ -10604,13 +10617,13 @@ class CloseSymbol extends BaseSymbol {
|
|
|
10604
10617
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
10605
10618
|
}
|
|
10606
10619
|
draw(ctx, size, x, y, z) {
|
|
10607
|
-
return close(ctx, size / 2, x, y);
|
|
10620
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
10608
10621
|
}
|
|
10609
10622
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10610
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
10623
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10611
10624
|
}
|
|
10612
10625
|
drawToSvgPath(size, x, y, z) {
|
|
10613
|
-
const r = size / 2;
|
|
10626
|
+
const r = this.parseSize(size) / 2;
|
|
10614
10627
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
10615
10628
|
}
|
|
10616
10629
|
}
|
|
@@ -10644,15 +10657,18 @@ class CustomSymbolClass {
|
|
|
10644
10657
|
this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
10645
10658
|
}
|
|
10646
10659
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
10647
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10660
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10648
10661
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
10649
10662
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
10650
10663
|
}
|
|
10651
10664
|
draw(ctx, size, x, y, z, cb) {
|
|
10652
|
-
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]);
|
|
10653
10669
|
}
|
|
10654
10670
|
bounds(size, bounds) {
|
|
10655
|
-
if (this.isSvg) {
|
|
10671
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
10656
10672
|
if (!this.svgCache) return;
|
|
10657
10673
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
10658
10674
|
let {
|
|
@@ -11156,7 +11172,11 @@ class Paragraph {
|
|
|
11156
11172
|
case "sub":
|
|
11157
11173
|
baseline += this.descent / 2;
|
|
11158
11174
|
}
|
|
11159
|
-
"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)
|
|
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();
|
|
11160
11180
|
}
|
|
11161
11181
|
getWidthWithEllips(direction) {
|
|
11162
11182
|
let text = this.text;
|
|
@@ -11379,12 +11399,18 @@ class Line {
|
|
|
11379
11399
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
11380
11400
|
}
|
|
11381
11401
|
}
|
|
11382
|
-
this.paragraphs.
|
|
11402
|
+
this.paragraphs.forEach((paragraph, index) => {
|
|
11383
11403
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
11384
11404
|
x: x + paragraph._x,
|
|
11385
11405
|
y: y + paragraph._y
|
|
11386
11406
|
}), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
|
|
11387
|
-
|
|
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);
|
|
11388
11414
|
});
|
|
11389
11415
|
}
|
|
11390
11416
|
getWidthWithEllips(ellipsis) {
|
|
@@ -11407,7 +11433,7 @@ class Line {
|
|
|
11407
11433
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
11408
11434
|
}
|
|
11409
11435
|
let width = 0;
|
|
11410
|
-
return this.paragraphs.
|
|
11436
|
+
return this.paragraphs.forEach((paragraph, index) => {
|
|
11411
11437
|
width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
|
|
11412
11438
|
}), width;
|
|
11413
11439
|
}
|
|
@@ -13343,8 +13369,9 @@ class PickerBase {
|
|
|
13343
13369
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
13344
13370
|
if (picked) return !0;
|
|
13345
13371
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13346
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13347
|
-
|
|
13372
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13373
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13374
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13348
13375
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13349
13376
|
}
|
|
13350
13377
|
}
|
|
@@ -13566,8 +13593,9 @@ class RectPickerBase {
|
|
|
13566
13593
|
if (!onlyTranslate || rect.shadowRoot || isNumber(cornerRadius, !0) && 0 !== cornerRadius || isArray(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
13567
13594
|
if (picked) return !0;
|
|
13568
13595
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13569
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13570
|
-
|
|
13596
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13597
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13598
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13571
13599
|
});else {
|
|
13572
13600
|
const {
|
|
13573
13601
|
fill = rectAttribute.fill,
|
|
@@ -13746,8 +13774,9 @@ class BaseLinePicker extends BaseRender {
|
|
|
13746
13774
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
13747
13775
|
if (picked) return !0;
|
|
13748
13776
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13749
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13750
|
-
|
|
13777
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13778
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13779
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13751
13780
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13752
13781
|
}
|
|
13753
13782
|
}
|
|
@@ -13882,8 +13911,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
13882
13911
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
13883
13912
|
if (picked) return !0;
|
|
13884
13913
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13885
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13886
|
-
|
|
13914
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13915
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13916
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13887
13917
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13888
13918
|
}
|
|
13889
13919
|
};
|
|
@@ -15987,24 +16017,29 @@ function defaultLabelPosition(type) {
|
|
|
15987
16017
|
return DefaultPositions;
|
|
15988
16018
|
}
|
|
15989
16019
|
}
|
|
15990
|
-
function clampText(text, width, height) {
|
|
16020
|
+
function clampText(text, width, height, padding = {}) {
|
|
15991
16021
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16022
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
15992
16023
|
const minX = Math.min(x1, x2);
|
|
15993
16024
|
const maxX = Math.max(x1, x2);
|
|
15994
16025
|
const minY = Math.min(y1, y2);
|
|
15995
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;
|
|
15996
16031
|
let dx = 0;
|
|
15997
16032
|
let dy = 0;
|
|
15998
|
-
if (minX <
|
|
16033
|
+
if (minX < minXWithPadding && maxX - minX <= width) {
|
|
15999
16034
|
dx = -minX;
|
|
16000
16035
|
}
|
|
16001
|
-
else if (maxX >
|
|
16036
|
+
else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
|
|
16002
16037
|
dx = width - maxX;
|
|
16003
16038
|
}
|
|
16004
|
-
if (minY <
|
|
16039
|
+
if (minY < minYWithPadding && maxY - minY <= height) {
|
|
16005
16040
|
dy = -minY;
|
|
16006
16041
|
}
|
|
16007
|
-
else if (maxY >
|
|
16042
|
+
else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
|
|
16008
16043
|
dy = height - maxY;
|
|
16009
16044
|
}
|
|
16010
16045
|
return { dx, dy };
|
|
@@ -16304,69 +16339,177 @@ function loadLabelComponent() {
|
|
|
16304
16339
|
registerLine();
|
|
16305
16340
|
}
|
|
16306
16341
|
|
|
16307
|
-
|
|
16308
|
-
|
|
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;
|
|
16309
16357
|
const n = texts.length;
|
|
16310
16358
|
if (n <= 1) {
|
|
16311
16359
|
return texts;
|
|
16312
16360
|
}
|
|
16313
|
-
const
|
|
16314
|
-
return d > a && b > c;
|
|
16315
|
-
};
|
|
16361
|
+
const xMap = new Map();
|
|
16316
16362
|
const textInformation = new Map();
|
|
16317
|
-
const
|
|
16318
|
-
const getY = (text) => textInformation.get(text).y;
|
|
16363
|
+
const getY1Initial = (text) => textInformation.get(text).y1Initial;
|
|
16319
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;
|
|
16320
16368
|
const getX1 = (text) => textInformation.get(text).x1;
|
|
16321
16369
|
const getX2 = (text) => textInformation.get(text).x2;
|
|
16322
|
-
const
|
|
16323
|
-
|
|
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;
|
|
16324
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);
|
|
16325
16396
|
for (const text of texts) {
|
|
16326
16397
|
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16327
|
-
|
|
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
|
+
}
|
|
16328
16428
|
}
|
|
16329
|
-
for (
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16342
|
-
|
|
16343
|
-
|
|
16344
|
-
|
|
16345
|
-
|
|
16346
|
-
|
|
16347
|
-
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
|
|
16354
|
-
|
|
16355
|
-
|
|
16356
|
-
|
|
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
|
+
}
|
|
16357
16485
|
}
|
|
16358
16486
|
}
|
|
16359
16487
|
}
|
|
16360
|
-
|
|
16361
|
-
|
|
16362
|
-
|
|
16488
|
+
if (error < maxError) {
|
|
16489
|
+
break;
|
|
16490
|
+
}
|
|
16363
16491
|
}
|
|
16364
16492
|
}
|
|
16365
16493
|
for (const text of texts) {
|
|
16366
|
-
const finalY = text.attribute.y +
|
|
16494
|
+
const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
|
|
16367
16495
|
text.setAttribute('y', finalY);
|
|
16368
16496
|
}
|
|
16369
|
-
|
|
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;
|
|
16370
16513
|
}
|
|
16371
16514
|
|
|
16372
16515
|
loadLabelComponent();
|
|
@@ -16712,18 +16855,25 @@ class LabelBase extends AbstractComponent {
|
|
|
16712
16855
|
if (clampForce) {
|
|
16713
16856
|
for (let i = 0; i < result.length; i++) {
|
|
16714
16857
|
const text = labels[i];
|
|
16715
|
-
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);
|
|
16716
16859
|
if (dx !== 0 || dy !== 0) {
|
|
16717
16860
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
16861
|
+
text._isClamped = true;
|
|
16718
16862
|
}
|
|
16719
16863
|
}
|
|
16720
16864
|
}
|
|
16721
|
-
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
|
+
} }));
|
|
16722
16872
|
for (let i = 0; i < result.length; i++) {
|
|
16723
16873
|
const text = result[i];
|
|
16724
16874
|
const bounds = text.AABBBounds;
|
|
16725
16875
|
const range = boundToRange(bmpTool, bounds, true);
|
|
16726
|
-
if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
|
|
16876
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
|
|
16727
16877
|
bitmap.setRange(range);
|
|
16728
16878
|
}
|
|
16729
16879
|
else {
|
|
@@ -16796,7 +16946,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16796
16946
|
}
|
|
16797
16947
|
}
|
|
16798
16948
|
if (!hasPlace && clampForce) {
|
|
16799
|
-
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);
|
|
16800
16950
|
if (dx === 0 && dy === 0) {
|
|
16801
16951
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
16802
16952
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -29546,6 +29696,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29546
29696
|
}
|
|
29547
29697
|
};
|
|
29548
29698
|
|
|
29549
|
-
const version = "0.20.
|
|
29699
|
+
const version = "0.20.16";
|
|
29550
29700
|
|
|
29551
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 };
|