@visactor/vrender 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/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +765 -731
- package/dist/index.js +765 -731
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -3996,7 +3996,8 @@
|
|
|
3996
3996
|
globalZIndex: 1,
|
|
3997
3997
|
globalCompositeOperation: "",
|
|
3998
3998
|
overflow: "hidden",
|
|
3999
|
-
shadowPickMode: "graphic"
|
|
3999
|
+
shadowPickMode: "graphic",
|
|
4000
|
+
keepStrokeScale: !1
|
|
4000
4001
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
4001
4002
|
function addAttributeToPrototype(obj, c, keys) {
|
|
4002
4003
|
keys.forEach(key => {
|
|
@@ -4148,6 +4149,292 @@
|
|
|
4148
4149
|
class Application {}
|
|
4149
4150
|
const application = new Application();
|
|
4150
4151
|
|
|
4152
|
+
const parse = function () {
|
|
4153
|
+
const tokens = {
|
|
4154
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
4155
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
4156
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
4157
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
4158
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
4159
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
4160
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
4161
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
4162
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
4163
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
4164
|
+
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
4165
|
+
startCall: /^\(/,
|
|
4166
|
+
endCall: /^\)/,
|
|
4167
|
+
comma: /^,/,
|
|
4168
|
+
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
4169
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
4170
|
+
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
4171
|
+
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
4172
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
4173
|
+
};
|
|
4174
|
+
let input = "";
|
|
4175
|
+
function error(msg) {
|
|
4176
|
+
const err = new Error(input + ": " + msg);
|
|
4177
|
+
throw err.source = input, err;
|
|
4178
|
+
}
|
|
4179
|
+
function getAST() {
|
|
4180
|
+
const ast = matchListing(matchDefinition);
|
|
4181
|
+
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
4182
|
+
}
|
|
4183
|
+
function matchDefinition() {
|
|
4184
|
+
return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
|
|
4185
|
+
}
|
|
4186
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
4187
|
+
return function (pattern, callback) {
|
|
4188
|
+
const captures = scan(pattern);
|
|
4189
|
+
if (captures) {
|
|
4190
|
+
scan(tokens.startCall) || error("Missing (");
|
|
4191
|
+
const result = callback(captures);
|
|
4192
|
+
return scan(tokens.endCall) || error("Missing )"), result;
|
|
4193
|
+
}
|
|
4194
|
+
}(pattern, function (captures) {
|
|
4195
|
+
const orientation = orientationMatcher();
|
|
4196
|
+
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
|
|
4197
|
+
type: gradientType,
|
|
4198
|
+
orientation: orientation,
|
|
4199
|
+
colorStops: matchListing(matchColorStop)
|
|
4200
|
+
};
|
|
4201
|
+
});
|
|
4202
|
+
}
|
|
4203
|
+
function matchLinearOrientation() {
|
|
4204
|
+
return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
|
|
4205
|
+
}
|
|
4206
|
+
function matchConicalOrientation() {
|
|
4207
|
+
return match("angular", tokens.fromAngleValue, 1);
|
|
4208
|
+
}
|
|
4209
|
+
function matchListRadialOrientations() {
|
|
4210
|
+
let radialOrientations,
|
|
4211
|
+
lookaheadCache,
|
|
4212
|
+
radialOrientation = matchRadialOrientation();
|
|
4213
|
+
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
4214
|
+
}
|
|
4215
|
+
function matchRadialOrientation() {
|
|
4216
|
+
let radialType = function () {
|
|
4217
|
+
const circle = match("shape", /^(circle)/i, 0);
|
|
4218
|
+
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
4219
|
+
return circle;
|
|
4220
|
+
}() || function () {
|
|
4221
|
+
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
4222
|
+
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
4223
|
+
return ellipse;
|
|
4224
|
+
}();
|
|
4225
|
+
if (radialType) radialType.at = matchAtPosition();else {
|
|
4226
|
+
const extent = matchExtentKeyword();
|
|
4227
|
+
if (extent) {
|
|
4228
|
+
radialType = extent;
|
|
4229
|
+
const positionAt = matchAtPosition();
|
|
4230
|
+
positionAt && (radialType.at = positionAt);
|
|
4231
|
+
} else {
|
|
4232
|
+
const defaultPosition = matchPositioning();
|
|
4233
|
+
defaultPosition && (radialType = {
|
|
4234
|
+
type: "default-radial",
|
|
4235
|
+
at: defaultPosition
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
return radialType;
|
|
4240
|
+
}
|
|
4241
|
+
function matchExtentKeyword() {
|
|
4242
|
+
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
4243
|
+
}
|
|
4244
|
+
function matchAtPosition() {
|
|
4245
|
+
if (match("position", /^at/, 0)) {
|
|
4246
|
+
const positioning = matchPositioning();
|
|
4247
|
+
return positioning || error("Missing positioning value"), positioning;
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
function matchPositioning() {
|
|
4251
|
+
const location = {
|
|
4252
|
+
x: matchDistance(),
|
|
4253
|
+
y: matchDistance()
|
|
4254
|
+
};
|
|
4255
|
+
if (location.x || location.y) return {
|
|
4256
|
+
type: "position",
|
|
4257
|
+
value: location
|
|
4258
|
+
};
|
|
4259
|
+
}
|
|
4260
|
+
function matchListing(matcher) {
|
|
4261
|
+
let captures = matcher();
|
|
4262
|
+
const result = [];
|
|
4263
|
+
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
4264
|
+
return result;
|
|
4265
|
+
}
|
|
4266
|
+
function matchColorStop() {
|
|
4267
|
+
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
4268
|
+
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
4269
|
+
}
|
|
4270
|
+
function matchDistance() {
|
|
4271
|
+
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
4272
|
+
}
|
|
4273
|
+
function matchLength() {
|
|
4274
|
+
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
4275
|
+
}
|
|
4276
|
+
function match(type, pattern, captureIndex) {
|
|
4277
|
+
const captures = scan(pattern);
|
|
4278
|
+
if (captures) return {
|
|
4279
|
+
type: type,
|
|
4280
|
+
value: captures[captureIndex]
|
|
4281
|
+
};
|
|
4282
|
+
}
|
|
4283
|
+
function scan(regexp) {
|
|
4284
|
+
const blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
4285
|
+
blankCaptures && consume(blankCaptures[0].length);
|
|
4286
|
+
const captures = regexp.exec(input);
|
|
4287
|
+
return captures && consume(captures[0].length), captures;
|
|
4288
|
+
}
|
|
4289
|
+
function consume(size) {
|
|
4290
|
+
input = input.substr(size);
|
|
4291
|
+
}
|
|
4292
|
+
return function (code) {
|
|
4293
|
+
return input = code.toString(), getAST();
|
|
4294
|
+
};
|
|
4295
|
+
}();
|
|
4296
|
+
class GradientParser {
|
|
4297
|
+
static IsGradient(c) {
|
|
4298
|
+
return !("string" == typeof c && !c.includes("gradient"));
|
|
4299
|
+
}
|
|
4300
|
+
static IsGradientStr(c) {
|
|
4301
|
+
return "string" == typeof c && c.includes("gradient");
|
|
4302
|
+
}
|
|
4303
|
+
static Parse(c) {
|
|
4304
|
+
if (GradientParser.IsGradientStr(c)) try {
|
|
4305
|
+
const datum = parse(c)[0];
|
|
4306
|
+
if (datum) {
|
|
4307
|
+
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
4308
|
+
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
4309
|
+
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
4310
|
+
}
|
|
4311
|
+
} catch (err) {
|
|
4312
|
+
return c;
|
|
4313
|
+
}
|
|
4314
|
+
return c;
|
|
4315
|
+
}
|
|
4316
|
+
static ParseConic(datum) {
|
|
4317
|
+
const {
|
|
4318
|
+
orientation: orientation,
|
|
4319
|
+
colorStops = []
|
|
4320
|
+
} = datum,
|
|
4321
|
+
halfPi = pi / 2,
|
|
4322
|
+
sa = parseFloat(orientation.value) / 180 * pi - halfPi;
|
|
4323
|
+
return {
|
|
4324
|
+
gradient: "conical",
|
|
4325
|
+
x: .5,
|
|
4326
|
+
y: .5,
|
|
4327
|
+
startAngle: sa,
|
|
4328
|
+
endAngle: sa + pi2,
|
|
4329
|
+
stops: colorStops.map(item => ({
|
|
4330
|
+
color: item.value,
|
|
4331
|
+
offset: parseFloat(item.length.value) / 100
|
|
4332
|
+
}))
|
|
4333
|
+
};
|
|
4334
|
+
}
|
|
4335
|
+
static ParseRadial(datum) {
|
|
4336
|
+
const {
|
|
4337
|
+
colorStops = []
|
|
4338
|
+
} = datum;
|
|
4339
|
+
return {
|
|
4340
|
+
gradient: "radial",
|
|
4341
|
+
x0: .5,
|
|
4342
|
+
y0: .5,
|
|
4343
|
+
x1: .5,
|
|
4344
|
+
y1: .5,
|
|
4345
|
+
r0: 0,
|
|
4346
|
+
r1: 1,
|
|
4347
|
+
stops: colorStops.map(item => ({
|
|
4348
|
+
color: item.value,
|
|
4349
|
+
offset: parseFloat(item.length.value) / 100
|
|
4350
|
+
}))
|
|
4351
|
+
};
|
|
4352
|
+
}
|
|
4353
|
+
static ParseLinear(datum) {
|
|
4354
|
+
const {
|
|
4355
|
+
orientation: orientation,
|
|
4356
|
+
colorStops = []
|
|
4357
|
+
} = datum,
|
|
4358
|
+
halfPi = pi / 2;
|
|
4359
|
+
let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
|
|
4360
|
+
for (; angle < 0;) angle += pi2;
|
|
4361
|
+
for (; angle >= pi2;) angle -= pi2;
|
|
4362
|
+
let x0 = 0,
|
|
4363
|
+
y0 = 0,
|
|
4364
|
+
x1 = 0,
|
|
4365
|
+
y1 = 0;
|
|
4366
|
+
return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = y0 - Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
|
|
4367
|
+
gradient: "linear",
|
|
4368
|
+
x0: x0,
|
|
4369
|
+
y0: y0,
|
|
4370
|
+
x1: x1,
|
|
4371
|
+
y1: y1,
|
|
4372
|
+
stops: colorStops.map(item => ({
|
|
4373
|
+
color: item.value,
|
|
4374
|
+
offset: parseFloat(item.length.value) / 100
|
|
4375
|
+
}))
|
|
4376
|
+
};
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
function getScaledStroke(context, width, dpr) {
|
|
4381
|
+
let strokeWidth = width;
|
|
4382
|
+
const {
|
|
4383
|
+
a: a,
|
|
4384
|
+
b: b,
|
|
4385
|
+
c: c,
|
|
4386
|
+
d: d
|
|
4387
|
+
} = context.currentMatrix,
|
|
4388
|
+
scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
|
|
4389
|
+
scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
4390
|
+
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
|
|
4391
|
+
}
|
|
4392
|
+
function createColor(context, c, params) {
|
|
4393
|
+
let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
4394
|
+
let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
4395
|
+
if (!c || !0 === c) return "black";
|
|
4396
|
+
let result, color;
|
|
4397
|
+
if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
4398
|
+
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
4399
|
+
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
4400
|
+
const bounds = params.AABBBounds;
|
|
4401
|
+
let w = bounds.x2 - bounds.x1,
|
|
4402
|
+
h = bounds.y2 - bounds.y1,
|
|
4403
|
+
x = bounds.x1 - offsetX,
|
|
4404
|
+
y = bounds.y1 - offsetY;
|
|
4405
|
+
if (params.attribute) {
|
|
4406
|
+
const {
|
|
4407
|
+
scaleX = 1,
|
|
4408
|
+
scaleY = 1
|
|
4409
|
+
} = params.attribute;
|
|
4410
|
+
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
4411
|
+
}
|
|
4412
|
+
"linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
|
|
4413
|
+
}
|
|
4414
|
+
return result || "orange";
|
|
4415
|
+
}
|
|
4416
|
+
function createLinearGradient(context, color, x, y, w, h) {
|
|
4417
|
+
var _a, _b, _c, _d;
|
|
4418
|
+
const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
|
|
4419
|
+
return color.stops.forEach(stop => {
|
|
4420
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4421
|
+
}), canvasGradient;
|
|
4422
|
+
}
|
|
4423
|
+
function createRadialGradient(context, color, x, y, w, h) {
|
|
4424
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4425
|
+
const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
|
|
4426
|
+
return color.stops.forEach(stop => {
|
|
4427
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4428
|
+
}), canvasGradient;
|
|
4429
|
+
}
|
|
4430
|
+
function createConicGradient(context, color, x, y, w, h) {
|
|
4431
|
+
var _a, _b;
|
|
4432
|
+
const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
|
|
4433
|
+
return color.stops.forEach(stop => {
|
|
4434
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4435
|
+
}), canvasGradient.GetPattern(w + x, h + y, undefined);
|
|
4436
|
+
}
|
|
4437
|
+
|
|
4151
4438
|
const DIRECTION_KEY = {
|
|
4152
4439
|
horizontal: {
|
|
4153
4440
|
width: "width",
|
|
@@ -4199,14 +4486,16 @@
|
|
|
4199
4486
|
fontFamily: character.fontFamily || "sans-serif"
|
|
4200
4487
|
});
|
|
4201
4488
|
};
|
|
4202
|
-
function applyFillStyle(ctx, character) {
|
|
4489
|
+
function applyFillStyle(ctx, character, b) {
|
|
4203
4490
|
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
4204
4491
|
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
4205
4492
|
const {
|
|
4206
4493
|
fillOpacity = 1,
|
|
4207
4494
|
opacity = 1
|
|
4208
4495
|
} = character;
|
|
4209
|
-
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle =
|
|
4496
|
+
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
|
|
4497
|
+
AABBBounds: b
|
|
4498
|
+
}) : fillStyle, setTextStyle(ctx, character);
|
|
4210
4499
|
}
|
|
4211
4500
|
function applyStrokeStyle(ctx, character) {
|
|
4212
4501
|
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
@@ -11120,695 +11409,409 @@
|
|
|
11120
11409
|
const m = this.pools.pop();
|
|
11121
11410
|
return m.a = a, m.b = b, m.c = c, m.d = d, m.e = e, m.f = f, m;
|
|
11122
11411
|
}
|
|
11123
|
-
allocateByObj(matrix) {
|
|
11124
|
-
if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
|
|
11125
|
-
const m = this.pools.pop();
|
|
11126
|
-
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;
|
|
11127
|
-
}
|
|
11128
|
-
free(d) {
|
|
11129
|
-
this.pools.push(d);
|
|
11130
|
-
}
|
|
11131
|
-
get length() {
|
|
11132
|
-
return this.pools.length;
|
|
11133
|
-
}
|
|
11134
|
-
release() {
|
|
11135
|
-
this.pools = [];
|
|
11136
|
-
}
|
|
11137
|
-
}
|
|
11138
|
-
class DefaultMat4Allocate {
|
|
11139
|
-
constructor() {
|
|
11140
|
-
this.pools = [];
|
|
11141
|
-
}
|
|
11142
|
-
static identity(out) {
|
|
11143
|
-
return identityMat4(out);
|
|
11144
|
-
}
|
|
11145
|
-
allocate() {
|
|
11146
|
-
if (!this.pools.length) return createMat4();
|
|
11147
|
-
const m = this.pools.pop();
|
|
11148
|
-
return DefaultMat4Allocate.identity(m), m;
|
|
11149
|
-
}
|
|
11150
|
-
allocateByObj(d) {
|
|
11151
|
-
let m;
|
|
11152
|
-
m = this.pools.length ? this.pools.pop() : createMat4();
|
|
11153
|
-
for (let i = 0; i < m.length; i++) m[i] = d[i];
|
|
11154
|
-
return m;
|
|
11155
|
-
}
|
|
11156
|
-
free(m) {
|
|
11157
|
-
m && this.pools.push(m);
|
|
11158
|
-
}
|
|
11159
|
-
get length() {
|
|
11160
|
-
return this.pools.length;
|
|
11161
|
-
}
|
|
11162
|
-
release() {
|
|
11163
|
-
this.pools = [];
|
|
11164
|
-
}
|
|
11165
|
-
}
|
|
11166
|
-
const matrixAllocate = new DefaultMatrixAllocate();
|
|
11167
|
-
const mat4Allocate = new DefaultMat4Allocate();
|
|
11168
|
-
|
|
11169
|
-
var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
11170
|
-
var d,
|
|
11171
|
-
c = arguments.length,
|
|
11172
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
11173
|
-
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);
|
|
11174
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11175
|
-
},
|
|
11176
|
-
__metadata$1d = undefined && undefined.__metadata || function (k, v) {
|
|
11177
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11178
|
-
},
|
|
11179
|
-
__param$R = undefined && undefined.__param || function (paramIndex, decorator) {
|
|
11180
|
-
return function (target, key) {
|
|
11181
|
-
decorator(target, key, paramIndex);
|
|
11182
|
-
};
|
|
11183
|
-
};
|
|
11184
|
-
function getExtraModelMatrix(dx, dy, graphic) {
|
|
11185
|
-
const {
|
|
11186
|
-
alpha: alpha,
|
|
11187
|
-
beta: beta
|
|
11188
|
-
} = graphic.attribute;
|
|
11189
|
-
if (!alpha && !beta) return null;
|
|
11190
|
-
const {
|
|
11191
|
-
anchor3d = graphic.attribute.anchor
|
|
11192
|
-
} = graphic.attribute,
|
|
11193
|
-
_anchor = [0, 0];
|
|
11194
|
-
if (anchor3d) {
|
|
11195
|
-
if ("string" == typeof anchor3d[0]) {
|
|
11196
|
-
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11197
|
-
bounds = graphic.AABBBounds;
|
|
11198
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11199
|
-
} else _anchor[0] = anchor3d[0];
|
|
11200
|
-
if ("string" == typeof anchor3d[1]) {
|
|
11201
|
-
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11202
|
-
bounds = graphic.AABBBounds;
|
|
11203
|
-
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11204
|
-
} else _anchor[1] = anchor3d[1];
|
|
11205
|
-
}
|
|
11206
|
-
if ("text" === graphic.type) {
|
|
11207
|
-
const {
|
|
11208
|
-
textAlign: textAlign
|
|
11209
|
-
} = graphic.attribute;
|
|
11210
|
-
_anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
|
|
11211
|
-
}
|
|
11212
|
-
_anchor[0] += dx, _anchor[1] += dy;
|
|
11213
|
-
const modelMatrix = mat4Allocate.allocate();
|
|
11214
|
-
return translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]), beta && rotateX(modelMatrix, modelMatrix, beta), alpha && rotateY(modelMatrix, modelMatrix, alpha), translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]), modelMatrix;
|
|
11215
|
-
}
|
|
11216
|
-
function getModelMatrix(out, graphic, theme) {
|
|
11217
|
-
var _a;
|
|
11218
|
-
const {
|
|
11219
|
-
x = theme.x,
|
|
11220
|
-
y = theme.y,
|
|
11221
|
-
z = theme.z,
|
|
11222
|
-
dx = theme.dx,
|
|
11223
|
-
dy = theme.dy,
|
|
11224
|
-
dz = theme.dz,
|
|
11225
|
-
scaleX = theme.scaleX,
|
|
11226
|
-
scaleY = theme.scaleY,
|
|
11227
|
-
scaleZ = theme.scaleZ,
|
|
11228
|
-
alpha = theme.alpha,
|
|
11229
|
-
beta = theme.beta,
|
|
11230
|
-
angle = theme.angle,
|
|
11231
|
-
anchor3d = graphic.attribute.anchor,
|
|
11232
|
-
anchor: anchor
|
|
11233
|
-
} = graphic.attribute,
|
|
11234
|
-
_anchor = [0, 0, 0];
|
|
11235
|
-
if (anchor3d) {
|
|
11236
|
-
if ("string" == typeof anchor3d[0]) {
|
|
11237
|
-
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11238
|
-
bounds = graphic.AABBBounds;
|
|
11239
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11240
|
-
} else _anchor[0] = anchor3d[0];
|
|
11241
|
-
if ("string" == typeof anchor3d[1]) {
|
|
11242
|
-
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11243
|
-
bounds = graphic.AABBBounds;
|
|
11244
|
-
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11245
|
-
} else _anchor[1] = anchor3d[1];
|
|
11246
|
-
_anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
|
|
11247
|
-
}
|
|
11248
|
-
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) {
|
|
11249
|
-
const m = mat4Allocate.allocate(),
|
|
11250
|
-
_anchor = [0, 0];
|
|
11251
|
-
if (anchor) {
|
|
11252
|
-
if ("string" == typeof anchor3d[0]) {
|
|
11253
|
-
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11254
|
-
bounds = graphic.AABBBounds;
|
|
11255
|
-
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11256
|
-
} else _anchor[0] = anchor3d[0];
|
|
11257
|
-
if ("string" == typeof anchor3d[1]) {
|
|
11258
|
-
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11259
|
-
bounds = graphic.AABBBounds;
|
|
11260
|
-
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11261
|
-
} else _anchor[1] = anchor3d[1];
|
|
11262
|
-
}
|
|
11263
|
-
translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
|
|
11264
|
-
}
|
|
11265
|
-
}
|
|
11266
|
-
function shouldUseMat4(graphic) {
|
|
11267
|
-
const {
|
|
11268
|
-
alpha: alpha,
|
|
11269
|
-
beta: beta
|
|
11270
|
-
} = graphic.attribute;
|
|
11271
|
-
return alpha || beta;
|
|
11272
|
-
}
|
|
11273
|
-
exports.DefaultGraphicService = class DefaultGraphicService {
|
|
11274
|
-
constructor(creator) {
|
|
11275
|
-
this.creator = creator, this.hooks = {
|
|
11276
|
-
onAttributeUpdate: new SyncHook(["graphic"]),
|
|
11277
|
-
onSetStage: new SyncHook(["graphic", "stage"]),
|
|
11278
|
-
onRemove: new SyncHook(["graphic"]),
|
|
11279
|
-
onRelease: new SyncHook(["graphic"]),
|
|
11280
|
-
onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11281
|
-
onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11282
|
-
beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
|
|
11283
|
-
afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
|
|
11284
|
-
}, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
|
|
11285
|
-
}
|
|
11286
|
-
onAttributeUpdate(graphic) {
|
|
11287
|
-
this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
|
|
11288
|
-
}
|
|
11289
|
-
onSetStage(graphic, stage) {
|
|
11290
|
-
this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
|
|
11291
|
-
}
|
|
11292
|
-
onRemove(graphic) {
|
|
11293
|
-
this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
|
|
11294
|
-
}
|
|
11295
|
-
onRelease(graphic) {
|
|
11296
|
-
this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
|
|
11297
|
-
}
|
|
11298
|
-
onAddIncremental(graphic, group, stage) {
|
|
11299
|
-
this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
|
|
11300
|
-
}
|
|
11301
|
-
onClearIncremental(group, stage) {
|
|
11302
|
-
this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
|
|
11303
|
-
}
|
|
11304
|
-
beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
|
|
11305
|
-
this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
|
|
11306
|
-
}
|
|
11307
|
-
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
11308
|
-
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
11309
|
-
}
|
|
11310
|
-
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
11311
|
-
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
11312
|
-
if (!path) return !1;
|
|
11313
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
11314
|
-
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
11315
|
-
}
|
|
11316
|
-
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
11317
|
-
const {
|
|
11318
|
-
textAlign: textAlign,
|
|
11319
|
-
textBaseline: textBaseline
|
|
11320
|
-
} = attribute;
|
|
11321
|
-
if (null != attribute.forceBoundsHeight) {
|
|
11322
|
-
const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
11323
|
-
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
11324
|
-
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
11325
|
-
}
|
|
11326
|
-
if (null != attribute.forceBoundsWidth) {
|
|
11327
|
-
const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
11328
|
-
dx = textDrawOffsetX(textAlign, w);
|
|
11329
|
-
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
11330
|
-
}
|
|
11331
|
-
}
|
|
11332
|
-
combindShadowAABBBounds(bounds, graphic) {
|
|
11333
|
-
if (graphic && graphic.shadowRoot) {
|
|
11334
|
-
const b = graphic.shadowRoot.AABBBounds;
|
|
11335
|
-
bounds.union(b);
|
|
11336
|
-
}
|
|
11337
|
-
}
|
|
11338
|
-
transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
|
|
11339
|
-
if (!aabbBounds.empty()) {
|
|
11340
|
-
const {
|
|
11341
|
-
scaleX = theme.scaleX,
|
|
11342
|
-
scaleY = theme.scaleY,
|
|
11343
|
-
stroke = theme.stroke,
|
|
11344
|
-
shadowBlur = theme.shadowBlur,
|
|
11345
|
-
lineWidth = theme.lineWidth,
|
|
11346
|
-
pickStrokeBuffer = theme.pickStrokeBuffer,
|
|
11347
|
-
strokeBoundsBuffer = theme.strokeBoundsBuffer
|
|
11348
|
-
} = attribute,
|
|
11349
|
-
tb1 = this.tempAABBBounds1,
|
|
11350
|
-
tb2 = this.tempAABBBounds2;
|
|
11351
|
-
if (stroke && lineWidth) {
|
|
11352
|
-
const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
|
|
11353
|
-
boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
11354
|
-
}
|
|
11355
|
-
if (shadowBlur) {
|
|
11356
|
-
const {
|
|
11357
|
-
shadowOffsetX = theme.shadowOffsetX,
|
|
11358
|
-
shadowOffsetY = theme.shadowOffsetY
|
|
11359
|
-
} = attribute,
|
|
11360
|
-
shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
|
|
11361
|
-
boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
|
|
11362
|
-
}
|
|
11363
|
-
}
|
|
11364
|
-
if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
|
|
11365
|
-
let updateMatrix = !0;
|
|
11366
|
-
const m = graphic.transMatrix;
|
|
11367
|
-
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);
|
|
11412
|
+
allocateByObj(matrix) {
|
|
11413
|
+
if (!this.pools.length) return new Matrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
|
|
11414
|
+
const m = this.pools.pop();
|
|
11415
|
+
return m.a = matrix.a, m.b = matrix.b, m.c = matrix.c, m.d = matrix.d, m.e = matrix.e, m.f = matrix.f, m;
|
|
11368
11416
|
}
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
11372
|
-
if (graphic.shadowRoot) return !0;
|
|
11373
|
-
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
11374
|
-
const {
|
|
11375
|
-
visible = theme.visible
|
|
11376
|
-
} = attribute;
|
|
11377
|
-
return !!visible || (aabbBounds.clear(), !1);
|
|
11417
|
+
free(d) {
|
|
11418
|
+
this.pools.push(d);
|
|
11378
11419
|
}
|
|
11379
|
-
|
|
11380
|
-
|
|
11381
|
-
tb2 = this.tempAABBBounds2;
|
|
11382
|
-
return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
|
|
11383
|
-
tb1: tb1,
|
|
11384
|
-
tb2: tb2
|
|
11385
|
-
};
|
|
11420
|
+
get length() {
|
|
11421
|
+
return this.pools.length;
|
|
11386
11422
|
}
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
const result = {
|
|
11391
|
-
x: 0,
|
|
11392
|
-
y: 0,
|
|
11393
|
-
z: 0,
|
|
11394
|
-
lastModelMatrix: null
|
|
11395
|
-
};
|
|
11396
|
-
class BaseRender {
|
|
11397
|
-
init(contributions) {
|
|
11398
|
-
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
|
|
11423
|
+
release() {
|
|
11424
|
+
this.pools = [];
|
|
11399
11425
|
}
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
}
|
|
11405
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11406
|
-
});
|
|
11426
|
+
}
|
|
11427
|
+
class DefaultMat4Allocate {
|
|
11428
|
+
constructor() {
|
|
11429
|
+
this.pools = [];
|
|
11407
11430
|
}
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
11411
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
11412
|
-
}
|
|
11413
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11414
|
-
});
|
|
11431
|
+
static identity(out) {
|
|
11432
|
+
return identityMat4(out);
|
|
11415
11433
|
}
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
stroke = defaultAttribute.stroke,
|
|
11421
|
-
opacity = defaultAttribute.opacity,
|
|
11422
|
-
fillOpacity = defaultAttribute.fillOpacity,
|
|
11423
|
-
lineWidth = defaultAttribute.lineWidth,
|
|
11424
|
-
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
11425
|
-
visible = defaultAttribute.visible
|
|
11426
|
-
} = graphic.attribute,
|
|
11427
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
11428
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
11429
|
-
doFill = runFill(fill, background),
|
|
11430
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
11431
|
-
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
11432
|
-
fVisible: fVisible,
|
|
11433
|
-
sVisible: sVisible,
|
|
11434
|
-
doFill: doFill,
|
|
11435
|
-
doStroke: doStroke
|
|
11436
|
-
};
|
|
11434
|
+
allocate() {
|
|
11435
|
+
if (!this.pools.length) return createMat4();
|
|
11436
|
+
const m = this.pools.pop();
|
|
11437
|
+
return DefaultMat4Allocate.identity(m), m;
|
|
11437
11438
|
}
|
|
11438
|
-
|
|
11439
|
-
let
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
z = graphicAttribute.z,
|
|
11444
|
-
scaleX = graphicAttribute.scaleX,
|
|
11445
|
-
scaleY = graphicAttribute.scaleY,
|
|
11446
|
-
angle = graphicAttribute.angle,
|
|
11447
|
-
postMatrix: postMatrix
|
|
11448
|
-
} = graphic.attribute,
|
|
11449
|
-
lastModelMatrix = context.modelMatrix,
|
|
11450
|
-
camera = context.camera;
|
|
11451
|
-
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
11452
|
-
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
11453
|
-
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
11454
|
-
if (shouldTransform3d) {
|
|
11455
|
-
const nextModelMatrix = mat4Allocate.allocate(),
|
|
11456
|
-
modelMatrix = mat4Allocate.allocate();
|
|
11457
|
-
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);
|
|
11458
|
-
}
|
|
11459
|
-
if (onlyTranslate && !lastModelMatrix) {
|
|
11460
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11461
|
-
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
11462
|
-
} 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) {
|
|
11463
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11464
|
-
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
11465
|
-
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
11466
|
-
return result;
|
|
11439
|
+
allocateByObj(d) {
|
|
11440
|
+
let m;
|
|
11441
|
+
m = this.pools.length ? this.pools.pop() : createMat4();
|
|
11442
|
+
for (let i = 0; i < m.length; i++) m[i] = d[i];
|
|
11443
|
+
return m;
|
|
11467
11444
|
}
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
if (this.camera = camera, camera) {
|
|
11471
|
-
const bounds = graphic.AABBBounds,
|
|
11472
|
-
width = bounds.x2 - bounds.x1,
|
|
11473
|
-
height = bounds.y2 - bounds.y1,
|
|
11474
|
-
p1 = context.project(0, 0, z),
|
|
11475
|
-
p2 = context.project(width, 0, z),
|
|
11476
|
-
p3 = context.project(width, height, z),
|
|
11477
|
-
_p1 = {
|
|
11478
|
-
x: 0,
|
|
11479
|
-
y: 0
|
|
11480
|
-
},
|
|
11481
|
-
_p2 = {
|
|
11482
|
-
x: width,
|
|
11483
|
-
y: 0
|
|
11484
|
-
},
|
|
11485
|
-
_p3 = {
|
|
11486
|
-
x: width,
|
|
11487
|
-
y: height
|
|
11488
|
-
};
|
|
11489
|
-
context.camera = null;
|
|
11490
|
-
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
11491
|
-
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
11492
|
-
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
11493
|
-
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
11494
|
-
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
11495
|
-
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,
|
|
11496
|
-
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;
|
|
11497
|
-
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
11498
|
-
}
|
|
11445
|
+
free(m) {
|
|
11446
|
+
m && this.pools.push(m);
|
|
11499
11447
|
}
|
|
11500
|
-
|
|
11501
|
-
this.
|
|
11448
|
+
get length() {
|
|
11449
|
+
return this.pools.length;
|
|
11502
11450
|
}
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
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();
|
|
11451
|
+
release() {
|
|
11452
|
+
this.pools = [];
|
|
11506
11453
|
}
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11454
|
+
}
|
|
11455
|
+
const matrixAllocate = new DefaultMatrixAllocate();
|
|
11456
|
+
const mat4Allocate = new DefaultMat4Allocate();
|
|
11457
|
+
|
|
11458
|
+
var __decorate$1B = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
11459
|
+
var d,
|
|
11460
|
+
c = arguments.length,
|
|
11461
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
11462
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
11463
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11464
|
+
},
|
|
11465
|
+
__metadata$1d = undefined && undefined.__metadata || function (k, v) {
|
|
11466
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
11467
|
+
},
|
|
11468
|
+
__param$R = undefined && undefined.__param || function (paramIndex, decorator) {
|
|
11469
|
+
return function (target, key) {
|
|
11470
|
+
decorator(target, key, paramIndex);
|
|
11471
|
+
};
|
|
11472
|
+
};
|
|
11473
|
+
function getExtraModelMatrix(dx, dy, graphic) {
|
|
11474
|
+
const {
|
|
11475
|
+
alpha: alpha,
|
|
11476
|
+
beta: beta
|
|
11477
|
+
} = graphic.attribute;
|
|
11478
|
+
if (!alpha && !beta) return null;
|
|
11479
|
+
const {
|
|
11480
|
+
anchor3d = graphic.attribute.anchor
|
|
11481
|
+
} = graphic.attribute,
|
|
11482
|
+
_anchor = [0, 0];
|
|
11483
|
+
if (anchor3d) {
|
|
11484
|
+
if ("string" == typeof anchor3d[0]) {
|
|
11485
|
+
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11486
|
+
bounds = graphic.AABBBounds;
|
|
11487
|
+
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11488
|
+
} else _anchor[0] = anchor3d[0];
|
|
11489
|
+
if ("string" == typeof anchor3d[1]) {
|
|
11490
|
+
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11491
|
+
bounds = graphic.AABBBounds;
|
|
11492
|
+
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11493
|
+
} else _anchor[1] = anchor3d[1];
|
|
11494
|
+
}
|
|
11495
|
+
if ("text" === graphic.type) {
|
|
11512
11496
|
const {
|
|
11513
|
-
|
|
11497
|
+
textAlign: textAlign
|
|
11514
11498
|
} = graphic.attribute;
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11499
|
+
_anchor[0] += textDrawOffsetX(textAlign, graphic.clipedWidth);
|
|
11500
|
+
}
|
|
11501
|
+
_anchor[0] += dx, _anchor[1] += dy;
|
|
11502
|
+
const modelMatrix = mat4Allocate.allocate();
|
|
11503
|
+
return translate(modelMatrix, modelMatrix, [_anchor[0], _anchor[1], 0]), beta && rotateX(modelMatrix, modelMatrix, beta), alpha && rotateY(modelMatrix, modelMatrix, alpha), translate(modelMatrix, modelMatrix, [-_anchor[0], -_anchor[1], 0]), modelMatrix;
|
|
11504
|
+
}
|
|
11505
|
+
function getModelMatrix(out, graphic, theme) {
|
|
11506
|
+
var _a;
|
|
11507
|
+
const {
|
|
11508
|
+
x = theme.x,
|
|
11509
|
+
y = theme.y,
|
|
11510
|
+
z = theme.z,
|
|
11511
|
+
dx = theme.dx,
|
|
11512
|
+
dy = theme.dy,
|
|
11513
|
+
dz = theme.dz,
|
|
11514
|
+
scaleX = theme.scaleX,
|
|
11515
|
+
scaleY = theme.scaleY,
|
|
11516
|
+
scaleZ = theme.scaleZ,
|
|
11517
|
+
alpha = theme.alpha,
|
|
11518
|
+
beta = theme.beta,
|
|
11519
|
+
angle = theme.angle,
|
|
11520
|
+
anchor3d = graphic.attribute.anchor,
|
|
11521
|
+
anchor: anchor
|
|
11522
|
+
} = graphic.attribute,
|
|
11523
|
+
_anchor = [0, 0, 0];
|
|
11524
|
+
if (anchor3d) {
|
|
11525
|
+
if ("string" == typeof anchor3d[0]) {
|
|
11526
|
+
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11527
|
+
bounds = graphic.AABBBounds;
|
|
11528
|
+
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11529
|
+
} else _anchor[0] = anchor3d[0];
|
|
11530
|
+
if ("string" == typeof anchor3d[1]) {
|
|
11531
|
+
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11532
|
+
bounds = graphic.AABBBounds;
|
|
11533
|
+
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11534
|
+
} else _anchor[1] = anchor3d[1];
|
|
11535
|
+
_anchor[2] = null !== (_a = anchor3d[2]) && void 0 !== _a ? _a : 0;
|
|
11536
|
+
}
|
|
11537
|
+
if (identityMat4(out), translate(out, out, [x + dx, y + dy, z + dz]), translate(out, out, [_anchor[0], _anchor[1], _anchor[2]]), rotateX(out, out, beta), rotateY(out, out, alpha), translate(out, out, [-_anchor[0], -_anchor[1], _anchor[2]]), scaleMat4(out, out, [scaleX, scaleY, scaleZ]), angle) {
|
|
11538
|
+
const m = mat4Allocate.allocate(),
|
|
11539
|
+
_anchor = [0, 0];
|
|
11540
|
+
if (anchor) {
|
|
11541
|
+
if ("string" == typeof anchor3d[0]) {
|
|
11542
|
+
const ratio = parseFloat(anchor3d[0]) / 100,
|
|
11543
|
+
bounds = graphic.AABBBounds;
|
|
11544
|
+
_anchor[0] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11545
|
+
} else _anchor[0] = anchor3d[0];
|
|
11546
|
+
if ("string" == typeof anchor3d[1]) {
|
|
11547
|
+
const ratio = parseFloat(anchor3d[1]) / 100,
|
|
11548
|
+
bounds = graphic.AABBBounds;
|
|
11549
|
+
_anchor[1] = bounds.x1 + (bounds.x2 - bounds.x1) * ratio;
|
|
11550
|
+
} else _anchor[1] = anchor3d[1];
|
|
11551
|
+
}
|
|
11552
|
+
translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
|
|
11525
11553
|
}
|
|
11526
11554
|
}
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
11547
|
-
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
11548
|
-
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
11549
|
-
};
|
|
11550
|
-
let input = "";
|
|
11551
|
-
function error(msg) {
|
|
11552
|
-
const err = new Error(input + ": " + msg);
|
|
11553
|
-
throw err.source = input, err;
|
|
11554
|
-
}
|
|
11555
|
-
function getAST() {
|
|
11556
|
-
const ast = matchListing(matchDefinition);
|
|
11557
|
-
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
11555
|
+
function shouldUseMat4(graphic) {
|
|
11556
|
+
const {
|
|
11557
|
+
alpha: alpha,
|
|
11558
|
+
beta: beta
|
|
11559
|
+
} = graphic.attribute;
|
|
11560
|
+
return alpha || beta;
|
|
11561
|
+
}
|
|
11562
|
+
exports.DefaultGraphicService = class DefaultGraphicService {
|
|
11563
|
+
constructor(creator) {
|
|
11564
|
+
this.creator = creator, this.hooks = {
|
|
11565
|
+
onAttributeUpdate: new SyncHook(["graphic"]),
|
|
11566
|
+
onSetStage: new SyncHook(["graphic", "stage"]),
|
|
11567
|
+
onRemove: new SyncHook(["graphic"]),
|
|
11568
|
+
onRelease: new SyncHook(["graphic"]),
|
|
11569
|
+
onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11570
|
+
onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11571
|
+
beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
|
|
11572
|
+
afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
|
|
11573
|
+
}, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
|
|
11558
11574
|
}
|
|
11559
|
-
|
|
11560
|
-
|
|
11575
|
+
onAttributeUpdate(graphic) {
|
|
11576
|
+
this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
|
|
11561
11577
|
}
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
const captures = scan(pattern);
|
|
11565
|
-
if (captures) {
|
|
11566
|
-
scan(tokens.startCall) || error("Missing (");
|
|
11567
|
-
const result = callback(captures);
|
|
11568
|
-
return scan(tokens.endCall) || error("Missing )"), result;
|
|
11569
|
-
}
|
|
11570
|
-
}(pattern, function (captures) {
|
|
11571
|
-
const orientation = orientationMatcher();
|
|
11572
|
-
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
|
|
11573
|
-
type: gradientType,
|
|
11574
|
-
orientation: orientation,
|
|
11575
|
-
colorStops: matchListing(matchColorStop)
|
|
11576
|
-
};
|
|
11577
|
-
});
|
|
11578
|
+
onSetStage(graphic, stage) {
|
|
11579
|
+
this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
|
|
11578
11580
|
}
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
+
onRemove(graphic) {
|
|
11582
|
+
this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
|
|
11581
11583
|
}
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
+
onRelease(graphic) {
|
|
11585
|
+
this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
|
|
11584
11586
|
}
|
|
11585
|
-
|
|
11586
|
-
|
|
11587
|
-
lookaheadCache,
|
|
11588
|
-
radialOrientation = matchRadialOrientation();
|
|
11589
|
-
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
11587
|
+
onAddIncremental(graphic, group, stage) {
|
|
11588
|
+
this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
|
|
11590
11589
|
}
|
|
11591
|
-
|
|
11592
|
-
|
|
11593
|
-
const circle = match("shape", /^(circle)/i, 0);
|
|
11594
|
-
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
11595
|
-
return circle;
|
|
11596
|
-
}() || function () {
|
|
11597
|
-
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
11598
|
-
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
11599
|
-
return ellipse;
|
|
11600
|
-
}();
|
|
11601
|
-
if (radialType) radialType.at = matchAtPosition();else {
|
|
11602
|
-
const extent = matchExtentKeyword();
|
|
11603
|
-
if (extent) {
|
|
11604
|
-
radialType = extent;
|
|
11605
|
-
const positionAt = matchAtPosition();
|
|
11606
|
-
positionAt && (radialType.at = positionAt);
|
|
11607
|
-
} else {
|
|
11608
|
-
const defaultPosition = matchPositioning();
|
|
11609
|
-
defaultPosition && (radialType = {
|
|
11610
|
-
type: "default-radial",
|
|
11611
|
-
at: defaultPosition
|
|
11612
|
-
});
|
|
11613
|
-
}
|
|
11614
|
-
}
|
|
11615
|
-
return radialType;
|
|
11590
|
+
onClearIncremental(group, stage) {
|
|
11591
|
+
this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
|
|
11616
11592
|
}
|
|
11617
|
-
|
|
11618
|
-
|
|
11593
|
+
beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
|
|
11594
|
+
this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
|
|
11619
11595
|
}
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
const positioning = matchPositioning();
|
|
11623
|
-
return positioning || error("Missing positioning value"), positioning;
|
|
11624
|
-
}
|
|
11596
|
+
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
11597
|
+
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
11625
11598
|
}
|
|
11626
|
-
|
|
11627
|
-
const
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
if (location.x || location.y) return {
|
|
11632
|
-
type: "position",
|
|
11633
|
-
value: location
|
|
11634
|
-
};
|
|
11599
|
+
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
11600
|
+
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
11601
|
+
if (!path) return !1;
|
|
11602
|
+
const boundsContext = new BoundsContext(aabbBounds);
|
|
11603
|
+
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
11635
11604
|
}
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11605
|
+
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
11606
|
+
const {
|
|
11607
|
+
textAlign: textAlign,
|
|
11608
|
+
textBaseline: textBaseline
|
|
11609
|
+
} = attribute;
|
|
11610
|
+
if (null != attribute.forceBoundsHeight) {
|
|
11611
|
+
const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
11612
|
+
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
11613
|
+
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
11614
|
+
}
|
|
11615
|
+
if (null != attribute.forceBoundsWidth) {
|
|
11616
|
+
const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
11617
|
+
dx = textDrawOffsetX(textAlign, w);
|
|
11618
|
+
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
11619
|
+
}
|
|
11641
11620
|
}
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11621
|
+
combindShadowAABBBounds(bounds, graphic) {
|
|
11622
|
+
if (graphic && graphic.shadowRoot) {
|
|
11623
|
+
const b = graphic.shadowRoot.AABBBounds;
|
|
11624
|
+
bounds.union(b);
|
|
11625
|
+
}
|
|
11645
11626
|
}
|
|
11646
|
-
|
|
11647
|
-
|
|
11627
|
+
transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
|
|
11628
|
+
if (!aabbBounds.empty()) {
|
|
11629
|
+
const {
|
|
11630
|
+
scaleX = theme.scaleX,
|
|
11631
|
+
scaleY = theme.scaleY,
|
|
11632
|
+
stroke = theme.stroke,
|
|
11633
|
+
shadowBlur = theme.shadowBlur,
|
|
11634
|
+
lineWidth = theme.lineWidth,
|
|
11635
|
+
pickStrokeBuffer = theme.pickStrokeBuffer,
|
|
11636
|
+
strokeBoundsBuffer = theme.strokeBoundsBuffer
|
|
11637
|
+
} = attribute,
|
|
11638
|
+
tb1 = this.tempAABBBounds1,
|
|
11639
|
+
tb2 = this.tempAABBBounds2;
|
|
11640
|
+
if (stroke && lineWidth) {
|
|
11641
|
+
const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
|
|
11642
|
+
boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
11643
|
+
}
|
|
11644
|
+
if (shadowBlur) {
|
|
11645
|
+
const {
|
|
11646
|
+
shadowOffsetX = theme.shadowOffsetX,
|
|
11647
|
+
shadowOffsetY = theme.shadowOffsetY
|
|
11648
|
+
} = attribute,
|
|
11649
|
+
shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
|
|
11650
|
+
boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
|
|
11651
|
+
}
|
|
11652
|
+
}
|
|
11653
|
+
if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
|
|
11654
|
+
let updateMatrix = !0;
|
|
11655
|
+
const m = graphic.transMatrix;
|
|
11656
|
+
graphic && graphic.isContainer && (updateMatrix = !(1 === m.a && 0 === m.b && 0 === m.c && 1 === m.d && 0 === m.e && 0 === m.f)), updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);
|
|
11648
11657
|
}
|
|
11649
|
-
|
|
11650
|
-
|
|
11658
|
+
validCheck(attribute, theme, aabbBounds, graphic) {
|
|
11659
|
+
if (!graphic) return !0;
|
|
11660
|
+
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
11661
|
+
if (graphic.shadowRoot) return !0;
|
|
11662
|
+
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
11663
|
+
const {
|
|
11664
|
+
visible = theme.visible
|
|
11665
|
+
} = attribute;
|
|
11666
|
+
return !!visible || (aabbBounds.clear(), !1);
|
|
11651
11667
|
}
|
|
11652
|
-
|
|
11653
|
-
const
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11668
|
+
updateTempAABBBounds(aabbBounds) {
|
|
11669
|
+
const tb1 = this.tempAABBBounds1,
|
|
11670
|
+
tb2 = this.tempAABBBounds2;
|
|
11671
|
+
return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
|
|
11672
|
+
tb1: tb1,
|
|
11673
|
+
tb2: tb2
|
|
11657
11674
|
};
|
|
11658
11675
|
}
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
}();
|
|
11672
|
-
class GradientParser {
|
|
11673
|
-
static IsGradient(c) {
|
|
11674
|
-
return !("string" == typeof c && !c.includes("gradient"));
|
|
11675
|
-
}
|
|
11676
|
-
static IsGradientStr(c) {
|
|
11677
|
-
return "string" == typeof c && c.includes("gradient");
|
|
11676
|
+
};
|
|
11677
|
+
exports.DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], exports.DefaultGraphicService);
|
|
11678
|
+
|
|
11679
|
+
const result = {
|
|
11680
|
+
x: 0,
|
|
11681
|
+
y: 0,
|
|
11682
|
+
z: 0,
|
|
11683
|
+
lastModelMatrix: null
|
|
11684
|
+
};
|
|
11685
|
+
class BaseRender {
|
|
11686
|
+
init(contributions) {
|
|
11687
|
+
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
|
|
11678
11688
|
}
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
11684
|
-
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
11685
|
-
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
11689
|
+
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
11690
|
+
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
11691
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
11692
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
11686
11693
|
}
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
}
|
|
11690
|
-
return c;
|
|
11694
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11695
|
+
});
|
|
11691
11696
|
}
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
return {
|
|
11700
|
-
gradient: "conical",
|
|
11701
|
-
x: .5,
|
|
11702
|
-
y: .5,
|
|
11703
|
-
startAngle: sa,
|
|
11704
|
-
endAngle: sa + pi2,
|
|
11705
|
-
stops: colorStops.map(item => ({
|
|
11706
|
-
color: item.value,
|
|
11707
|
-
offset: parseFloat(item.length.value) / 100
|
|
11708
|
-
}))
|
|
11709
|
-
};
|
|
11697
|
+
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
11698
|
+
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
11699
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
11700
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
11701
|
+
}
|
|
11702
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11703
|
+
});
|
|
11710
11704
|
}
|
|
11711
|
-
|
|
11705
|
+
valid(graphic, defaultAttribute, fillCb, strokeCb) {
|
|
11712
11706
|
const {
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11707
|
+
fill = defaultAttribute.fill,
|
|
11708
|
+
background: background,
|
|
11709
|
+
stroke = defaultAttribute.stroke,
|
|
11710
|
+
opacity = defaultAttribute.opacity,
|
|
11711
|
+
fillOpacity = defaultAttribute.fillOpacity,
|
|
11712
|
+
lineWidth = defaultAttribute.lineWidth,
|
|
11713
|
+
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
11714
|
+
visible = defaultAttribute.visible
|
|
11715
|
+
} = graphic.attribute,
|
|
11716
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
11717
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
11718
|
+
doFill = runFill(fill, background),
|
|
11719
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
11720
|
+
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
11721
|
+
fVisible: fVisible,
|
|
11722
|
+
sVisible: sVisible,
|
|
11723
|
+
doFill: doFill,
|
|
11724
|
+
doStroke: doStroke
|
|
11727
11725
|
};
|
|
11728
11726
|
}
|
|
11729
|
-
|
|
11727
|
+
transform(graphic, graphicAttribute, context) {
|
|
11728
|
+
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
11730
11729
|
const {
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
};
|
|
11730
|
+
x = graphicAttribute.x,
|
|
11731
|
+
y = graphicAttribute.y,
|
|
11732
|
+
z = graphicAttribute.z,
|
|
11733
|
+
scaleX = graphicAttribute.scaleX,
|
|
11734
|
+
scaleY = graphicAttribute.scaleY,
|
|
11735
|
+
angle = graphicAttribute.angle,
|
|
11736
|
+
postMatrix: postMatrix
|
|
11737
|
+
} = graphic.attribute,
|
|
11738
|
+
lastModelMatrix = context.modelMatrix,
|
|
11739
|
+
camera = context.camera;
|
|
11740
|
+
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
11741
|
+
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
11742
|
+
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
11743
|
+
if (shouldTransform3d) {
|
|
11744
|
+
const nextModelMatrix = mat4Allocate.allocate(),
|
|
11745
|
+
modelMatrix = mat4Allocate.allocate();
|
|
11746
|
+
getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
|
|
11747
|
+
}
|
|
11748
|
+
if (onlyTranslate && !lastModelMatrix) {
|
|
11749
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11750
|
+
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
11751
|
+
} else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
|
|
11752
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11753
|
+
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
11754
|
+
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
11755
|
+
return result;
|
|
11753
11756
|
}
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
scaleY = 1
|
|
11785
|
-
} = params.attribute;
|
|
11786
|
-
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
11757
|
+
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11758
|
+
const camera = context.camera;
|
|
11759
|
+
if (this.camera = camera, camera) {
|
|
11760
|
+
const bounds = graphic.AABBBounds,
|
|
11761
|
+
width = bounds.x2 - bounds.x1,
|
|
11762
|
+
height = bounds.y2 - bounds.y1,
|
|
11763
|
+
p1 = context.project(0, 0, z),
|
|
11764
|
+
p2 = context.project(width, 0, z),
|
|
11765
|
+
p3 = context.project(width, height, z),
|
|
11766
|
+
_p1 = {
|
|
11767
|
+
x: 0,
|
|
11768
|
+
y: 0
|
|
11769
|
+
},
|
|
11770
|
+
_p2 = {
|
|
11771
|
+
x: width,
|
|
11772
|
+
y: 0
|
|
11773
|
+
},
|
|
11774
|
+
_p3 = {
|
|
11775
|
+
x: width,
|
|
11776
|
+
y: height
|
|
11777
|
+
};
|
|
11778
|
+
context.camera = null;
|
|
11779
|
+
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
11780
|
+
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
11781
|
+
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
11782
|
+
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
11783
|
+
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
11784
|
+
dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
|
|
11785
|
+
dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
|
|
11786
|
+
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
11787
11787
|
}
|
|
11788
|
-
"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));
|
|
11789
11788
|
}
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11796
|
-
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11789
|
+
restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11790
|
+
this.camera && (context.camera = this.camera);
|
|
11791
|
+
}
|
|
11792
|
+
transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
|
|
11793
|
+
const p = context.project(x, y, z);
|
|
11794
|
+
context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
|
|
11795
|
+
}
|
|
11796
|
+
_draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
|
|
11797
|
+
const {
|
|
11798
|
+
context: context
|
|
11799
|
+
} = drawContext;
|
|
11800
|
+
if (!context) return;
|
|
11801
|
+
const {
|
|
11802
|
+
renderable: renderable
|
|
11803
|
+
} = graphic.attribute;
|
|
11804
|
+
if (!1 === renderable) return;
|
|
11805
|
+
context.highPerformanceSave();
|
|
11806
|
+
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
11807
|
+
{
|
|
11808
|
+
x: x,
|
|
11809
|
+
y: y,
|
|
11810
|
+
z: z,
|
|
11811
|
+
lastModelMatrix: lastModelMatrix
|
|
11812
|
+
} = data;
|
|
11813
|
+
this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params), this.z = 0, context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix), context.modelMatrix = lastModelMatrix), context.highPerformanceRestore();
|
|
11814
|
+
}
|
|
11812
11815
|
}
|
|
11813
11816
|
|
|
11814
11817
|
var __decorate$1A = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
@@ -12035,7 +12038,8 @@
|
|
|
12035
12038
|
x: originX = arcAttribute.x,
|
|
12036
12039
|
y: originY = arcAttribute.y,
|
|
12037
12040
|
scaleX = arcAttribute.scaleX,
|
|
12038
|
-
scaleY = arcAttribute.scaleY
|
|
12041
|
+
scaleY = arcAttribute.scaleY,
|
|
12042
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
12039
12043
|
} = arc.attribute;
|
|
12040
12044
|
let {
|
|
12041
12045
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -12047,7 +12051,7 @@
|
|
|
12047
12051
|
{
|
|
12048
12052
|
distance = arcAttribute[key].distance
|
|
12049
12053
|
} = borderStyle,
|
|
12050
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12054
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12051
12055
|
deltaAngle = distance / outerRadius,
|
|
12052
12056
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12053
12057
|
if (arc.setAttributes({
|
|
@@ -12092,14 +12096,15 @@
|
|
|
12092
12096
|
x: originX = circleAttribute.x,
|
|
12093
12097
|
y: originY = circleAttribute.y,
|
|
12094
12098
|
scaleX = circleAttribute.scaleX,
|
|
12095
|
-
scaleY = circleAttribute.scaleY
|
|
12099
|
+
scaleY = circleAttribute.scaleY,
|
|
12100
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
12096
12101
|
} = circle.attribute,
|
|
12097
12102
|
renderBorder = (borderStyle, key) => {
|
|
12098
12103
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12099
12104
|
{
|
|
12100
12105
|
distance = circleAttribute[key].distance
|
|
12101
12106
|
} = borderStyle,
|
|
12102
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12107
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12103
12108
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12104
12109
|
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) {
|
|
12105
12110
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -12218,7 +12223,8 @@
|
|
|
12218
12223
|
scaleX = rectAttribute.scaleX,
|
|
12219
12224
|
scaleY = rectAttribute.scaleY,
|
|
12220
12225
|
x1: x1,
|
|
12221
|
-
y1: y1
|
|
12226
|
+
y1: y1,
|
|
12227
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
12222
12228
|
} = rect.attribute;
|
|
12223
12229
|
let {
|
|
12224
12230
|
width: width,
|
|
@@ -12231,7 +12237,7 @@
|
|
|
12231
12237
|
{
|
|
12232
12238
|
distance = rectAttribute[key].distance
|
|
12233
12239
|
} = borderStyle,
|
|
12234
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12240
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12235
12241
|
nextX = x + sign * d,
|
|
12236
12242
|
nextY = y + sign * d,
|
|
12237
12243
|
dw = 2 * d;
|
|
@@ -12388,14 +12394,15 @@
|
|
|
12388
12394
|
x: originX = symbolAttribute.x,
|
|
12389
12395
|
y: originY = symbolAttribute.y,
|
|
12390
12396
|
scaleX = symbolAttribute.scaleX,
|
|
12391
|
-
scaleY = symbolAttribute.scaleY
|
|
12397
|
+
scaleY = symbolAttribute.scaleY,
|
|
12398
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
12392
12399
|
} = symbol.attribute,
|
|
12393
12400
|
renderBorder = (borderStyle, key) => {
|
|
12394
12401
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12395
12402
|
{
|
|
12396
12403
|
distance = symbolAttribute[key].distance
|
|
12397
12404
|
} = borderStyle,
|
|
12398
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12405
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12399
12406
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12400
12407
|
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) {
|
|
12401
12408
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -14220,7 +14227,10 @@
|
|
|
14220
14227
|
const {
|
|
14221
14228
|
context: context
|
|
14222
14229
|
} = drawContext;
|
|
14223
|
-
|
|
14230
|
+
context.highPerformanceSave();
|
|
14231
|
+
const t1 = graphic.parent.globalTransMatrix,
|
|
14232
|
+
t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
|
|
14233
|
+
if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
14224
14234
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
14225
14235
|
const m = graphic.globalTransMatrix.getInverse();
|
|
14226
14236
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
|
|
@@ -15243,6 +15253,9 @@
|
|
|
15243
15253
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
15244
15254
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
15245
15255
|
}
|
|
15256
|
+
parseSize(size) {
|
|
15257
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15258
|
+
}
|
|
15246
15259
|
}
|
|
15247
15260
|
|
|
15248
15261
|
function circle(ctx, r, x, y, z) {
|
|
@@ -15253,13 +15266,13 @@
|
|
|
15253
15266
|
super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
|
|
15254
15267
|
}
|
|
15255
15268
|
draw(ctx, size, x, y, z) {
|
|
15256
|
-
return circle(ctx, size / 2, x, y, z);
|
|
15269
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15257
15270
|
}
|
|
15258
15271
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15259
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
15272
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
15260
15273
|
}
|
|
15261
15274
|
drawToSvgPath(size, x, y, z) {
|
|
15262
|
-
const r = size / 2;
|
|
15275
|
+
const r = this.parseSize(size) / 2;
|
|
15263
15276
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
15264
15277
|
}
|
|
15265
15278
|
}
|
|
@@ -15276,10 +15289,10 @@
|
|
|
15276
15289
|
super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
|
|
15277
15290
|
}
|
|
15278
15291
|
draw(ctx, size, x, y, z) {
|
|
15279
|
-
return cross(ctx, size / 6, x, y, z);
|
|
15292
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
15280
15293
|
}
|
|
15281
15294
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15282
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
15295
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
15283
15296
|
}
|
|
15284
15297
|
}
|
|
15285
15298
|
var cross$1 = new CrossSymbol();
|
|
@@ -15292,13 +15305,13 @@
|
|
|
15292
15305
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
15293
15306
|
}
|
|
15294
15307
|
draw(ctx, size, x, y, z) {
|
|
15295
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
15308
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15296
15309
|
}
|
|
15297
15310
|
drawFitDir(ctx, size, x, y, z) {
|
|
15298
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
15311
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15299
15312
|
}
|
|
15300
15313
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15301
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
15314
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
15302
15315
|
}
|
|
15303
15316
|
}
|
|
15304
15317
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -15312,10 +15325,10 @@
|
|
|
15312
15325
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
15313
15326
|
}
|
|
15314
15327
|
draw(ctx, size, x, y) {
|
|
15315
|
-
return square(ctx, size / 2, x, y);
|
|
15328
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
15316
15329
|
}
|
|
15317
15330
|
drawOffset(ctx, size, x, y, offset) {
|
|
15318
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
15331
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15319
15332
|
}
|
|
15320
15333
|
}
|
|
15321
15334
|
var square$1 = new SquareSymbol();
|
|
@@ -15329,10 +15342,10 @@
|
|
|
15329
15342
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
15330
15343
|
}
|
|
15331
15344
|
draw(ctx, size, x, y) {
|
|
15332
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
15345
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15333
15346
|
}
|
|
15334
15347
|
drawOffset(ctx, size, x, y, offset) {
|
|
15335
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
15348
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15336
15349
|
}
|
|
15337
15350
|
}
|
|
15338
15351
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -15364,10 +15377,10 @@
|
|
|
15364
15377
|
super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
|
|
15365
15378
|
}
|
|
15366
15379
|
draw(ctx, size, transX, transY) {
|
|
15367
|
-
return star(ctx, size / 2, transX, transY);
|
|
15380
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15368
15381
|
}
|
|
15369
15382
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15370
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
15383
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15371
15384
|
}
|
|
15372
15385
|
}
|
|
15373
15386
|
var star$1 = new StarSymbol();
|
|
@@ -15385,10 +15398,10 @@
|
|
|
15385
15398
|
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
|
|
15386
15399
|
}
|
|
15387
15400
|
draw(ctx, size, transX, transY) {
|
|
15388
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
15401
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15389
15402
|
}
|
|
15390
15403
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15391
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
15404
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15392
15405
|
}
|
|
15393
15406
|
}
|
|
15394
15407
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -15402,10 +15415,10 @@
|
|
|
15402
15415
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
15403
15416
|
}
|
|
15404
15417
|
draw(ctx, size, transX, transY) {
|
|
15405
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
15418
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15406
15419
|
}
|
|
15407
15420
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15408
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
15421
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15409
15422
|
}
|
|
15410
15423
|
}
|
|
15411
15424
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -15418,10 +15431,10 @@
|
|
|
15418
15431
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
15419
15432
|
}
|
|
15420
15433
|
draw(ctx, size, transX, transY) {
|
|
15421
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
15434
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15422
15435
|
}
|
|
15423
15436
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15424
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
15437
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15425
15438
|
}
|
|
15426
15439
|
}
|
|
15427
15440
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -15443,10 +15456,10 @@
|
|
|
15443
15456
|
super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
|
|
15444
15457
|
}
|
|
15445
15458
|
draw(ctx, size, transX, transY) {
|
|
15446
|
-
return wye(ctx, size / 2, transX, transY);
|
|
15459
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15447
15460
|
}
|
|
15448
15461
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15449
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
15462
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15450
15463
|
}
|
|
15451
15464
|
}
|
|
15452
15465
|
var wye$1 = new WyeSymbol();
|
|
@@ -15459,10 +15472,10 @@
|
|
|
15459
15472
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
15460
15473
|
}
|
|
15461
15474
|
draw(ctx, size, x, y) {
|
|
15462
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
15475
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
15463
15476
|
}
|
|
15464
15477
|
drawOffset(ctx, size, x, y, offset) {
|
|
15465
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
15478
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15466
15479
|
}
|
|
15467
15480
|
}
|
|
15468
15481
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -15476,10 +15489,10 @@
|
|
|
15476
15489
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
15477
15490
|
}
|
|
15478
15491
|
draw(ctx, size, x, y) {
|
|
15479
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
15492
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15480
15493
|
}
|
|
15481
15494
|
drawOffset(ctx, size, x, y, offset) {
|
|
15482
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
15495
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15483
15496
|
}
|
|
15484
15497
|
}
|
|
15485
15498
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -15493,10 +15506,10 @@
|
|
|
15493
15506
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
15494
15507
|
}
|
|
15495
15508
|
draw(ctx, size, x, y) {
|
|
15496
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
15509
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15497
15510
|
}
|
|
15498
15511
|
drawOffset(ctx, size, x, y, offset) {
|
|
15499
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
15512
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15500
15513
|
}
|
|
15501
15514
|
}
|
|
15502
15515
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -15511,10 +15524,10 @@
|
|
|
15511
15524
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
15512
15525
|
}
|
|
15513
15526
|
draw(ctx, size, x, y) {
|
|
15514
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
15527
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
15515
15528
|
}
|
|
15516
15529
|
drawOffset(ctx, size, x, y, offset) {
|
|
15517
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
15530
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
15518
15531
|
}
|
|
15519
15532
|
}
|
|
15520
15533
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -15528,10 +15541,10 @@
|
|
|
15528
15541
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
15529
15542
|
}
|
|
15530
15543
|
draw(ctx, size, transX, transY) {
|
|
15531
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
15544
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15532
15545
|
}
|
|
15533
15546
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15534
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
15547
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15535
15548
|
}
|
|
15536
15549
|
}
|
|
15537
15550
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -15545,10 +15558,10 @@
|
|
|
15545
15558
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
15546
15559
|
}
|
|
15547
15560
|
draw(ctx, size, transX, transY) {
|
|
15548
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
15561
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15549
15562
|
}
|
|
15550
15563
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15551
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
15564
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15552
15565
|
}
|
|
15553
15566
|
}
|
|
15554
15567
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -15562,10 +15575,10 @@
|
|
|
15562
15575
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
15563
15576
|
}
|
|
15564
15577
|
draw(ctx, size, transX, transY) {
|
|
15565
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
15578
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15566
15579
|
}
|
|
15567
15580
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15568
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
15581
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15569
15582
|
}
|
|
15570
15583
|
}
|
|
15571
15584
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -15579,10 +15592,10 @@
|
|
|
15579
15592
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
15580
15593
|
}
|
|
15581
15594
|
draw(ctx, size, transX, transY) {
|
|
15582
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
15595
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15583
15596
|
}
|
|
15584
15597
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15585
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
15598
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15586
15599
|
}
|
|
15587
15600
|
}
|
|
15588
15601
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -15595,13 +15608,13 @@
|
|
|
15595
15608
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
15596
15609
|
}
|
|
15597
15610
|
draw(ctx, size, x, y, z) {
|
|
15598
|
-
return lineV(ctx, size / 2, x, y);
|
|
15611
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
15599
15612
|
}
|
|
15600
15613
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15601
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
15614
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15602
15615
|
}
|
|
15603
15616
|
drawToSvgPath(size, x, y, z) {
|
|
15604
|
-
const r = size / 2;
|
|
15617
|
+
const r = this.parseSize(size) / 2;
|
|
15605
15618
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
15606
15619
|
}
|
|
15607
15620
|
}
|
|
@@ -15615,13 +15628,13 @@
|
|
|
15615
15628
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
15616
15629
|
}
|
|
15617
15630
|
draw(ctx, size, x, y, z) {
|
|
15618
|
-
return lineH(ctx, size / 2, x, y);
|
|
15631
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
15619
15632
|
}
|
|
15620
15633
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15621
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
15634
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15622
15635
|
}
|
|
15623
15636
|
drawToSvgPath(size, x, y, z) {
|
|
15624
|
-
const r = size / 2;
|
|
15637
|
+
const r = this.parseSize(size) / 2;
|
|
15625
15638
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
15626
15639
|
}
|
|
15627
15640
|
}
|
|
@@ -15635,13 +15648,13 @@
|
|
|
15635
15648
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
15636
15649
|
}
|
|
15637
15650
|
draw(ctx, size, x, y, z) {
|
|
15638
|
-
return close(ctx, size / 2, x, y);
|
|
15651
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
15639
15652
|
}
|
|
15640
15653
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15641
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
15654
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15642
15655
|
}
|
|
15643
15656
|
drawToSvgPath(size, x, y, z) {
|
|
15644
|
-
const r = size / 2;
|
|
15657
|
+
const r = this.parseSize(size) / 2;
|
|
15645
15658
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
15646
15659
|
}
|
|
15647
15660
|
}
|
|
@@ -15675,15 +15688,18 @@
|
|
|
15675
15688
|
this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
15676
15689
|
}
|
|
15677
15690
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
15678
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
15691
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
15679
15692
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
15680
15693
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
15681
15694
|
}
|
|
15682
15695
|
draw(ctx, size, x, y, z, cb) {
|
|
15683
|
-
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
15696
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
15697
|
+
}
|
|
15698
|
+
parseSize(size) {
|
|
15699
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15684
15700
|
}
|
|
15685
15701
|
bounds(size, bounds) {
|
|
15686
|
-
if (this.isSvg) {
|
|
15702
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
15687
15703
|
if (!this.svgCache) return;
|
|
15688
15704
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
15689
15705
|
let {
|
|
@@ -16366,7 +16382,11 @@
|
|
|
16366
16382
|
case "sub":
|
|
16367
16383
|
baseline += this.descent / 2;
|
|
16368
16384
|
}
|
|
16369
|
-
"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)
|
|
16385
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
16386
|
+
const {
|
|
16387
|
+
lineWidth = 1
|
|
16388
|
+
} = this.character;
|
|
16389
|
+
this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
16370
16390
|
}
|
|
16371
16391
|
getWidthWithEllips(direction) {
|
|
16372
16392
|
let text = this.text;
|
|
@@ -16589,12 +16609,18 @@
|
|
|
16589
16609
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
16590
16610
|
}
|
|
16591
16611
|
}
|
|
16592
|
-
this.paragraphs.
|
|
16612
|
+
this.paragraphs.forEach((paragraph, index) => {
|
|
16593
16613
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
16594
16614
|
x: x + paragraph._x,
|
|
16595
16615
|
y: y + paragraph._y
|
|
16596
16616
|
}), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
|
|
16597
|
-
|
|
16617
|
+
const b = {
|
|
16618
|
+
x1: this.left,
|
|
16619
|
+
y1: this.top,
|
|
16620
|
+
x2: this.left + this.actualWidth,
|
|
16621
|
+
y2: this.top + this.height
|
|
16622
|
+
};
|
|
16623
|
+
applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
|
|
16598
16624
|
});
|
|
16599
16625
|
}
|
|
16600
16626
|
getWidthWithEllips(ellipsis) {
|
|
@@ -16617,7 +16643,7 @@
|
|
|
16617
16643
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
16618
16644
|
}
|
|
16619
16645
|
let width = 0;
|
|
16620
|
-
return this.paragraphs.
|
|
16646
|
+
return this.paragraphs.forEach((paragraph, index) => {
|
|
16621
16647
|
width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
|
|
16622
16648
|
}), width;
|
|
16623
16649
|
}
|
|
@@ -23923,7 +23949,7 @@
|
|
|
23923
23949
|
startTime: startTime,
|
|
23924
23950
|
startPoints: startPoints
|
|
23925
23951
|
} = this;
|
|
23926
|
-
if (eventType) return eventType;
|
|
23952
|
+
if ("press" === eventType) return eventType;
|
|
23927
23953
|
let type;
|
|
23928
23954
|
return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
|
|
23929
23955
|
}
|
|
@@ -24455,9 +24481,10 @@
|
|
|
24455
24481
|
lineJoin = defaultParams.lineJoin,
|
|
24456
24482
|
lineDash = defaultParams.lineDash,
|
|
24457
24483
|
lineCap = defaultParams.lineCap,
|
|
24458
|
-
miterLimit = defaultParams.miterLimit
|
|
24484
|
+
miterLimit = defaultParams.miterLimit,
|
|
24485
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
24459
24486
|
} = attribute;
|
|
24460
|
-
_context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24487
|
+
_context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24461
24488
|
}
|
|
24462
24489
|
}
|
|
24463
24490
|
setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
|
|
@@ -25357,8 +25384,9 @@
|
|
|
25357
25384
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
25358
25385
|
if (picked) return !0;
|
|
25359
25386
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25360
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25361
|
-
|
|
25387
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
25388
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
25389
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25362
25390
|
}), pickContext.highPerformanceRestore(), picked;
|
|
25363
25391
|
}
|
|
25364
25392
|
}
|
|
@@ -25631,8 +25659,9 @@
|
|
|
25631
25659
|
if (!onlyTranslate || rect.shadowRoot || isNumber$1(cornerRadius, !0) && 0 !== cornerRadius || isArray$1(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) => {
|
|
25632
25660
|
if (picked) return !0;
|
|
25633
25661
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25634
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25635
|
-
|
|
25662
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
25663
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
25664
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25636
25665
|
});else {
|
|
25637
25666
|
const {
|
|
25638
25667
|
fill = rectAttribute.fill,
|
|
@@ -25946,9 +25975,10 @@
|
|
|
25946
25975
|
lineJoin = defaultParams.lineJoin,
|
|
25947
25976
|
lineDash = defaultParams.lineDash,
|
|
25948
25977
|
lineCap = defaultParams.lineCap,
|
|
25949
|
-
miterLimit = defaultParams.miterLimit
|
|
25978
|
+
miterLimit = defaultParams.miterLimit,
|
|
25979
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
25950
25980
|
} = attribute;
|
|
25951
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
25981
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
25952
25982
|
}
|
|
25953
25983
|
}
|
|
25954
25984
|
measureText(text) {
|
|
@@ -26576,9 +26606,10 @@
|
|
|
26576
26606
|
lineJoin = defaultParams.lineJoin,
|
|
26577
26607
|
lineDash = defaultParams.lineDash,
|
|
26578
26608
|
lineCap = defaultParams.lineCap,
|
|
26579
|
-
miterLimit = defaultParams.miterLimit
|
|
26609
|
+
miterLimit = defaultParams.miterLimit,
|
|
26610
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
26580
26611
|
} = attribute;
|
|
26581
|
-
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
26612
|
+
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
26582
26613
|
}
|
|
26583
26614
|
}
|
|
26584
26615
|
setTextStyleWithoutAlignBaseline(params, defaultParams) {
|
|
@@ -27618,9 +27649,10 @@
|
|
|
27618
27649
|
lineJoin = defaultParams.lineJoin,
|
|
27619
27650
|
lineDash = defaultParams.lineDash,
|
|
27620
27651
|
lineCap = defaultParams.lineCap,
|
|
27621
|
-
miterLimit = defaultParams.miterLimit
|
|
27652
|
+
miterLimit = defaultParams.miterLimit,
|
|
27653
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
27622
27654
|
} = attribute;
|
|
27623
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
27655
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
27624
27656
|
}
|
|
27625
27657
|
}
|
|
27626
27658
|
measureText(text) {
|
|
@@ -28027,8 +28059,9 @@
|
|
|
28027
28059
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
28028
28060
|
if (picked) return !0;
|
|
28029
28061
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28030
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28031
|
-
|
|
28062
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28063
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28064
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28032
28065
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28033
28066
|
}
|
|
28034
28067
|
}
|
|
@@ -28163,8 +28196,9 @@
|
|
|
28163
28196
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
28164
28197
|
if (picked) return !0;
|
|
28165
28198
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28166
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28167
|
-
|
|
28199
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28200
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28201
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28168
28202
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28169
28203
|
}
|
|
28170
28204
|
};
|
|
@@ -28601,7 +28635,7 @@
|
|
|
28601
28635
|
|
|
28602
28636
|
const roughModule = _roughModule;
|
|
28603
28637
|
|
|
28604
|
-
const version = "0.20.
|
|
28638
|
+
const version = "0.20.16";
|
|
28605
28639
|
preLoadAllModule();
|
|
28606
28640
|
if (isBrowserEnv()) {
|
|
28607
28641
|
loadBrowserEnv(container);
|