@antv/g-svg 1.6.0-alpha.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ContextRegisterPlugin.d.ts +4 -4
- package/dist/ContextRegisterPlugin.d.ts.map +1 -1
- package/dist/index.esm.js +18 -8
- package/dist/index.js +17 -7
- package/dist/index.umd.js +1253 -1097
- package/dist/index.umd.min.js +4 -4
- package/package.json +5 -5
package/dist/index.umd.js
CHANGED
|
@@ -812,6 +812,21 @@
|
|
|
812
812
|
};
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
+
function _inheritsLoose$1(subClass, superClass) {
|
|
816
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
817
|
+
subClass.prototype.constructor = subClass;
|
|
818
|
+
|
|
819
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function _setPrototypeOf$1(o, p) {
|
|
823
|
+
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
824
|
+
o.__proto__ = p;
|
|
825
|
+
return o;
|
|
826
|
+
};
|
|
827
|
+
return _setPrototypeOf$1(o, p);
|
|
828
|
+
}
|
|
829
|
+
|
|
815
830
|
var _class;
|
|
816
831
|
|
|
817
832
|
var DOMInteractionPlugin_1;
|
|
@@ -871,7 +886,7 @@
|
|
|
871
886
|
var addTouchEventListener = function addTouchEventListener($el) {
|
|
872
887
|
$el.addEventListener('touchstart', onPointerDown, true);
|
|
873
888
|
$el.addEventListener('touchend', onPointerUp, true);
|
|
874
|
-
|
|
889
|
+
$el.addEventListener('touchmove', onPointerMove, true);
|
|
875
890
|
$el.addEventListener('touchcancel', onPointerCancel, true);
|
|
876
891
|
};
|
|
877
892
|
|
|
@@ -894,8 +909,8 @@
|
|
|
894
909
|
var removeTouchEventListener = function removeTouchEventListener($el) {
|
|
895
910
|
$el.removeEventListener('touchstart', onPointerDown, true);
|
|
896
911
|
$el.removeEventListener('touchend', onPointerUp, true);
|
|
912
|
+
$el.removeEventListener('touchmove', onPointerMove, true);
|
|
897
913
|
$el.removeEventListener('touchcancel', onPointerCancel, true);
|
|
898
|
-
globalThis.document.removeEventListener('touchmove', onPointerMove, true);
|
|
899
914
|
};
|
|
900
915
|
|
|
901
916
|
var removeMouseEventListener = function removeMouseEventListener($el) {
|
|
@@ -978,23 +993,33 @@
|
|
|
978
993
|
register(DOMInteractionPlugin);
|
|
979
994
|
});
|
|
980
995
|
|
|
981
|
-
var Plugin = /*#__PURE__*/function () {
|
|
996
|
+
var Plugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
997
|
+
_inheritsLoose$1(Plugin, _AbstractRendererPlug);
|
|
998
|
+
|
|
982
999
|
function Plugin() {
|
|
983
|
-
|
|
1000
|
+
var _this;
|
|
1001
|
+
|
|
1002
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1003
|
+
args[_key] = arguments[_key];
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
1007
|
+
_this.name = 'dom-interaction';
|
|
1008
|
+
return _this;
|
|
984
1009
|
}
|
|
985
1010
|
|
|
986
1011
|
var _proto = Plugin.prototype;
|
|
987
1012
|
|
|
988
|
-
_proto.init = function init(
|
|
989
|
-
container.load(containerModule, true);
|
|
1013
|
+
_proto.init = function init() {
|
|
1014
|
+
this.container.load(containerModule, true);
|
|
990
1015
|
};
|
|
991
1016
|
|
|
992
|
-
_proto.destroy = function destroy(
|
|
993
|
-
container.unload(containerModule);
|
|
1017
|
+
_proto.destroy = function destroy() {
|
|
1018
|
+
this.container.unload(containerModule);
|
|
994
1019
|
};
|
|
995
1020
|
|
|
996
1021
|
return Plugin;
|
|
997
|
-
}();
|
|
1022
|
+
}(g.AbstractRendererPlugin);
|
|
998
1023
|
|
|
999
1024
|
var index_esm = /*#__PURE__*/Object.freeze({
|
|
1000
1025
|
__proto__: null,
|
|
@@ -1207,1317 +1232,1403 @@
|
|
|
1207
1232
|
return output;
|
|
1208
1233
|
}
|
|
1209
1234
|
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1235
|
+
function _regeneratorRuntime$2() {
|
|
1236
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
1237
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
1238
|
+
return exports;
|
|
1239
|
+
};
|
|
1215
1240
|
|
|
1216
|
-
|
|
1241
|
+
var exports = {},
|
|
1242
|
+
Op = Object.prototype,
|
|
1243
|
+
hasOwn = Op.hasOwnProperty,
|
|
1244
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1245
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1246
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1247
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1217
1248
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1249
|
+
function define(obj, key, value) {
|
|
1250
|
+
return Object.defineProperty(obj, key, {
|
|
1251
|
+
value: value,
|
|
1252
|
+
enumerable: !0,
|
|
1253
|
+
configurable: !0,
|
|
1254
|
+
writable: !0
|
|
1255
|
+
}), obj[key];
|
|
1256
|
+
}
|
|
1225
1257
|
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1258
|
+
try {
|
|
1259
|
+
define({}, "");
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
define = function define(obj, key, value) {
|
|
1262
|
+
return obj[key] = value;
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1233
1265
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1266
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1267
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
1268
|
+
generator = Object.create(protoGenerator.prototype),
|
|
1269
|
+
context = new Context(tryLocsList || []);
|
|
1270
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
1271
|
+
var state = "suspendedStart";
|
|
1272
|
+
return function (method, arg) {
|
|
1273
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
1237
1274
|
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
} else if (img instanceof ImageData) {
|
|
1243
|
-
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1275
|
+
if ("completed" === state) {
|
|
1276
|
+
if ("throw" === method) throw arg;
|
|
1277
|
+
return doneResult();
|
|
1278
|
+
}
|
|
1244
1279
|
|
|
1245
|
-
|
|
1280
|
+
for (context.method = method, context.arg = arg;;) {
|
|
1281
|
+
var delegate = context.delegate;
|
|
1246
1282
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1283
|
+
if (delegate) {
|
|
1284
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1249
1285
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1286
|
+
if (delegateResult) {
|
|
1287
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1288
|
+
return delegateResult;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1252
1291
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1292
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
1293
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
1294
|
+
context.dispatchException(context.arg);
|
|
1295
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1296
|
+
state = "executing";
|
|
1297
|
+
var record = tryCatch(innerFn, self, context);
|
|
1257
1298
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1299
|
+
if ("normal" === record.type) {
|
|
1300
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
1301
|
+
return {
|
|
1302
|
+
value: record.arg,
|
|
1303
|
+
done: context.done
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1262
1306
|
|
|
1263
|
-
|
|
1307
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
}(innerFn, self, context), generator;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function tryCatch(fn, obj, arg) {
|
|
1314
|
+
try {
|
|
1315
|
+
return {
|
|
1316
|
+
type: "normal",
|
|
1317
|
+
arg: fn.call(obj, arg)
|
|
1318
|
+
};
|
|
1319
|
+
} catch (err) {
|
|
1320
|
+
return {
|
|
1321
|
+
type: "throw",
|
|
1322
|
+
arg: err
|
|
1323
|
+
};
|
|
1264
1324
|
}
|
|
1265
1325
|
}
|
|
1266
|
-
}
|
|
1267
1326
|
|
|
1268
|
-
|
|
1269
|
-
var
|
|
1270
|
-
y1 = parsedStyle.y1,
|
|
1271
|
-
x2 = parsedStyle.x2,
|
|
1272
|
-
y2 = parsedStyle.y2,
|
|
1273
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1274
|
-
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1275
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1276
|
-
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY; // @see https://github.com/antvis/g/issues/1038
|
|
1327
|
+
exports.wrap = wrap;
|
|
1328
|
+
var ContinueSentinel = {};
|
|
1277
1329
|
|
|
1278
|
-
|
|
1279
|
-
$el.setAttribute('y1', "" + (y1.value - defY));
|
|
1280
|
-
$el.setAttribute('x2', "" + (x2.value - defX));
|
|
1281
|
-
$el.setAttribute('y2', "" + (y2.value - defY));
|
|
1282
|
-
}
|
|
1330
|
+
function Generator() {}
|
|
1283
1331
|
|
|
1284
|
-
|
|
1285
|
-
var path = parsedStyle.path,
|
|
1286
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1287
|
-
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1288
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1289
|
-
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1290
|
-
$el.setAttribute('d', g.translatePathToString(path.absolutePath, defX, defY));
|
|
1291
|
-
}
|
|
1332
|
+
function GeneratorFunction() {}
|
|
1292
1333
|
|
|
1293
|
-
|
|
1294
|
-
var points = parsedStyle.points,
|
|
1295
|
-
_parsedStyle$defX = parsedStyle.defX,
|
|
1296
|
-
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1297
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
1298
|
-
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1334
|
+
function GeneratorFunctionPrototype() {}
|
|
1299
1335
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1336
|
+
var IteratorPrototype = {};
|
|
1337
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1338
|
+
return this;
|
|
1339
|
+
});
|
|
1340
|
+
var getProto = Object.getPrototypeOf,
|
|
1341
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1342
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1343
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1344
|
+
|
|
1345
|
+
function defineIteratorMethods(prototype) {
|
|
1346
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1347
|
+
define(prototype, method, function (arg) {
|
|
1348
|
+
return this._invoke(method, arg);
|
|
1349
|
+
});
|
|
1350
|
+
});
|
|
1304
1351
|
}
|
|
1305
|
-
}
|
|
1306
1352
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
height = parsedStyle.height; // CSSKeyword: auto
|
|
1353
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1354
|
+
function invoke(method, arg, resolve, reject) {
|
|
1355
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1311
1356
|
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1357
|
+
if ("throw" !== record.type) {
|
|
1358
|
+
var result = record.arg,
|
|
1359
|
+
value = result.value;
|
|
1360
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1361
|
+
invoke("next", value, resolve, reject);
|
|
1362
|
+
}, function (err) {
|
|
1363
|
+
invoke("throw", err, resolve, reject);
|
|
1364
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1365
|
+
result.value = unwrapped, resolve(result);
|
|
1366
|
+
}, function (error) {
|
|
1367
|
+
return invoke("throw", error, resolve, reject);
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1315
1370
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
});
|
|
1319
|
-
var d = '';
|
|
1371
|
+
reject(record.arg);
|
|
1372
|
+
}
|
|
1320
1373
|
|
|
1321
|
-
|
|
1322
|
-
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
1323
|
-
} else {
|
|
1324
|
-
var _radius$map = radius.map(function (r) {
|
|
1325
|
-
return g.clamp(r.value, 0, Math.min(Math.abs(width.value) / 2, Math.abs(height.value) / 2));
|
|
1326
|
-
}),
|
|
1327
|
-
tlr = _radius$map[0],
|
|
1328
|
-
trr = _radius$map[1],
|
|
1329
|
-
brr = _radius$map[2],
|
|
1330
|
-
blr = _radius$map[3];
|
|
1374
|
+
var previousPromise;
|
|
1331
1375
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1376
|
+
this._invoke = function (method, arg) {
|
|
1377
|
+
function callInvokeWithMethodAndArg() {
|
|
1378
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1379
|
+
invoke(method, arg, resolve, reject);
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1334
1382
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1383
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1384
|
+
};
|
|
1337
1385
|
}
|
|
1338
1386
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
function numberToLongString(x) {
|
|
1343
|
-
return x.toFixed(6).replace('.000000', '');
|
|
1344
|
-
}
|
|
1387
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1388
|
+
var method = delegate.iterator[context.method];
|
|
1345
1389
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
return
|
|
1353
|
-
} else if (match === '>') {
|
|
1354
|
-
return '>';
|
|
1355
|
-
} else if (match === '"') {
|
|
1356
|
-
return '"';
|
|
1357
|
-
} else {
|
|
1358
|
-
return ''';
|
|
1390
|
+
if (undefined === method) {
|
|
1391
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
1392
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1393
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
return ContinueSentinel;
|
|
1359
1397
|
}
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
1398
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
ideographic: 'ideographic',
|
|
1369
|
-
hanging: 'hanging'
|
|
1370
|
-
}; // for FireFox
|
|
1371
|
-
// @see https://github.com/plouc/nivo/issues/164
|
|
1399
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1400
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1401
|
+
var info = record.arg;
|
|
1402
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
1403
|
+
}
|
|
1372
1404
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
hanging: 'hanging'
|
|
1380
|
-
};
|
|
1405
|
+
function pushTryEntry(locs) {
|
|
1406
|
+
var entry = {
|
|
1407
|
+
tryLoc: locs[0]
|
|
1408
|
+
};
|
|
1409
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1410
|
+
}
|
|
1381
1411
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
dx = parsedStyle.dx,
|
|
1387
|
-
dy = parsedStyle.dy;
|
|
1388
|
-
var browser = detect();
|
|
1412
|
+
function resetTryEntry(entry) {
|
|
1413
|
+
var record = entry.completion || {};
|
|
1414
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
1415
|
+
}
|
|
1389
1416
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1395
|
-
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1417
|
+
function Context(tryLocsList) {
|
|
1418
|
+
this.tryEntries = [{
|
|
1419
|
+
tryLoc: "root"
|
|
1420
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1396
1421
|
}
|
|
1397
1422
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1423
|
+
function values(iterable) {
|
|
1424
|
+
if (iterable) {
|
|
1425
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1426
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
1427
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
1404
1428
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
var dy = 0;
|
|
1429
|
+
if (!isNaN(iterable.length)) {
|
|
1430
|
+
var i = -1,
|
|
1431
|
+
next = function next() {
|
|
1432
|
+
for (; ++i < iterable.length;) {
|
|
1433
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1434
|
+
}
|
|
1412
1435
|
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1418
|
-
dy = 0;
|
|
1419
|
-
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1420
|
-
dy = -lineHeight * (lineNum - 1);
|
|
1421
|
-
}
|
|
1422
|
-
} else {
|
|
1423
|
-
dy = lineHeight;
|
|
1436
|
+
return next.value = undefined, next.done = !0, next;
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
return next.next = next;
|
|
1424
1440
|
}
|
|
1441
|
+
}
|
|
1425
1442
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1443
|
+
return {
|
|
1444
|
+
next: doneResult
|
|
1445
|
+
};
|
|
1428
1446
|
}
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
var CreateElementContribution = g.Syringe.defineToken('CreateElementContribution', {
|
|
1432
|
-
multiple: false
|
|
1433
|
-
});
|
|
1434
|
-
|
|
1435
|
-
function createSVGElement(type, doc) {
|
|
1436
|
-
return (doc || document).createElementNS('http://www.w3.org/2000/svg', type);
|
|
1437
|
-
}
|
|
1438
1447
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
var DefaultCreateElementContribution = /*#__PURE__*/function () {
|
|
1445
|
-
function DefaultCreateElementContribution() {
|
|
1446
|
-
this.canvasConfig = void 0;
|
|
1448
|
+
function doneResult() {
|
|
1449
|
+
return {
|
|
1450
|
+
value: undefined,
|
|
1451
|
+
done: !0
|
|
1452
|
+
};
|
|
1447
1453
|
}
|
|
1448
1454
|
|
|
1449
|
-
|
|
1455
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
1456
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
1457
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
1458
|
+
}, exports.mark = function (genFun) {
|
|
1459
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1460
|
+
}, exports.awrap = function (arg) {
|
|
1461
|
+
return {
|
|
1462
|
+
__await: arg
|
|
1463
|
+
};
|
|
1464
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1465
|
+
return this;
|
|
1466
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1467
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1468
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1469
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1470
|
+
return result.done ? result.value : iter.next();
|
|
1471
|
+
});
|
|
1472
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1473
|
+
return this;
|
|
1474
|
+
}), define(Gp, "toString", function () {
|
|
1475
|
+
return "[object Generator]";
|
|
1476
|
+
}), exports.keys = function (object) {
|
|
1477
|
+
var keys = [];
|
|
1450
1478
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
return createSVGElement(type, doc || document);
|
|
1455
|
-
};
|
|
1479
|
+
for (var key in object) {
|
|
1480
|
+
keys.push(key);
|
|
1481
|
+
}
|
|
1456
1482
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1483
|
+
return keys.reverse(), function next() {
|
|
1484
|
+
for (; keys.length;) {
|
|
1485
|
+
var key = keys.pop();
|
|
1486
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
1487
|
+
}
|
|
1461
1488
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1489
|
+
return next.done = !0, next;
|
|
1490
|
+
};
|
|
1491
|
+
}, exports.values = values, Context.prototype = {
|
|
1492
|
+
constructor: Context,
|
|
1493
|
+
reset: function reset(skipTempReset) {
|
|
1494
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
1495
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1496
|
+
}
|
|
1497
|
+
},
|
|
1498
|
+
stop: function stop() {
|
|
1499
|
+
this.done = !0;
|
|
1500
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
1501
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1502
|
+
return this.rval;
|
|
1503
|
+
},
|
|
1504
|
+
dispatchException: function dispatchException(exception) {
|
|
1505
|
+
if (this.done) throw exception;
|
|
1506
|
+
var context = this;
|
|
1467
1507
|
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
updateImageElementAttribute($el, parsedStyle);
|
|
1472
|
-
break;
|
|
1473
|
-
}
|
|
1508
|
+
function handle(loc, caught) {
|
|
1509
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1510
|
+
}
|
|
1474
1511
|
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1512
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1513
|
+
var entry = this.tryEntries[i],
|
|
1514
|
+
record = entry.completion;
|
|
1515
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
1480
1516
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
break;
|
|
1485
|
-
}
|
|
1517
|
+
if (entry.tryLoc <= this.prev) {
|
|
1518
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
1519
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1486
1520
|
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1521
|
+
if (hasCatch && hasFinally) {
|
|
1522
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1523
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1524
|
+
} else if (hasCatch) {
|
|
1525
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1526
|
+
} else {
|
|
1527
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1528
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1529
|
+
}
|
|
1492
1530
|
}
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
abrupt: function abrupt(type, arg) {
|
|
1534
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1535
|
+
var entry = this.tryEntries[i];
|
|
1493
1536
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
updatePathElementAttribute($el, parsedStyle);
|
|
1537
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1538
|
+
var finallyEntry = entry;
|
|
1497
1539
|
break;
|
|
1498
1540
|
}
|
|
1541
|
+
}
|
|
1499
1542
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1543
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
1544
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1545
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
1546
|
+
},
|
|
1547
|
+
complete: function complete(record, afterLoc) {
|
|
1548
|
+
if ("throw" === record.type) throw record.arg;
|
|
1549
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
1550
|
+
},
|
|
1551
|
+
finish: function finish(finallyLoc) {
|
|
1552
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1553
|
+
var entry = this.tryEntries[i];
|
|
1554
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
catch: function _catch(tryLoc) {
|
|
1558
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1559
|
+
var entry = this.tryEntries[i];
|
|
1507
1560
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1561
|
+
if (entry.tryLoc === tryLoc) {
|
|
1562
|
+
var record = entry.completion;
|
|
1510
1563
|
|
|
1511
|
-
|
|
1564
|
+
if ("throw" === record.type) {
|
|
1565
|
+
var thrown = record.arg;
|
|
1566
|
+
resetTryEntry(entry);
|
|
1567
|
+
}
|
|
1512
1568
|
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
var FILTER_PREFIX = 'g-filter-';
|
|
1517
|
-
/**
|
|
1518
|
-
* use SVG filters, eg. blur, brightness, contrast...
|
|
1519
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
1520
|
-
*/
|
|
1569
|
+
return thrown;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1521
1572
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1573
|
+
throw new Error("illegal catch attempt");
|
|
1574
|
+
},
|
|
1575
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1576
|
+
return this.delegate = {
|
|
1577
|
+
iterator: values(iterable),
|
|
1578
|
+
resultName: resultName,
|
|
1579
|
+
nextLoc: nextLoc
|
|
1580
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1581
|
+
}
|
|
1582
|
+
}, exports;
|
|
1583
|
+
}
|
|
1526
1584
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1585
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1586
|
+
try {
|
|
1587
|
+
var info = gen[key](arg);
|
|
1588
|
+
var value = info.value;
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
reject(error);
|
|
1591
|
+
return;
|
|
1531
1592
|
}
|
|
1532
1593
|
|
|
1533
|
-
if (
|
|
1534
|
-
|
|
1535
|
-
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
1594
|
+
if (info.done) {
|
|
1595
|
+
resolve(value);
|
|
1536
1596
|
} else {
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
var $filter = createSVGElement('filter', document); // @see https://github.com/antvis/g/issues/1025
|
|
1597
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1541
1600
|
|
|
1542
|
-
|
|
1601
|
+
function _asyncToGenerator$2(fn) {
|
|
1602
|
+
return function () {
|
|
1603
|
+
var self = this,
|
|
1604
|
+
args = arguments;
|
|
1605
|
+
return new Promise(function (resolve, reject) {
|
|
1606
|
+
var gen = fn.apply(self, args);
|
|
1543
1607
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
} else if (name === 'contrast') {
|
|
1551
|
-
createContrast(document, $filter, params);
|
|
1552
|
-
} else if (name === 'grayscale') {
|
|
1553
|
-
createGrayscale(document, $filter, params);
|
|
1554
|
-
} else if (name === 'sepia') {
|
|
1555
|
-
createSepia(document, $filter, params);
|
|
1556
|
-
} else if (name === 'saturate') {
|
|
1557
|
-
createSaturate(document, $filter, params);
|
|
1558
|
-
} else if (name === 'hue-rotate') {
|
|
1559
|
-
createHueRotate(document, $filter, params);
|
|
1560
|
-
} else if (name === 'invert') {
|
|
1561
|
-
createInvert(document, $filter, params);
|
|
1608
|
+
function _next(value) {
|
|
1609
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
function _throw(err) {
|
|
1613
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1562
1614
|
}
|
|
1563
1615
|
|
|
1564
|
-
|
|
1565
|
-
$filter.setAttribute('name', filterName);
|
|
1566
|
-
$def.appendChild($filter);
|
|
1567
|
-
return $filter.id;
|
|
1616
|
+
_next(undefined);
|
|
1568
1617
|
});
|
|
1569
|
-
|
|
1570
|
-
return "url(#" + filterId + ")";
|
|
1571
|
-
}).join(' '));
|
|
1572
|
-
}
|
|
1618
|
+
};
|
|
1573
1619
|
}
|
|
1574
1620
|
|
|
1575
|
-
function
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
* @see https://drafts.fxtf.org/filter-effects/#blurEquivalent
|
|
1580
|
-
*/
|
|
1621
|
+
function _inheritsLoose$2(subClass, superClass) {
|
|
1622
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
1623
|
+
subClass.prototype.constructor = subClass;
|
|
1581
1624
|
|
|
1625
|
+
_setPrototypeOf$2(subClass, superClass);
|
|
1626
|
+
}
|
|
1582
1627
|
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1628
|
+
function _setPrototypeOf$2(o, p) {
|
|
1629
|
+
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
1630
|
+
o.__proto__ = p;
|
|
1631
|
+
return o;
|
|
1632
|
+
};
|
|
1633
|
+
return _setPrototypeOf$2(o, p);
|
|
1588
1634
|
}
|
|
1589
1635
|
|
|
1590
|
-
function
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
1596
|
-
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
1597
|
-
$feFunc.setAttribute('type', type);
|
|
1636
|
+
var ElementSVG = function ElementSVG() {
|
|
1637
|
+
this.$el = void 0;
|
|
1638
|
+
this.$groupEl = void 0;
|
|
1639
|
+
this.$hitTestingEl = void 0;
|
|
1640
|
+
};
|
|
1598
1641
|
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
$
|
|
1642
|
+
ElementSVG.tag = 'c-svg-element';
|
|
1643
|
+
|
|
1644
|
+
function updateImageElementAttribute($el, parsedStyle) {
|
|
1645
|
+
var _parsedStyle$img = parsedStyle.img,
|
|
1646
|
+
img = _parsedStyle$img === void 0 ? '' : _parsedStyle$img,
|
|
1647
|
+
width = parsedStyle.width,
|
|
1648
|
+
height = parsedStyle.height;
|
|
1649
|
+
$el.setAttribute('x', '0');
|
|
1650
|
+
$el.setAttribute('y', '0');
|
|
1651
|
+
|
|
1652
|
+
if (g.isString(img)) {
|
|
1653
|
+
$el.setAttribute('href', img);
|
|
1654
|
+
} else if (img instanceof Image) {
|
|
1655
|
+
if (!width) {
|
|
1656
|
+
$el.setAttribute('width', "" + img.width); // TODO: set renderable.boundsDirty
|
|
1657
|
+
// this.attr('width', img.width);
|
|
1604
1658
|
}
|
|
1605
1659
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1660
|
+
if (!height) {
|
|
1661
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1662
|
+
}
|
|
1610
1663
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
});
|
|
1618
|
-
}
|
|
1664
|
+
$el.setAttribute('href', img.src);
|
|
1665
|
+
} else if ( // @ts-ignore
|
|
1666
|
+
img instanceof HTMLElement && g.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
|
|
1667
|
+
$el.setAttribute('href', img.toDataURL()); // @ts-ignore
|
|
1668
|
+
} else if (img instanceof ImageData) {
|
|
1669
|
+
var canvas = document.createElement('canvas'); // @ts-ignore
|
|
1619
1670
|
|
|
1620
|
-
|
|
1621
|
-
var amount = convertToAbsoluteValue(params[0]);
|
|
1622
|
-
createFeComponentTransfer(document, $filter, {
|
|
1623
|
-
type: 'table',
|
|
1624
|
-
tableValues: amount + " " + (1 - amount)
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1671
|
+
canvas.setAttribute('width', "" + img.width); // @ts-ignore
|
|
1627
1672
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
createFeComponentTransfer(document, $filter, {
|
|
1631
|
-
type: 'linear',
|
|
1632
|
-
slope: slope,
|
|
1633
|
-
intercept: 0
|
|
1634
|
-
});
|
|
1635
|
-
}
|
|
1673
|
+
canvas.setAttribute('height', "" + img.height);
|
|
1674
|
+
var context = canvas.getContext('2d');
|
|
1636
1675
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
1640
|
-
$feColorMatrix.setAttribute('type', 'saturate');
|
|
1641
|
-
$feColorMatrix.setAttribute('values', "" + amount);
|
|
1642
|
-
$filter.appendChild($feColorMatrix);
|
|
1643
|
-
}
|
|
1676
|
+
if (context) {
|
|
1677
|
+
context.putImageData(img, 0, 0);
|
|
1644
1678
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1679
|
+
if (!width) {
|
|
1680
|
+
// @ts-ignore
|
|
1681
|
+
$el.setAttribute('width', "" + img.width); // this.attr('width', img.width);
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
if (!height) {
|
|
1685
|
+
// @ts-ignore
|
|
1686
|
+
$el.setAttribute('height', "" + img.height); // this.attr('height', img.height);
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
$el.setAttribute('href', canvas.toDataURL());
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1650
1692
|
}
|
|
1651
1693
|
|
|
1652
|
-
function
|
|
1653
|
-
var
|
|
1654
|
-
|
|
1655
|
-
|
|
1694
|
+
function updateLineElementAttribute($el, parsedStyle) {
|
|
1695
|
+
var x1 = parsedStyle.x1,
|
|
1696
|
+
y1 = parsedStyle.y1,
|
|
1697
|
+
x2 = parsedStyle.x2,
|
|
1698
|
+
y2 = parsedStyle.y2,
|
|
1699
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1700
|
+
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1701
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1702
|
+
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY; // @see https://github.com/antvis/g/issues/1038
|
|
1656
1703
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
$
|
|
1660
|
-
$
|
|
1661
|
-
$filter.appendChild($feGaussianBlur);
|
|
1662
|
-
var $feOffset = createSVGElement('feOffset', document);
|
|
1663
|
-
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
1664
|
-
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
1665
|
-
$feOffset.setAttribute('result', 'offsetblur');
|
|
1666
|
-
$filter.appendChild($feOffset);
|
|
1667
|
-
var $feFlood = createSVGElement('feFlood', document);
|
|
1668
|
-
$feFlood.setAttribute('flood-color', shadowColor);
|
|
1669
|
-
$filter.appendChild($feFlood);
|
|
1670
|
-
var $feComposite = createSVGElement('feComposite', document);
|
|
1671
|
-
$feComposite.setAttribute('in2', 'offsetblur');
|
|
1672
|
-
$feComposite.setAttribute('operator', 'in');
|
|
1673
|
-
$filter.appendChild($feComposite);
|
|
1674
|
-
var $feMerge = createSVGElement('feMerge', document);
|
|
1675
|
-
$filter.appendChild($feMerge);
|
|
1676
|
-
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
1677
|
-
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
1678
|
-
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
1679
|
-
$feMerge.appendChild($feMergeNode1);
|
|
1680
|
-
$feMerge.appendChild($feMergeNode2);
|
|
1704
|
+
$el.setAttribute('x1', "" + (x1.value - defX));
|
|
1705
|
+
$el.setAttribute('y1', "" + (y1.value - defY));
|
|
1706
|
+
$el.setAttribute('x2', "" + (x2.value - defX));
|
|
1707
|
+
$el.setAttribute('y2', "" + (y2.value - defY));
|
|
1681
1708
|
}
|
|
1682
1709
|
|
|
1683
|
-
function
|
|
1684
|
-
var
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1710
|
+
function updatePathElementAttribute($el, parsedStyle) {
|
|
1711
|
+
var path = parsedStyle.path,
|
|
1712
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1713
|
+
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1714
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1715
|
+
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1716
|
+
$el.setAttribute('d', g.translatePathToString(path.absolutePath, defX, defY));
|
|
1688
1717
|
}
|
|
1689
|
-
/**
|
|
1690
|
-
* @see https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
|
|
1691
|
-
*/
|
|
1692
1718
|
|
|
1719
|
+
function updatePolylineElementAttribute($el, parsedStyle) {
|
|
1720
|
+
var points = parsedStyle.points,
|
|
1721
|
+
_parsedStyle$defX = parsedStyle.defX,
|
|
1722
|
+
defX = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
1723
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
1724
|
+
defY = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
1693
1725
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1726
|
+
if (points && points.points && points.points.length >= 2) {
|
|
1727
|
+
$el.setAttribute('points', points.points.map(function (point) {
|
|
1728
|
+
return point[0] - defX + "," + (point[1] - defY);
|
|
1729
|
+
}).join(' '));
|
|
1730
|
+
}
|
|
1697
1731
|
}
|
|
1698
|
-
/**
|
|
1699
|
-
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
1700
|
-
*/
|
|
1701
1732
|
|
|
1733
|
+
function updateRectElementAttribute($el, parsedStyle) {
|
|
1734
|
+
var radius = parsedStyle.radius,
|
|
1735
|
+
width = parsedStyle.width,
|
|
1736
|
+
height = parsedStyle.height; // CSSKeyword: auto
|
|
1702
1737
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1738
|
+
if (!isFinite(width.value) || !isFinite(height.value)) {
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1707
1741
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1742
|
+
var hasRadius = radius && radius.some(function (r) {
|
|
1743
|
+
return r.value !== 0;
|
|
1744
|
+
});
|
|
1745
|
+
var d = '';
|
|
1711
1746
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1747
|
+
if (!hasRadius) {
|
|
1748
|
+
d = "M 0,0 l " + width.value + ",0 l 0," + height.value + " l" + -width.value + " 0 z";
|
|
1749
|
+
} else {
|
|
1750
|
+
var _radius$map = radius.map(function (r) {
|
|
1751
|
+
return g.clamp(r.value, 0, Math.min(Math.abs(width.value) / 2, Math.abs(height.value) / 2));
|
|
1752
|
+
}),
|
|
1753
|
+
tlr = _radius$map[0],
|
|
1754
|
+
trr = _radius$map[1],
|
|
1755
|
+
brr = _radius$map[2],
|
|
1756
|
+
blr = _radius$map[3];
|
|
1757
|
+
|
|
1758
|
+
var signX = width.value > 0 ? 1 : -1;
|
|
1759
|
+
var signY = height.value > 0 ? 1 : -1; // sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
1760
|
+
|
|
1761
|
+
var sweepFlag = signX + signY !== 0 ? 1 : 0;
|
|
1762
|
+
d = [["M " + signX * tlr + ",0"], ["l " + (width.value - signX * (tlr + trr)) + ",0"], ["a " + trr + "," + trr + ",0,0," + sweepFlag + "," + signX * trr + "," + signY * trr], ["l 0," + (height.value - signY * (trr + brr))], ["a " + brr + "," + brr + ",0,0," + sweepFlag + "," + -signX * brr + "," + signY * brr], ["l " + (signX * (brr + blr) - width.value) + ",0"], ["a " + blr + "," + blr + ",0,0," + sweepFlag + "," + -signX * blr + "," + -signY * blr], ["l 0," + (signY * (blr + tlr) - height.value)], ["a " + tlr + "," + tlr + ",0,0," + sweepFlag + "," + signX * tlr + "," + -signY * tlr], ['z']].join(' ');
|
|
1716
1763
|
}
|
|
1717
1764
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1765
|
+
$el.setAttribute('d', d);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
function numberToLongString(x) {
|
|
1769
|
+
return x.toFixed(6).replace('.000000', '');
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
function convertHTML(str) {
|
|
1773
|
+
var regex = /[&|<|>|"|']/g;
|
|
1774
|
+
return str.replace(regex, function (match) {
|
|
1775
|
+
if (match === '&') {
|
|
1776
|
+
return '&';
|
|
1777
|
+
} else if (match === '<') {
|
|
1778
|
+
return '<';
|
|
1779
|
+
} else if (match === '>') {
|
|
1780
|
+
return '>';
|
|
1781
|
+
} else if (match === '"') {
|
|
1782
|
+
return '"';
|
|
1722
1783
|
} else {
|
|
1723
|
-
|
|
1724
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, parsedColor.isNone ? 'none' : parsedColor.toString());
|
|
1784
|
+
return ''';
|
|
1725
1785
|
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
|
-
// @see https://stackoverflow.com/a/7723115
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1729
1788
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1789
|
+
var BASELINE_MAP = {
|
|
1790
|
+
top: 'before-edge',
|
|
1791
|
+
middle: 'central',
|
|
1792
|
+
bottom: 'after-edge',
|
|
1793
|
+
alphabetic: 'alphabetic',
|
|
1794
|
+
ideographic: 'ideographic',
|
|
1795
|
+
hanging: 'hanging'
|
|
1796
|
+
}; // for FireFox
|
|
1797
|
+
// @see https://github.com/plouc/nivo/issues/164
|
|
1798
|
+
|
|
1799
|
+
var BASELINE_MAP_FOR_FIREFOX = {
|
|
1800
|
+
top: 'text-before-edge',
|
|
1801
|
+
middle: 'central',
|
|
1802
|
+
bottom: 'text-after-edge',
|
|
1803
|
+
alphabetic: 'alphabetic',
|
|
1804
|
+
ideographic: 'ideographic',
|
|
1805
|
+
hanging: 'hanging'
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1808
|
+
function updateTextElementAttribute($el, parsedStyle) {
|
|
1809
|
+
var textBaseline = parsedStyle.textBaseline,
|
|
1810
|
+
lineWidth = parsedStyle.lineWidth,
|
|
1811
|
+
metrics = parsedStyle.metrics,
|
|
1812
|
+
dx = parsedStyle.dx,
|
|
1813
|
+
dy = parsedStyle.dy;
|
|
1814
|
+
var browser = detect();
|
|
1815
|
+
|
|
1816
|
+
if (browser && browser.name === 'firefox') {
|
|
1817
|
+
// compatible with FireFox browser, ref: https://github.com/antvis/g/issues/119
|
|
1818
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value] || 'alphabetic');
|
|
1732
1819
|
} else {
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
1736
|
-
return gradientId;
|
|
1737
|
-
} else {
|
|
1738
|
-
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
1739
|
-
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
1740
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
|
|
1741
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
1742
|
-
return filterId;
|
|
1743
|
-
}
|
|
1820
|
+
$el.setAttribute('dominant-baseline', BASELINE_MAP_FOR_FIREFOX[textBaseline.value]);
|
|
1821
|
+
$el.setAttribute('alignment-baseline', BASELINE_MAP[textBaseline.value]);
|
|
1744
1822
|
}
|
|
1745
1823
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1824
|
+
$el.setAttribute('paint-order', 'stroke');
|
|
1825
|
+
var lines = metrics.lines,
|
|
1826
|
+
lineHeight = metrics.lineHeight,
|
|
1827
|
+
height = metrics.height;
|
|
1828
|
+
var lineNum = lines.length;
|
|
1829
|
+
$el.setAttribute('style', "transform:translate(" + dx.toString() + ", " + dy.toString() + ");");
|
|
1748
1830
|
|
|
1749
|
-
|
|
1750
|
-
|
|
1831
|
+
if (lineNum === 1) {
|
|
1832
|
+
$el.innerHTML = convertHTML(lines[0]);
|
|
1833
|
+
$el.setAttribute('dx', "" + lineWidth.value / 2);
|
|
1834
|
+
} else {
|
|
1835
|
+
$el.innerHTML = lines.map(function (line, i) {
|
|
1836
|
+
var dx = lineWidth.value / 2;
|
|
1837
|
+
var dy = 0;
|
|
1751
1838
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
value
|
|
1839
|
+
if (i === 0) {
|
|
1840
|
+
// TODO: handle other textBaseline values
|
|
1841
|
+
if (textBaseline.value === 'middle') {
|
|
1842
|
+
dy = lineHeight / 2 - height / 2;
|
|
1843
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1844
|
+
dy = 0;
|
|
1845
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1846
|
+
dy = -lineHeight * (lineNum - 1);
|
|
1847
|
+
}
|
|
1848
|
+
} else {
|
|
1849
|
+
dy = lineHeight;
|
|
1850
|
+
}
|
|
1755
1851
|
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
var _type = value.type,
|
|
1759
|
-
width = value.width,
|
|
1760
|
-
height = value.height,
|
|
1761
|
-
steps = value.steps,
|
|
1762
|
-
angle = value.angle,
|
|
1763
|
-
cx = value.cx,
|
|
1764
|
-
cy = value.cy;
|
|
1765
|
-
cacheKey = "" + _type + width + height + (angle || 0) + (cx || 0) + (cy || 0) + steps.map(function (step) {
|
|
1766
|
-
return step.join('');
|
|
1767
|
-
}).join('');
|
|
1768
|
-
}
|
|
1769
|
-
} else if (g.isPattern(src)) {
|
|
1770
|
-
if (g.isString(src.image)) {
|
|
1771
|
-
cacheKey = "pattern-" + src.image + "-" + src.repetition;
|
|
1772
|
-
} else {
|
|
1773
|
-
cacheKey = "pattern-" + counter;
|
|
1774
|
-
}
|
|
1852
|
+
return "<tspan x=\"0\" dx=\"" + dx + "\" dy=\"" + dy + "\">" + convertHTML(line) + "</tspan>";
|
|
1853
|
+
}).join('');
|
|
1775
1854
|
}
|
|
1855
|
+
}
|
|
1776
1856
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1857
|
+
var CreateElementContribution = g.Syringe.defineToken('CreateElementContribution', {
|
|
1858
|
+
multiple: false
|
|
1859
|
+
});
|
|
1782
1860
|
|
|
1783
|
-
|
|
1861
|
+
function createSVGElement(type, doc) {
|
|
1862
|
+
return (doc || document).createElementNS('http://www.w3.org/2000/svg', type);
|
|
1784
1863
|
}
|
|
1785
1864
|
|
|
1786
|
-
|
|
1787
|
-
var patternId = generateCacheKey(pattern);
|
|
1788
|
-
var $existed = $def.querySelector("#" + patternId);
|
|
1865
|
+
var _SHAPE2TAGS, _SHAPE_UPDATE_DEPS;
|
|
1789
1866
|
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
repetition = pattern.repetition;
|
|
1793
|
-
var imageURL = '';
|
|
1867
|
+
var SHAPE2TAGS = (_SHAPE2TAGS = {}, _SHAPE2TAGS[g.Shape.RECT] = 'path', _SHAPE2TAGS[g.Shape.CIRCLE] = 'circle', _SHAPE2TAGS[g.Shape.ELLIPSE] = 'ellipse', _SHAPE2TAGS[g.Shape.IMAGE] = 'image', _SHAPE2TAGS[g.Shape.GROUP] = 'g', _SHAPE2TAGS[g.Shape.LINE] = 'line', _SHAPE2TAGS[g.Shape.POLYLINE] = 'polyline', _SHAPE2TAGS[g.Shape.POLYGON] = 'polygon', _SHAPE2TAGS[g.Shape.TEXT] = 'text', _SHAPE2TAGS[g.Shape.PATH] = 'path', _SHAPE2TAGS[g.Shape.HTML] = 'foreignObject', _SHAPE2TAGS);
|
|
1868
|
+
var SHAPE_UPDATE_DEPS = (_SHAPE_UPDATE_DEPS = {}, _SHAPE_UPDATE_DEPS[g.Shape.CIRCLE] = ['r'], _SHAPE_UPDATE_DEPS[g.Shape.ELLIPSE] = ['rx', 'ry'], _SHAPE_UPDATE_DEPS[g.Shape.RECT] = ['width', 'height', 'radius'], _SHAPE_UPDATE_DEPS[g.Shape.IMAGE] = ['img', 'width', 'height'], _SHAPE_UPDATE_DEPS[g.Shape.LINE] = ['x1', 'y1', 'x2', 'y2'], _SHAPE_UPDATE_DEPS[g.Shape.POLYLINE] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.POLYGON] = ['points'], _SHAPE_UPDATE_DEPS[g.Shape.PATH] = ['path'], _SHAPE_UPDATE_DEPS[g.Shape.TEXT] = ['text', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'textTransform', 'whiteSpace', 'dx', 'dy'], _SHAPE_UPDATE_DEPS);
|
|
1794
1869
|
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
if (image instanceof HTMLImageElement) {
|
|
1800
|
-
imageURL = image.src;
|
|
1801
|
-
} else if (image instanceof HTMLCanvasElement) {
|
|
1802
|
-
imageURL = image.toDataURL();
|
|
1803
|
-
} else ;
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1870
|
+
var DefaultCreateElementContribution = /*#__PURE__*/function () {
|
|
1871
|
+
function DefaultCreateElementContribution() {
|
|
1872
|
+
this.canvasConfig = void 0;
|
|
1873
|
+
}
|
|
1806
1874
|
|
|
1807
|
-
|
|
1808
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
1809
|
-
var $pattern = createSVGElement('pattern', document);
|
|
1810
|
-
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
1811
|
-
var $image = createSVGElement('image', document);
|
|
1812
|
-
$pattern.appendChild($image);
|
|
1813
|
-
$pattern.id = patternId;
|
|
1814
|
-
$def.appendChild($pattern); // use href instead of xlink:href
|
|
1815
|
-
// @see https://stackoverflow.com/a/13379007
|
|
1875
|
+
var _proto = DefaultCreateElementContribution.prototype;
|
|
1816
1876
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1877
|
+
_proto.createElement = function createElement(object) {
|
|
1878
|
+
var doc = this.canvasConfig.document;
|
|
1879
|
+
var type = SHAPE2TAGS[object.nodeName] || 'g';
|
|
1880
|
+
return createSVGElement(type, doc || document);
|
|
1881
|
+
};
|
|
1819
1882
|
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
}
|
|
1883
|
+
_proto.shouldUpdateElementAttribute = function shouldUpdateElementAttribute(object, attributeName) {
|
|
1884
|
+
var nodeName = object.nodeName;
|
|
1885
|
+
return (SHAPE_UPDATE_DEPS[nodeName] || []).indexOf(attributeName) > -1;
|
|
1886
|
+
};
|
|
1825
1887
|
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1888
|
+
_proto.updateElementAttribute = function updateElementAttribute(object) {
|
|
1889
|
+
// @ts-ignore
|
|
1890
|
+
var $el = object.elementSVG.$el;
|
|
1891
|
+
var nodeName = object.nodeName,
|
|
1892
|
+
parsedStyle = object.parsedStyle;
|
|
1830
1893
|
|
|
1831
|
-
|
|
1894
|
+
switch (nodeName) {
|
|
1895
|
+
case g.Shape.IMAGE:
|
|
1896
|
+
{
|
|
1897
|
+
updateImageElementAttribute($el, parsedStyle);
|
|
1898
|
+
break;
|
|
1899
|
+
}
|
|
1832
1900
|
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1901
|
+
case g.Shape.RECT:
|
|
1902
|
+
{
|
|
1903
|
+
updateRectElementAttribute($el, parsedStyle);
|
|
1904
|
+
break;
|
|
1905
|
+
}
|
|
1836
1906
|
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1907
|
+
case g.Shape.LINE:
|
|
1908
|
+
{
|
|
1909
|
+
updateLineElementAttribute($el, parsedStyle);
|
|
1910
|
+
break;
|
|
1911
|
+
}
|
|
1840
1912
|
|
|
1913
|
+
case g.Shape.POLYGON:
|
|
1914
|
+
case g.Shape.POLYLINE:
|
|
1915
|
+
{
|
|
1916
|
+
updatePolylineElementAttribute($el, parsedStyle);
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1841
1919
|
|
|
1842
|
-
|
|
1843
|
-
|
|
1920
|
+
case g.Shape.PATH:
|
|
1921
|
+
{
|
|
1922
|
+
updatePathElementAttribute($el, parsedStyle);
|
|
1923
|
+
break;
|
|
1924
|
+
}
|
|
1844
1925
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
} else if (repetition === 'no-repeat') {
|
|
1850
|
-
patternWidth = halfExtents[0] * 2;
|
|
1851
|
-
patternHeight = halfExtents[1] * 2;
|
|
1926
|
+
case g.Shape.TEXT:
|
|
1927
|
+
{
|
|
1928
|
+
updateTextElementAttribute($el, parsedStyle);
|
|
1929
|
+
break;
|
|
1852
1930
|
}
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1853
1933
|
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
$image.setAttribute('x', '0');
|
|
1857
|
-
$image.setAttribute('y', '0');
|
|
1858
|
-
$image.setAttribute('width', "" + img.width);
|
|
1859
|
-
$image.setAttribute('height', "" + img.height);
|
|
1860
|
-
};
|
|
1934
|
+
return DefaultCreateElementContribution;
|
|
1935
|
+
}();
|
|
1861
1936
|
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1937
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], DefaultCreateElementContribution.prototype, "canvasConfig", void 0);
|
|
1938
|
+
|
|
1939
|
+
DefaultCreateElementContribution = __decorate([g.singleton({
|
|
1940
|
+
token: CreateElementContribution
|
|
1941
|
+
})], DefaultCreateElementContribution);
|
|
1942
|
+
var FILTER_PREFIX = 'g-filter-';
|
|
1943
|
+
/**
|
|
1944
|
+
* use SVG filters, eg. blur, brightness, contrast...
|
|
1945
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
1946
|
+
*/
|
|
1947
|
+
|
|
1948
|
+
function createOrUpdateFilter(document, $def, object, $el, filters) {
|
|
1949
|
+
// eg. filter="url(#f1) url(#f2)"
|
|
1950
|
+
var filterName = FILTER_PREFIX + object.entity;
|
|
1951
|
+
var $existedFilters = $def.querySelectorAll("[name=" + filterName + "]");
|
|
1866
1952
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1953
|
+
if ($existedFilters.length) {
|
|
1954
|
+
$existedFilters.forEach(function ($filter) {
|
|
1955
|
+
$def.removeChild($filter);
|
|
1956
|
+
});
|
|
1870
1957
|
}
|
|
1871
1958
|
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1959
|
+
if (filters.length === 0) {
|
|
1960
|
+
// 'none'
|
|
1961
|
+
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
1962
|
+
} else {
|
|
1963
|
+
var filterIds = filters.map(function (_ref, i) {
|
|
1964
|
+
var name = _ref.name,
|
|
1965
|
+
params = _ref.params;
|
|
1966
|
+
var $filter = createSVGElement('filter', document); // @see https://github.com/antvis/g/issues/1025
|
|
1878
1967
|
|
|
1879
|
-
|
|
1880
|
-
// <linearGradient> <radialGradient>
|
|
1881
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
1882
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
1883
|
-
$existed = createSVGElement(parsedColor.type === g.GradientType.LinearGradient ? 'linearGradient' : 'radialGradient', document); // @see https://github.com/antvis/g/issues/1025
|
|
1968
|
+
$filter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
1884
1969
|
|
|
1885
|
-
|
|
1970
|
+
if (name === 'blur') {
|
|
1971
|
+
createBlur(document, $filter, params);
|
|
1972
|
+
} else if (name === 'brightness') {
|
|
1973
|
+
createBrightness(document, $filter, params);
|
|
1974
|
+
} else if (name === 'drop-shadow') {
|
|
1975
|
+
createDropShadow(document, $filter, params);
|
|
1976
|
+
} else if (name === 'contrast') {
|
|
1977
|
+
createContrast(document, $filter, params);
|
|
1978
|
+
} else if (name === 'grayscale') {
|
|
1979
|
+
createGrayscale(document, $filter, params);
|
|
1980
|
+
} else if (name === 'sepia') {
|
|
1981
|
+
createSepia(document, $filter, params);
|
|
1982
|
+
} else if (name === 'saturate') {
|
|
1983
|
+
createSaturate(document, $filter, params);
|
|
1984
|
+
} else if (name === 'hue-rotate') {
|
|
1985
|
+
createHueRotate(document, $filter, params);
|
|
1986
|
+
} else if (name === 'invert') {
|
|
1987
|
+
createInvert(document, $filter, params);
|
|
1988
|
+
}
|
|
1886
1989
|
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
1990
|
+
$filter.id = filterName + "-" + i;
|
|
1991
|
+
$filter.setAttribute('name', filterName);
|
|
1992
|
+
$def.appendChild($filter);
|
|
1993
|
+
return $filter.id;
|
|
1892
1994
|
});
|
|
1893
|
-
$
|
|
1894
|
-
|
|
1895
|
-
|
|
1995
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', filterIds.map(function (filterId) {
|
|
1996
|
+
return "url(#" + filterId + ")";
|
|
1997
|
+
}).join(' '));
|
|
1896
1998
|
}
|
|
1999
|
+
}
|
|
1897
2000
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
2001
|
+
function convertToAbsoluteValue(param) {
|
|
2002
|
+
return param.unit === g.UnitType.kPercentage ? param.value / 100 : param.value;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* @see https://drafts.fxtf.org/filter-effects/#blurEquivalent
|
|
2006
|
+
*/
|
|
1904
2007
|
|
|
1905
|
-
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
1906
|
-
x1 = _computeLinearGradien.x1,
|
|
1907
|
-
y1 = _computeLinearGradien.y1,
|
|
1908
|
-
x2 = _computeLinearGradien.x2,
|
|
1909
|
-
y2 = _computeLinearGradien.y2;
|
|
1910
2008
|
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
cx = _parsedColor$value.cx,
|
|
1918
|
-
cy = _parsedColor$value.cy;
|
|
2009
|
+
function createBlur(document, $filter, params) {
|
|
2010
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2011
|
+
$feGaussianBlur.setAttribute('in', 'SourceGraphic');
|
|
2012
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + params[0].value);
|
|
2013
|
+
$filter.appendChild($feGaussianBlur);
|
|
2014
|
+
}
|
|
1919
2015
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2016
|
+
function createFeComponentTransfer(document, $filter, _ref2) {
|
|
2017
|
+
var type = _ref2.type,
|
|
2018
|
+
slope = _ref2.slope,
|
|
2019
|
+
intercept = _ref2.intercept,
|
|
2020
|
+
tableValues = _ref2.tableValues;
|
|
2021
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
2022
|
+
[createSVGElement('feFuncR', document), createSVGElement('feFuncG', document), createSVGElement('feFuncB', document)].forEach(function ($feFunc) {
|
|
2023
|
+
$feFunc.setAttribute('type', type);
|
|
1924
2024
|
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2025
|
+
if (type === 'table') {
|
|
2026
|
+
$feFunc.setAttribute('tableValues', "" + tableValues);
|
|
2027
|
+
} else {
|
|
2028
|
+
$feFunc.setAttribute('slope', "" + slope);
|
|
2029
|
+
$feFunc.setAttribute('intercept', "" + intercept);
|
|
2030
|
+
}
|
|
1929
2031
|
|
|
1930
|
-
|
|
2032
|
+
$feComponentTransfer.appendChild($feFunc);
|
|
2033
|
+
});
|
|
2034
|
+
$filter.appendChild($feComponentTransfer);
|
|
1931
2035
|
}
|
|
1932
2036
|
|
|
1933
|
-
function
|
|
1934
|
-
var
|
|
1935
|
-
|
|
2037
|
+
function createContrast(document, $filter, params) {
|
|
2038
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
2039
|
+
createFeComponentTransfer(document, $filter, {
|
|
2040
|
+
type: 'linear',
|
|
2041
|
+
slope: slope,
|
|
2042
|
+
intercept: -(0.5 * slope) + 0.5
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
1936
2045
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2046
|
+
function createInvert(document, $filter, params) {
|
|
2047
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2048
|
+
createFeComponentTransfer(document, $filter, {
|
|
2049
|
+
type: 'table',
|
|
2050
|
+
tableValues: amount + " " + (1 - amount)
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
1940
2053
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
* <rect id="wave-rect" x="0" y="0" width="100%" height="100%" fill="url(#wave)"></rect>
|
|
1950
|
-
* <filter id="blend-it" x="0%" y="0%" width="100%" height="100%">
|
|
1951
|
-
<feImage xlink:href="#wave-rect" result="myWave" x="100" y="100"/>
|
|
1952
|
-
<feImage xlink:href="#ry-rect" result="myRY" x="100" y="100"/>
|
|
1953
|
-
<feBlend in="myWave" in2="myRY" mode="multiply" result="blendedGrad"/>
|
|
1954
|
-
<feComposite in="blendedGrad" in2="SourceGraphic" operator="in"/>
|
|
1955
|
-
</filter>
|
|
1956
|
-
*/
|
|
2054
|
+
function createBrightness(document, $filter, params) {
|
|
2055
|
+
var slope = convertToAbsoluteValue(params[0]);
|
|
2056
|
+
createFeComponentTransfer(document, $filter, {
|
|
2057
|
+
type: 'linear',
|
|
2058
|
+
slope: slope,
|
|
2059
|
+
intercept: 0
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
1957
2062
|
|
|
2063
|
+
function createSaturate(document, $filter, params) {
|
|
2064
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2065
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2066
|
+
$feColorMatrix.setAttribute('type', 'saturate');
|
|
2067
|
+
$feColorMatrix.setAttribute('values', "" + amount);
|
|
2068
|
+
$filter.appendChild($feColorMatrix);
|
|
2069
|
+
}
|
|
1958
2070
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
$rect.setAttribute('y', '0');
|
|
1966
|
-
$rect.setAttribute('width', '100%');
|
|
1967
|
-
$rect.setAttribute('height', '100%');
|
|
1968
|
-
$rect.setAttribute('fill', "url(#" + gradientId + ")");
|
|
1969
|
-
$rect.id = rectId;
|
|
1970
|
-
$def.appendChild($rect);
|
|
1971
|
-
var $feImage = createSVGElement('feImage', document);
|
|
1972
|
-
$feImage.setAttribute('href', "#" + rectId);
|
|
1973
|
-
$feImage.setAttribute('result', filterId + "-" + i);
|
|
1974
|
-
$existed.appendChild($feImage);
|
|
2071
|
+
function createHueRotate(document, $filter, params) {
|
|
2072
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2073
|
+
$feColorMatrix.setAttribute('type', 'hueRotate');
|
|
2074
|
+
$feColorMatrix.setAttribute('values', "" + params[0].to(g.UnitType.kDegrees).value);
|
|
2075
|
+
$filter.appendChild($feColorMatrix);
|
|
2076
|
+
}
|
|
1975
2077
|
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
$feBlend.setAttribute('result', filterId + "-blended-" + blended++); // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
2078
|
+
function createDropShadow(document, $filter, params) {
|
|
2079
|
+
var shadowOffsetX = params[0].value;
|
|
2080
|
+
var shadowOffsetY = params[1].value;
|
|
2081
|
+
var shadowBlur = params[2].value; // @ts-ignore
|
|
1981
2082
|
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
2083
|
+
var shadowColor = params[3].formatted;
|
|
2084
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2085
|
+
$feGaussianBlur.setAttribute('in', 'SourceAlpha');
|
|
2086
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + shadowBlur);
|
|
2087
|
+
$filter.appendChild($feGaussianBlur);
|
|
2088
|
+
var $feOffset = createSVGElement('feOffset', document);
|
|
2089
|
+
$feOffset.setAttribute('dx', "" + shadowOffsetX);
|
|
2090
|
+
$feOffset.setAttribute('dy', "" + shadowOffsetY);
|
|
2091
|
+
$feOffset.setAttribute('result', 'offsetblur');
|
|
2092
|
+
$filter.appendChild($feOffset);
|
|
2093
|
+
var $feFlood = createSVGElement('feFlood', document);
|
|
2094
|
+
$feFlood.setAttribute('flood-color', shadowColor);
|
|
2095
|
+
$filter.appendChild($feFlood);
|
|
1986
2096
|
var $feComposite = createSVGElement('feComposite', document);
|
|
1987
|
-
$feComposite.setAttribute('
|
|
1988
|
-
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
2097
|
+
$feComposite.setAttribute('in2', 'offsetblur');
|
|
1989
2098
|
$feComposite.setAttribute('operator', 'in');
|
|
1990
|
-
$
|
|
1991
|
-
|
|
2099
|
+
$filter.appendChild($feComposite);
|
|
2100
|
+
var $feMerge = createSVGElement('feMerge', document);
|
|
2101
|
+
$filter.appendChild($feMerge);
|
|
2102
|
+
var $feMergeNode1 = createSVGElement('feMergeNode', document);
|
|
2103
|
+
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
2104
|
+
$feMergeNode2.setAttribute('in', 'SourceGraphic');
|
|
2105
|
+
$feMerge.appendChild($feMergeNode1);
|
|
2106
|
+
$feMerge.appendChild($feMergeNode2);
|
|
1992
2107
|
}
|
|
1993
2108
|
|
|
1994
|
-
|
|
2109
|
+
function createFeColorMatrix(document, $filter, matrix) {
|
|
2110
|
+
var $feColorMatrix = createSVGElement('feColorMatrix', document);
|
|
2111
|
+
$feColorMatrix.setAttribute('type', 'matrix');
|
|
2112
|
+
$feColorMatrix.setAttribute('values', matrix.join(' '));
|
|
2113
|
+
$filter.appendChild($feColorMatrix);
|
|
2114
|
+
}
|
|
1995
2115
|
/**
|
|
1996
|
-
*
|
|
1997
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2116
|
+
* @see https://drafts.fxtf.org/filter-effects/#grayscaleEquivalent
|
|
1998
2117
|
*/
|
|
1999
2118
|
|
|
2000
|
-
function createOrUpdateShadow(document, $def, object, $el, name) {
|
|
2001
|
-
var _object$parsedStyle$s;
|
|
2002
|
-
|
|
2003
|
-
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2004
|
-
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2005
|
-
|
|
2006
|
-
if (!$existedFilter) {
|
|
2007
|
-
$existedFilter = createSVGElement('filter', document);
|
|
2008
|
-
|
|
2009
|
-
var _$feDropShadow = createSVGElement('feDropShadow', document);
|
|
2010
|
-
|
|
2011
|
-
_$feDropShadow.setAttribute('dx', '0');
|
|
2012
|
-
|
|
2013
|
-
_$feDropShadow.setAttribute('dy', '0');
|
|
2014
2119
|
|
|
2015
|
-
|
|
2016
|
-
|
|
2120
|
+
function createGrayscale(document, $filter, params) {
|
|
2121
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2122
|
+
createFeColorMatrix(document, $filter, [0.2126 + 0.7874 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 + 0.2848 * (1 - amount), 0.0722 - 0.0722 * (1 - amount), 0, 0, 0.2126 - 0.2126 * (1 - amount), 0.7152 - 0.7152 * (1 - amount), 0.0722 + 0.9278 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2123
|
+
}
|
|
2124
|
+
/**
|
|
2125
|
+
* @see https://drafts.fxtf.org/filter-effects/#sepiaEquivalent
|
|
2126
|
+
*/
|
|
2017
2127
|
|
|
2018
|
-
$existedFilter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
2019
|
-
$def.appendChild($existedFilter);
|
|
2020
|
-
}
|
|
2021
2128
|
|
|
2022
|
-
|
|
2129
|
+
function createSepia(document, $filter, params) {
|
|
2130
|
+
var amount = convertToAbsoluteValue(params[0]);
|
|
2131
|
+
createFeColorMatrix(document, $filter, [0.393 + 0.607 * (1 - amount), 0.769 - 0.769 * (1 - amount), 0.189 - 0.189 * (1 - amount), 0, 0, 0.349 - 0.349 * (1 - amount), 0.686 + 0.314 * (1 - amount), 0.168 - 0.168 * (1 - amount), 0, 0, 0.272 - 0.272 * (1 - amount), 0.534 - 0.534 * (1 - amount), 0.131 + 0.869 * (1 - amount), 0, 0, 0, 0, 0, 1, 0]);
|
|
2132
|
+
}
|
|
2023
2133
|
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
} else if (name === 'shadowBlur') {
|
|
2028
|
-
var shadowBlur = object.parsedStyle[name]; // half the blur radius
|
|
2029
|
-
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2030
|
-
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2134
|
+
var PATTERN_PREFIX = 'g-pattern-';
|
|
2135
|
+
var cacheKey2IDMap = {};
|
|
2136
|
+
var counter = 0;
|
|
2031
2137
|
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
}
|
|
2037
|
-
var shadowOffsetY = object.parsedStyle[name];
|
|
2038
|
-
$feDropShadow.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2039
|
-
} // only apply shadow when blur > 0
|
|
2138
|
+
function createOrUpdateGradientAndPattern(document, $def, object, $el, parsedColor, name, createImage) {
|
|
2139
|
+
// eg. clipPath don't have fill/stroke
|
|
2140
|
+
if (!parsedColor) {
|
|
2141
|
+
return '';
|
|
2142
|
+
}
|
|
2040
2143
|
|
|
2144
|
+
if (parsedColor instanceof g.CSSRGB) {
|
|
2145
|
+
// keep using currentColor @see https://github.com/d3/d3-axis/issues/49
|
|
2146
|
+
if (object.style[name] === 'currentColor') {
|
|
2147
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, 'currentColor');
|
|
2148
|
+
} else {
|
|
2149
|
+
// constant value, eg. '#fff'
|
|
2150
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, parsedColor.isNone ? 'none' : parsedColor.toString());
|
|
2151
|
+
}
|
|
2152
|
+
} else if (g.isPattern(parsedColor)) {
|
|
2153
|
+
var patternId = createOrUpdatePattern(document, $def, object, parsedColor, createImage); // use style instead of attribute when applying <pattern>
|
|
2154
|
+
// @see https://stackoverflow.com/a/7723115
|
|
2041
2155
|
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2045
|
-
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2156
|
+
$el.style[name] = "url(#" + patternId + ")";
|
|
2157
|
+
return patternId;
|
|
2046
2158
|
} else {
|
|
2047
|
-
|
|
2159
|
+
if (parsedColor.length === 1) {
|
|
2160
|
+
var gradientId = createOrUpdateGradient(document, object, $def, $el, parsedColor[0]);
|
|
2161
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute(name, "url(#" + gradientId + ")");
|
|
2162
|
+
return gradientId;
|
|
2163
|
+
} else {
|
|
2164
|
+
// @see https://stackoverflow.com/questions/20671502/can-i-blend-gradients-in-svg
|
|
2165
|
+
var filterId = createOrUpdateMultiGradient(document, object, $def, $el, parsedColor);
|
|
2166
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + filterId + ")");
|
|
2167
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('fill', 'black');
|
|
2168
|
+
return filterId;
|
|
2169
|
+
}
|
|
2048
2170
|
}
|
|
2049
|
-
}
|
|
2050
2171
|
|
|
2051
|
-
|
|
2172
|
+
return '';
|
|
2173
|
+
}
|
|
2052
2174
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
this.canvasConfig = void 0;
|
|
2056
|
-
this.contextService = void 0;
|
|
2057
|
-
this.$def = void 0;
|
|
2058
|
-
this.gradientCache = {};
|
|
2059
|
-
}
|
|
2175
|
+
function generateCacheKey(src) {
|
|
2176
|
+
var cacheKey = '';
|
|
2060
2177
|
|
|
2061
|
-
|
|
2178
|
+
if (src instanceof g.CSSGradientValue) {
|
|
2179
|
+
var type = src.type,
|
|
2180
|
+
value = src.value;
|
|
2062
2181
|
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2182
|
+
if (type === g.GradientType.LinearGradient || type === g.GradientType.RadialGradient) {
|
|
2183
|
+
// @ts-ignore
|
|
2184
|
+
var _type = value.type,
|
|
2185
|
+
width = value.width,
|
|
2186
|
+
height = value.height,
|
|
2187
|
+
steps = value.steps,
|
|
2188
|
+
angle = value.angle,
|
|
2189
|
+
cx = value.cx,
|
|
2190
|
+
cy = value.cy;
|
|
2191
|
+
cacheKey = "" + _type + width + height + (angle || 0) + (cx || 0) + (cy || 0) + steps.map(function (step) {
|
|
2192
|
+
return step.join('');
|
|
2193
|
+
}).join('');
|
|
2194
|
+
}
|
|
2195
|
+
} else if (g.isPattern(src)) {
|
|
2196
|
+
if (g.isString(src.image)) {
|
|
2197
|
+
cacheKey = "pattern-" + src.image + "-" + src.repetition;
|
|
2198
|
+
} else {
|
|
2199
|
+
cacheKey = "pattern-" + counter;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2066
2202
|
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
};
|
|
2203
|
+
if (cacheKey) {
|
|
2204
|
+
if (!cacheKey2IDMap[cacheKey]) {
|
|
2205
|
+
cacheKey2IDMap[cacheKey] = PATTERN_PREFIX + ("" + counter++);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2073
2208
|
|
|
2074
|
-
|
|
2075
|
-
|
|
2209
|
+
return cacheKey2IDMap[cacheKey];
|
|
2210
|
+
}
|
|
2076
2211
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
};
|
|
2212
|
+
function createOrUpdatePattern(document, $def, object, pattern, createImage) {
|
|
2213
|
+
var patternId = generateCacheKey(pattern);
|
|
2214
|
+
var $existed = $def.querySelector("#" + patternId);
|
|
2081
2215
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2216
|
+
if (!$existed) {
|
|
2217
|
+
var image = pattern.image,
|
|
2218
|
+
repetition = pattern.repetition;
|
|
2219
|
+
var imageURL = '';
|
|
2085
2220
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2221
|
+
if (g.isString(image)) {
|
|
2222
|
+
imageURL = image;
|
|
2223
|
+
} else {
|
|
2224
|
+
if (g.isBrowser) {
|
|
2225
|
+
if (image instanceof HTMLImageElement) {
|
|
2226
|
+
imageURL = image.src;
|
|
2227
|
+
} else if (image instanceof HTMLCanvasElement) {
|
|
2228
|
+
imageURL = image.toDataURL();
|
|
2229
|
+
} else ;
|
|
2088
2230
|
}
|
|
2089
2231
|
}
|
|
2090
|
-
};
|
|
2091
|
-
|
|
2092
|
-
_proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name) {
|
|
2093
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
2094
|
-
doc = _this$canvasConfig.document,
|
|
2095
|
-
createImage = _this$canvasConfig.createImage;
|
|
2096
|
-
|
|
2097
|
-
if ($el) {
|
|
2098
|
-
var _$el$getAttribute; // `url(#${gradientId})`
|
|
2099
2232
|
|
|
2233
|
+
if (imageURL) {
|
|
2234
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/pattern
|
|
2235
|
+
var $pattern = createSVGElement('pattern', document);
|
|
2236
|
+
$pattern.setAttribute('patternUnits', 'userSpaceOnUse');
|
|
2237
|
+
var $image = createSVGElement('image', document);
|
|
2238
|
+
$pattern.appendChild($image);
|
|
2239
|
+
$pattern.id = patternId;
|
|
2240
|
+
$def.appendChild($pattern); // use href instead of xlink:href
|
|
2241
|
+
// @see https://stackoverflow.com/a/13379007
|
|
2100
2242
|
|
|
2101
|
-
|
|
2243
|
+
$image.setAttribute('href', imageURL);
|
|
2244
|
+
var img;
|
|
2102
2245
|
|
|
2103
|
-
if (
|
|
2104
|
-
|
|
2246
|
+
if (createImage) {
|
|
2247
|
+
img = createImage(imageURL);
|
|
2248
|
+
} else if (g.isBrowser) {
|
|
2249
|
+
img = new window.Image();
|
|
2105
2250
|
}
|
|
2106
2251
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
this.gradientCache[newDefElementId] = new Set();
|
|
2252
|
+
if (!imageURL.match(/^data:/i)) {
|
|
2253
|
+
img.crossOrigin = 'Anonymous';
|
|
2254
|
+
$image.setAttribute('crossorigin', 'anonymous');
|
|
2111
2255
|
}
|
|
2112
2256
|
|
|
2113
|
-
|
|
2114
|
-
}
|
|
2115
|
-
};
|
|
2116
|
-
|
|
2117
|
-
_proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
|
|
2118
|
-
var doc = this.canvasConfig.document;
|
|
2119
|
-
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
2120
|
-
};
|
|
2121
|
-
|
|
2122
|
-
_proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
|
|
2123
|
-
var doc = this.canvasConfig.document;
|
|
2124
|
-
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
2125
|
-
};
|
|
2126
|
-
|
|
2127
|
-
return DefElementManager;
|
|
2128
|
-
}();
|
|
2129
|
-
|
|
2130
|
-
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], DefElementManager.prototype, "canvasConfig", void 0);
|
|
2131
|
-
|
|
2132
|
-
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], DefElementManager.prototype, "contextService", void 0);
|
|
2133
|
-
|
|
2134
|
-
DefElementManager = __decorate([g.singleton()], DefElementManager);
|
|
2135
|
-
|
|
2136
|
-
function _regeneratorRuntime$2() {
|
|
2137
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2138
|
-
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2139
|
-
return exports;
|
|
2140
|
-
};
|
|
2141
|
-
|
|
2142
|
-
var exports = {},
|
|
2143
|
-
Op = Object.prototype,
|
|
2144
|
-
hasOwn = Op.hasOwnProperty,
|
|
2145
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
2146
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
2147
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
2148
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
2149
|
-
|
|
2150
|
-
function define(obj, key, value) {
|
|
2151
|
-
return Object.defineProperty(obj, key, {
|
|
2152
|
-
value: value,
|
|
2153
|
-
enumerable: !0,
|
|
2154
|
-
configurable: !0,
|
|
2155
|
-
writable: !0
|
|
2156
|
-
}), obj[key];
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
try {
|
|
2160
|
-
define({}, "");
|
|
2161
|
-
} catch (err) {
|
|
2162
|
-
define = function define(obj, key, value) {
|
|
2163
|
-
return obj[key] = value;
|
|
2164
|
-
};
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
2168
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
2169
|
-
generator = Object.create(protoGenerator.prototype),
|
|
2170
|
-
context = new Context(tryLocsList || []);
|
|
2171
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
2172
|
-
var state = "suspendedStart";
|
|
2173
|
-
return function (method, arg) {
|
|
2174
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
2175
|
-
|
|
2176
|
-
if ("completed" === state) {
|
|
2177
|
-
if ("throw" === method) throw arg;
|
|
2178
|
-
return doneResult();
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
for (context.method = method, context.arg = arg;;) {
|
|
2182
|
-
var delegate = context.delegate;
|
|
2183
|
-
|
|
2184
|
-
if (delegate) {
|
|
2185
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
2257
|
+
img.src = imageURL;
|
|
2186
2258
|
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2259
|
+
var onload = function onload() {
|
|
2260
|
+
$pattern.setAttribute('x', '0');
|
|
2261
|
+
$pattern.setAttribute('y', '0');
|
|
2192
2262
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
2197
|
-
state = "executing";
|
|
2198
|
-
var record = tryCatch(innerFn, self, context);
|
|
2263
|
+
var _object$getGeometryBo = object.getGeometryBounds(),
|
|
2264
|
+
halfExtents = _object$getGeometryBo.halfExtents; // There is no equivalent to CSS no-repeat for SVG patterns
|
|
2265
|
+
// @see https://stackoverflow.com/a/33481956
|
|
2199
2266
|
|
|
2200
|
-
if ("normal" === record.type) {
|
|
2201
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
2202
|
-
return {
|
|
2203
|
-
value: record.arg,
|
|
2204
|
-
done: context.done
|
|
2205
|
-
};
|
|
2206
|
-
}
|
|
2207
2267
|
|
|
2208
|
-
|
|
2268
|
+
var patternWidth = img.width;
|
|
2269
|
+
var patternHeight = img.height;
|
|
2270
|
+
|
|
2271
|
+
if (repetition === 'repeat-x') {
|
|
2272
|
+
patternHeight = halfExtents[1] * 2;
|
|
2273
|
+
} else if (repetition === 'repeat-y') {
|
|
2274
|
+
patternWidth = halfExtents[0] * 2;
|
|
2275
|
+
} else if (repetition === 'no-repeat') {
|
|
2276
|
+
patternWidth = halfExtents[0] * 2;
|
|
2277
|
+
patternHeight = halfExtents[1] * 2;
|
|
2209
2278
|
}
|
|
2210
|
-
};
|
|
2211
|
-
}(innerFn, self, context), generator;
|
|
2212
|
-
}
|
|
2213
2279
|
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
} catch (err) {
|
|
2221
|
-
return {
|
|
2222
|
-
type: "throw",
|
|
2223
|
-
arg: err
|
|
2280
|
+
$pattern.setAttribute('width', "" + patternWidth);
|
|
2281
|
+
$pattern.setAttribute('height', "" + patternHeight);
|
|
2282
|
+
$image.setAttribute('x', '0');
|
|
2283
|
+
$image.setAttribute('y', '0');
|
|
2284
|
+
$image.setAttribute('width', "" + img.width);
|
|
2285
|
+
$image.setAttribute('height', "" + img.height);
|
|
2224
2286
|
};
|
|
2287
|
+
|
|
2288
|
+
if (img.complete) {
|
|
2289
|
+
onload();
|
|
2290
|
+
} else {
|
|
2291
|
+
img.onload = onload; // Fix onload() bug in IE9
|
|
2292
|
+
|
|
2293
|
+
img.src = img.src;
|
|
2294
|
+
}
|
|
2225
2295
|
}
|
|
2226
2296
|
}
|
|
2227
2297
|
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
function Generator() {}
|
|
2298
|
+
return patternId;
|
|
2299
|
+
}
|
|
2232
2300
|
|
|
2233
|
-
|
|
2301
|
+
function createOrUpdateGradient(document, object, $def, $el, parsedColor) {
|
|
2302
|
+
var gradientId = generateCacheKey(parsedColor);
|
|
2303
|
+
var $existed = $def.querySelector("#" + gradientId);
|
|
2234
2304
|
|
|
2235
|
-
|
|
2305
|
+
if (!$existed) {
|
|
2306
|
+
// <linearGradient> <radialGradient>
|
|
2307
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/linearGradient
|
|
2308
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/radialGradient
|
|
2309
|
+
$existed = createSVGElement(parsedColor.type === g.GradientType.LinearGradient ? 'linearGradient' : 'radialGradient', document); // @see https://github.com/antvis/g/issues/1025
|
|
2236
2310
|
|
|
2237
|
-
|
|
2238
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
2239
|
-
return this;
|
|
2240
|
-
});
|
|
2241
|
-
var getProto = Object.getPrototypeOf,
|
|
2242
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
2243
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
2244
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
2311
|
+
$existed.setAttribute('gradientUnits', 'userSpaceOnUse'); // add stops
|
|
2245
2312
|
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2313
|
+
var innerHTML = '';
|
|
2314
|
+
parsedColor.value.steps.forEach(function (_ref) {
|
|
2315
|
+
var offset = _ref[0],
|
|
2316
|
+
color = _ref[1];
|
|
2317
|
+
innerHTML += "<stop offset=\"" + offset + "\" stop-color=\"" + color + "\"></stop>";
|
|
2251
2318
|
});
|
|
2319
|
+
$existed.innerHTML = innerHTML;
|
|
2320
|
+
$existed.id = gradientId;
|
|
2321
|
+
$def.appendChild($existed);
|
|
2252
2322
|
}
|
|
2253
2323
|
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2324
|
+
var bounds = object.getGeometryBounds();
|
|
2325
|
+
var width = bounds && bounds.halfExtents[0] * 2 || 0;
|
|
2326
|
+
var height = bounds && bounds.halfExtents[1] * 2 || 0;
|
|
2257
2327
|
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
value = result.value;
|
|
2261
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
2262
|
-
invoke("next", value, resolve, reject);
|
|
2263
|
-
}, function (err) {
|
|
2264
|
-
invoke("throw", err, resolve, reject);
|
|
2265
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
2266
|
-
result.value = unwrapped, resolve(result);
|
|
2267
|
-
}, function (error) {
|
|
2268
|
-
return invoke("throw", error, resolve, reject);
|
|
2269
|
-
});
|
|
2270
|
-
}
|
|
2328
|
+
if (parsedColor.type === g.GradientType.LinearGradient) {
|
|
2329
|
+
var angle = parsedColor.value.angle;
|
|
2271
2330
|
|
|
2272
|
-
|
|
2273
|
-
|
|
2331
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
2332
|
+
x1 = _computeLinearGradien.x1,
|
|
2333
|
+
y1 = _computeLinearGradien.y1,
|
|
2334
|
+
x2 = _computeLinearGradien.x2,
|
|
2335
|
+
y2 = _computeLinearGradien.y2;
|
|
2274
2336
|
|
|
2275
|
-
|
|
2337
|
+
$existed.setAttribute('x1', "" + x1);
|
|
2338
|
+
$existed.setAttribute('y1', "" + y1);
|
|
2339
|
+
$existed.setAttribute('x2', "" + x2);
|
|
2340
|
+
$existed.setAttribute('y2', "" + y2); // $existed.setAttribute('gradientTransform', `rotate(${angle})`);
|
|
2341
|
+
} else {
|
|
2342
|
+
var _parsedColor$value = parsedColor.value,
|
|
2343
|
+
cx = _parsedColor$value.cx,
|
|
2344
|
+
cy = _parsedColor$value.cy;
|
|
2276
2345
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
});
|
|
2282
|
-
}
|
|
2346
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
2347
|
+
x = _computeRadialGradien.x,
|
|
2348
|
+
y = _computeRadialGradien.y,
|
|
2349
|
+
r = _computeRadialGradien.r;
|
|
2283
2350
|
|
|
2284
|
-
|
|
2285
|
-
|
|
2351
|
+
$existed.setAttribute('cx', "" + x);
|
|
2352
|
+
$existed.setAttribute('cy', "" + y);
|
|
2353
|
+
$existed.setAttribute('r', "" + r);
|
|
2286
2354
|
}
|
|
2287
2355
|
|
|
2288
|
-
|
|
2289
|
-
|
|
2356
|
+
return gradientId;
|
|
2357
|
+
}
|
|
2290
2358
|
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
2295
|
-
}
|
|
2359
|
+
function createOrUpdateMultiGradient(document, object, $def, $el, gradients) {
|
|
2360
|
+
var filterId = FILTER_PREFIX + object.entity + '-gradient';
|
|
2361
|
+
var $existed = $def.querySelector("#" + filterId);
|
|
2296
2362
|
|
|
2297
|
-
|
|
2298
|
-
|
|
2363
|
+
if (!$existed) {
|
|
2364
|
+
$existed = createSVGElement('filter', document);
|
|
2365
|
+
$existed.setAttribute('filterUnits', 'userSpaceOnUse'); // @see https://github.com/antvis/g/issues/1025
|
|
2299
2366
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2367
|
+
$existed.setAttribute('x', '0%');
|
|
2368
|
+
$existed.setAttribute('y', '0%');
|
|
2369
|
+
$existed.setAttribute('width', '100%');
|
|
2370
|
+
$existed.setAttribute('height', '100%');
|
|
2371
|
+
$existed.id = filterId;
|
|
2372
|
+
$def.appendChild($existed);
|
|
2304
2373
|
}
|
|
2374
|
+
/**
|
|
2375
|
+
* <rect id="wave-rect" x="0" y="0" width="100%" height="100%" fill="url(#wave)"></rect>
|
|
2376
|
+
* <filter id="blend-it" x="0%" y="0%" width="100%" height="100%">
|
|
2377
|
+
<feImage xlink:href="#wave-rect" result="myWave" x="100" y="100"/>
|
|
2378
|
+
<feImage xlink:href="#ry-rect" result="myRY" x="100" y="100"/>
|
|
2379
|
+
<feBlend in="myWave" in2="myRY" mode="multiply" result="blendedGrad"/>
|
|
2380
|
+
<feComposite in="blendedGrad" in2="SourceGraphic" operator="in"/>
|
|
2381
|
+
</filter>
|
|
2382
|
+
*/
|
|
2305
2383
|
|
|
2306
|
-
function pushTryEntry(locs) {
|
|
2307
|
-
var entry = {
|
|
2308
|
-
tryLoc: locs[0]
|
|
2309
|
-
};
|
|
2310
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
2311
|
-
}
|
|
2312
2384
|
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2385
|
+
var blended = 0;
|
|
2386
|
+
gradients.forEach(function (gradient, i) {
|
|
2387
|
+
var gradientId = createOrUpdateGradient(document, object, $def, $el, gradient);
|
|
2388
|
+
var rectId = gradientId + '_rect';
|
|
2389
|
+
var $rect = createSVGElement('rect', document);
|
|
2390
|
+
$rect.setAttribute('x', '0');
|
|
2391
|
+
$rect.setAttribute('y', '0');
|
|
2392
|
+
$rect.setAttribute('width', '100%');
|
|
2393
|
+
$rect.setAttribute('height', '100%');
|
|
2394
|
+
$rect.setAttribute('fill', "url(#" + gradientId + ")");
|
|
2395
|
+
$rect.id = rectId;
|
|
2396
|
+
$def.appendChild($rect);
|
|
2397
|
+
var $feImage = createSVGElement('feImage', document);
|
|
2398
|
+
$feImage.setAttribute('href', "#" + rectId);
|
|
2399
|
+
$feImage.setAttribute('result', filterId + "-" + i);
|
|
2400
|
+
$existed.appendChild($feImage);
|
|
2317
2401
|
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2402
|
+
if (i > 0) {
|
|
2403
|
+
var $feBlend = createSVGElement('feBlend', document);
|
|
2404
|
+
$feBlend.setAttribute('in', i === 1 ? filterId + "-" + (i - 1) : filterId + "-blended-" + (blended - 1));
|
|
2405
|
+
$feBlend.setAttribute('in2', filterId + "-" + i);
|
|
2406
|
+
$feBlend.setAttribute('result', filterId + "-blended-" + blended++); // @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
|
|
2407
|
+
|
|
2408
|
+
$feBlend.setAttribute('mode', 'multiply');
|
|
2409
|
+
$existed.appendChild($feBlend);
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
2413
|
+
$feComposite.setAttribute('in', filterId + "-blended-" + blended);
|
|
2414
|
+
$feComposite.setAttribute('in2', 'SourceGraphic');
|
|
2415
|
+
$feComposite.setAttribute('operator', 'in');
|
|
2416
|
+
$existed.appendChild($feComposite);
|
|
2417
|
+
return filterId;
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
var FILTER_DROPSHADOW_PREFIX = 'g-filter-dropshadow-';
|
|
2421
|
+
/**
|
|
2422
|
+
* use SVG filters
|
|
2423
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/filter
|
|
2424
|
+
*/
|
|
2425
|
+
|
|
2426
|
+
function createOrUpdateShadow(document, $def, object, $el, name) {
|
|
2427
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
2428
|
+
shadowType = _object$parsedStyle.shadowType,
|
|
2429
|
+
shadowBlur = _object$parsedStyle.shadowBlur,
|
|
2430
|
+
shadowColor = _object$parsedStyle.shadowColor,
|
|
2431
|
+
shadowOffsetX = _object$parsedStyle.shadowOffsetX,
|
|
2432
|
+
shadowOffsetY = _object$parsedStyle.shadowOffsetY;
|
|
2433
|
+
var hasShadow = !g.isNil(shadowColor) && (shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) > 0;
|
|
2434
|
+
var shadowId = FILTER_DROPSHADOW_PREFIX + object.entity;
|
|
2435
|
+
var $existedFilter = $def.querySelector("#" + shadowId);
|
|
2436
|
+
|
|
2437
|
+
if ($existedFilter) {
|
|
2438
|
+
var existedShadowType = $existedFilter.getAttribute('data-type');
|
|
2439
|
+
|
|
2440
|
+
if (existedShadowType !== shadowType.value || !hasShadow) {
|
|
2441
|
+
// remove existed shadow
|
|
2442
|
+
$existedFilter.remove();
|
|
2443
|
+
$existedFilter = null;
|
|
2444
|
+
}
|
|
2445
|
+
} // <Group> also has shadowType as its default value
|
|
2446
|
+
// only apply shadow when blur > 0
|
|
2447
|
+
|
|
2448
|
+
|
|
2449
|
+
if (hasShadow) {
|
|
2450
|
+
// use filter <feDropShadow>
|
|
2451
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow
|
|
2452
|
+
$el === null || $el === void 0 ? void 0 : $el.setAttribute('filter', "url(#" + shadowId + ")");
|
|
2453
|
+
} else {
|
|
2454
|
+
$el === null || $el === void 0 ? void 0 : $el.removeAttribute('filter');
|
|
2455
|
+
return;
|
|
2322
2456
|
}
|
|
2323
2457
|
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2458
|
+
if (!$existedFilter) {
|
|
2459
|
+
$existedFilter = createSVGElement('filter', document);
|
|
2460
|
+
$existedFilter.setAttribute('data-type', shadowType.value);
|
|
2461
|
+
|
|
2462
|
+
if (shadowType.value === 'outer') {
|
|
2463
|
+
var $feDropShadow = createSVGElement('feDropShadow', document);
|
|
2464
|
+
$feDropShadow.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2465
|
+
$feDropShadow.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2466
|
+
$feDropShadow.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2467
|
+
$feDropShadow.setAttribute('flood-color', shadowColor.toString());
|
|
2468
|
+
$existedFilter.appendChild($feDropShadow);
|
|
2469
|
+
} else if (shadowType.value === 'inner') {
|
|
2470
|
+
var $feComponentTransfer = createSVGElement('feComponentTransfer', document);
|
|
2471
|
+
$feComponentTransfer.setAttribute('in', 'SourceAlpha');
|
|
2472
|
+
var $feFuncA = createSVGElement('feFuncA', document);
|
|
2473
|
+
$feFuncA.setAttribute('type', 'table');
|
|
2474
|
+
$feFuncA.setAttribute('tableValues', '1 0');
|
|
2475
|
+
$feComponentTransfer.appendChild($feFuncA);
|
|
2476
|
+
$existedFilter.appendChild($feComponentTransfer);
|
|
2477
|
+
var $feGaussianBlur = createSVGElement('feGaussianBlur', document);
|
|
2478
|
+
$feGaussianBlur.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2479
|
+
$existedFilter.appendChild($feGaussianBlur);
|
|
2480
|
+
var $feOffset = createSVGElement('feOffset', document);
|
|
2481
|
+
$feOffset.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2482
|
+
$feOffset.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2483
|
+
$feOffset.setAttribute('result', 'offsetblur');
|
|
2484
|
+
$existedFilter.appendChild($feOffset);
|
|
2485
|
+
var $feFlood = createSVGElement('feFlood', document);
|
|
2486
|
+
$feFlood.setAttribute('flood-color', shadowColor.toString());
|
|
2487
|
+
$feFlood.setAttribute('result', 'color');
|
|
2488
|
+
$existedFilter.appendChild($feFlood);
|
|
2489
|
+
var $feComposite = createSVGElement('feComposite', document);
|
|
2490
|
+
$feComposite.setAttribute('in2', 'offsetblur');
|
|
2491
|
+
$feComposite.setAttribute('operator', 'in');
|
|
2492
|
+
$existedFilter.appendChild($feComposite);
|
|
2493
|
+
var $feComposite2 = createSVGElement('feComposite', document);
|
|
2494
|
+
$feComposite2.setAttribute('in2', 'SourceAlpha');
|
|
2495
|
+
$feComposite2.setAttribute('operator', 'in');
|
|
2496
|
+
$existedFilter.appendChild($feComposite2);
|
|
2497
|
+
var $feMerge = createSVGElement('feMerge', document);
|
|
2498
|
+
$existedFilter.appendChild($feMerge);
|
|
2499
|
+
var $feMergeNode = createSVGElement('feMergeNode', document);
|
|
2500
|
+
$feMergeNode.setAttribute('in', 'SourceGraphic');
|
|
2501
|
+
var $feMergeNode2 = createSVGElement('feMergeNode', document);
|
|
2502
|
+
$feMerge.appendChild($feMergeNode);
|
|
2503
|
+
$feMerge.appendChild($feMergeNode2);
|
|
2504
|
+
}
|
|
2329
2505
|
|
|
2330
|
-
|
|
2331
|
-
var i = -1,
|
|
2332
|
-
next = function next() {
|
|
2333
|
-
for (; ++i < iterable.length;) {
|
|
2334
|
-
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
2335
|
-
}
|
|
2506
|
+
$existedFilter.id = shadowId; // @see https://github.com/antvis/g/issues/1025
|
|
2336
2507
|
|
|
2337
|
-
|
|
2338
|
-
|
|
2508
|
+
$existedFilter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
2509
|
+
$def.appendChild($existedFilter);
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2339
2512
|
|
|
2340
|
-
|
|
2341
|
-
|
|
2513
|
+
if (shadowType.value === 'inner') {
|
|
2514
|
+
var _$feGaussianBlur = $existedFilter.children[1];
|
|
2515
|
+
var _$feOffset = $existedFilter.children[2];
|
|
2516
|
+
var _$feFlood = $existedFilter.children[3];
|
|
2517
|
+
|
|
2518
|
+
if (name === 'shadowColor') {
|
|
2519
|
+
_$feFlood.setAttribute('flood-color', shadowColor.toString());
|
|
2520
|
+
} else if (name === 'shadowBlur') {
|
|
2521
|
+
// half the blur radius
|
|
2522
|
+
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2523
|
+
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2524
|
+
_$feGaussianBlur.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2525
|
+
} else if (name === 'shadowOffsetX') {
|
|
2526
|
+
_$feOffset.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2527
|
+
} else if (name === 'shadowOffsetY') {
|
|
2528
|
+
_$feOffset.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2529
|
+
}
|
|
2530
|
+
} else if (shadowType.value === 'outer') {
|
|
2531
|
+
var _$feDropShadow = $existedFilter.children[0];
|
|
2532
|
+
|
|
2533
|
+
if (name === 'shadowColor') {
|
|
2534
|
+
_$feDropShadow.setAttribute('flood-color', shadowColor.toString());
|
|
2535
|
+
} else if (name === 'shadowBlur') {
|
|
2536
|
+
// half the blur radius
|
|
2537
|
+
// @see https://drafts.csswg.org/css-backgrounds/#shadow-blur
|
|
2538
|
+
// @see https://css-tricks.com/breaking-css-box-shadow-vs-drop-shadow/
|
|
2539
|
+
_$feDropShadow.setAttribute('stdDeviation', "" + ((shadowBlur === null || shadowBlur === void 0 ? void 0 : shadowBlur.value) || 0) / 4);
|
|
2540
|
+
} else if (name === 'shadowOffsetX') {
|
|
2541
|
+
_$feDropShadow.setAttribute('dx', "" + ((shadowOffsetX === null || shadowOffsetX === void 0 ? void 0 : shadowOffsetX.value) || 0) / 2);
|
|
2542
|
+
} else if (name === 'shadowOffsetY') {
|
|
2543
|
+
_$feDropShadow.setAttribute('dy', "" + ((shadowOffsetY === null || shadowOffsetY === void 0 ? void 0 : shadowOffsetY.value) || 0) / 2);
|
|
2342
2544
|
}
|
|
2343
|
-
|
|
2344
|
-
return {
|
|
2345
|
-
next: doneResult
|
|
2346
|
-
};
|
|
2347
2545
|
}
|
|
2546
|
+
}
|
|
2348
2547
|
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2548
|
+
var urlRegexp = /url\(#(.*)\)/;
|
|
2549
|
+
|
|
2550
|
+
var DefElementManager = /*#__PURE__*/function () {
|
|
2551
|
+
function DefElementManager() {
|
|
2552
|
+
this.canvasConfig = void 0;
|
|
2553
|
+
this.contextService = void 0;
|
|
2554
|
+
this.$def = void 0;
|
|
2555
|
+
this.gradientCache = {};
|
|
2354
2556
|
}
|
|
2355
2557
|
|
|
2356
|
-
|
|
2357
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
2358
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
2359
|
-
}, exports.mark = function (genFun) {
|
|
2360
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
2361
|
-
}, exports.awrap = function (arg) {
|
|
2362
|
-
return {
|
|
2363
|
-
__await: arg
|
|
2364
|
-
};
|
|
2365
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
2366
|
-
return this;
|
|
2367
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
2368
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
2369
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
2370
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
2371
|
-
return result.done ? result.value : iter.next();
|
|
2372
|
-
});
|
|
2373
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
2374
|
-
return this;
|
|
2375
|
-
}), define(Gp, "toString", function () {
|
|
2376
|
-
return "[object Generator]";
|
|
2377
|
-
}), exports.keys = function (object) {
|
|
2378
|
-
var keys = [];
|
|
2558
|
+
var _proto = DefElementManager.prototype;
|
|
2379
2559
|
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2560
|
+
_proto.getDefElement = function getDefElement() {
|
|
2561
|
+
return this.$def;
|
|
2562
|
+
};
|
|
2383
2563
|
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2564
|
+
_proto.init = function init() {
|
|
2565
|
+
var document = this.canvasConfig.document;
|
|
2566
|
+
var $svg = this.contextService.getContext();
|
|
2567
|
+
this.$def = createSVGElement('defs', document);
|
|
2568
|
+
$svg.appendChild(this.$def);
|
|
2569
|
+
};
|
|
2389
2570
|
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
}, exports.values = values, Context.prototype = {
|
|
2393
|
-
constructor: Context,
|
|
2394
|
-
reset: function reset(skipTempReset) {
|
|
2395
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
2396
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
2397
|
-
}
|
|
2398
|
-
},
|
|
2399
|
-
stop: function stop() {
|
|
2400
|
-
this.done = !0;
|
|
2401
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
2402
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
2403
|
-
return this.rval;
|
|
2404
|
-
},
|
|
2405
|
-
dispatchException: function dispatchException(exception) {
|
|
2406
|
-
if (this.done) throw exception;
|
|
2407
|
-
var context = this;
|
|
2571
|
+
_proto.clear = function clear(entity) {
|
|
2572
|
+
var _this = this;
|
|
2408
2573
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2574
|
+
Object.keys(this.gradientCache).forEach(function (id) {
|
|
2575
|
+
_this.clearUnusedDefElement(_this.gradientCache, id, entity);
|
|
2576
|
+
});
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2579
|
+
_proto.clearUnusedDefElement = function clearUnusedDefElement(cache, id, entity) {
|
|
2580
|
+
if (cache[id] && cache[id].size === 1 && cache[id].has(entity)) {
|
|
2581
|
+
var targetElement = this.$def.querySelector("#" + id);
|
|
2582
|
+
|
|
2583
|
+
if (targetElement) {
|
|
2584
|
+
this.$def.removeChild(targetElement);
|
|
2411
2585
|
}
|
|
2586
|
+
}
|
|
2587
|
+
};
|
|
2412
2588
|
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2589
|
+
_proto.createOrUpdateGradientAndPattern = function createOrUpdateGradientAndPattern$1(object, $el, parsedColor, name) {
|
|
2590
|
+
var _this$canvasConfig = this.canvasConfig,
|
|
2591
|
+
doc = _this$canvasConfig.document,
|
|
2592
|
+
createImage = _this$canvasConfig.createImage;
|
|
2417
2593
|
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
2594
|
+
if ($el) {
|
|
2595
|
+
var _$el$getAttribute; // `url(#${gradientId})`
|
|
2421
2596
|
|
|
2422
|
-
if (hasCatch && hasFinally) {
|
|
2423
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
2424
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
2425
|
-
} else if (hasCatch) {
|
|
2426
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
2427
|
-
} else {
|
|
2428
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
2429
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
},
|
|
2434
|
-
abrupt: function abrupt(type, arg) {
|
|
2435
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2436
|
-
var entry = this.tryEntries[i];
|
|
2437
2597
|
|
|
2438
|
-
|
|
2439
|
-
var finallyEntry = entry;
|
|
2440
|
-
break;
|
|
2441
|
-
}
|
|
2442
|
-
}
|
|
2598
|
+
var matches = (_$el$getAttribute = $el.getAttribute(name)) === null || _$el$getAttribute === void 0 ? void 0 : _$el$getAttribute.match(urlRegexp);
|
|
2443
2599
|
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
2447
|
-
},
|
|
2448
|
-
complete: function complete(record, afterLoc) {
|
|
2449
|
-
if ("throw" === record.type) throw record.arg;
|
|
2450
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
2451
|
-
},
|
|
2452
|
-
finish: function finish(finallyLoc) {
|
|
2453
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2454
|
-
var entry = this.tryEntries[i];
|
|
2455
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
2600
|
+
if (matches && matches.length > 1) {
|
|
2601
|
+
this.clearUnusedDefElement(this.gradientCache, matches[1], object.entity);
|
|
2456
2602
|
}
|
|
2457
|
-
},
|
|
2458
|
-
catch: function _catch(tryLoc) {
|
|
2459
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2460
|
-
var entry = this.tryEntries[i];
|
|
2461
2603
|
|
|
2462
|
-
|
|
2463
|
-
var record = entry.completion;
|
|
2464
|
-
|
|
2465
|
-
if ("throw" === record.type) {
|
|
2466
|
-
var thrown = record.arg;
|
|
2467
|
-
resetTryEntry(entry);
|
|
2468
|
-
}
|
|
2604
|
+
var newDefElementId = createOrUpdateGradientAndPattern(doc || document, this.$def, object, $el, parsedColor, name, createImage);
|
|
2469
2605
|
|
|
2470
|
-
|
|
2471
|
-
|
|
2606
|
+
if (!this.gradientCache[newDefElementId]) {
|
|
2607
|
+
this.gradientCache[newDefElementId] = new Set();
|
|
2472
2608
|
}
|
|
2473
2609
|
|
|
2474
|
-
|
|
2475
|
-
},
|
|
2476
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
2477
|
-
return this.delegate = {
|
|
2478
|
-
iterator: values(iterable),
|
|
2479
|
-
resultName: resultName,
|
|
2480
|
-
nextLoc: nextLoc
|
|
2481
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
2610
|
+
this.gradientCache[newDefElementId].add(object.entity);
|
|
2482
2611
|
}
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2612
|
+
};
|
|
2485
2613
|
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
} catch (error) {
|
|
2491
|
-
reject(error);
|
|
2492
|
-
return;
|
|
2493
|
-
}
|
|
2614
|
+
_proto.createOrUpdateShadow = function createOrUpdateShadow$1(object, $el, name) {
|
|
2615
|
+
var doc = this.canvasConfig.document;
|
|
2616
|
+
createOrUpdateShadow(doc || document, this.$def, object, $el, name);
|
|
2617
|
+
};
|
|
2494
2618
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2619
|
+
_proto.createOrUpdateFilter = function createOrUpdateFilter$1(object, $el, filters) {
|
|
2620
|
+
var doc = this.canvasConfig.document;
|
|
2621
|
+
createOrUpdateFilter(doc || document, this.$def, object, $el, filters);
|
|
2622
|
+
};
|
|
2501
2623
|
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
var self = this,
|
|
2505
|
-
args = arguments;
|
|
2506
|
-
return new Promise(function (resolve, reject) {
|
|
2507
|
-
var gen = fn.apply(self, args);
|
|
2624
|
+
return DefElementManager;
|
|
2625
|
+
}();
|
|
2508
2626
|
|
|
2509
|
-
|
|
2510
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2511
|
-
}
|
|
2627
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], DefElementManager.prototype, "canvasConfig", void 0);
|
|
2512
2628
|
|
|
2513
|
-
|
|
2514
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2515
|
-
}
|
|
2629
|
+
__decorate([g.inject(g.ContextService), __metadata("design:type", Object)], DefElementManager.prototype, "contextService", void 0);
|
|
2516
2630
|
|
|
2517
|
-
|
|
2518
|
-
});
|
|
2519
|
-
};
|
|
2520
|
-
}
|
|
2631
|
+
DefElementManager = __decorate([g.singleton()], DefElementManager);
|
|
2521
2632
|
|
|
2522
2633
|
var _class$1;
|
|
2523
2634
|
|
|
@@ -2895,7 +3006,7 @@
|
|
|
2895
3006
|
$groupEl === null || $groupEl === void 0 ? void 0 : $groupEl.setAttribute(usedName, "" + computedValue.value);
|
|
2896
3007
|
} else if (name === 'clipPath') {
|
|
2897
3008
|
_this2.createOrUpdateClipPath(document, usedValue, $groupEl);
|
|
2898
|
-
} else if (name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
3009
|
+
} else if (name === 'shadowType' || name === 'shadowColor' || name === 'shadowBlur' || name === 'shadowOffsetX' || name === 'shadowOffsetY') {
|
|
2899
3010
|
_this2.defElementManager.createOrUpdateShadow(object, $el, name);
|
|
2900
3011
|
} else if (name === 'filter') {
|
|
2901
3012
|
_this2.defElementManager.createOrUpdateFilter(object, $el, usedValue);
|
|
@@ -3134,23 +3245,33 @@
|
|
|
3134
3245
|
register(SVGRendererPlugin);
|
|
3135
3246
|
});
|
|
3136
3247
|
|
|
3137
|
-
var Plugin$1 = /*#__PURE__*/function () {
|
|
3248
|
+
var Plugin$1 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3249
|
+
_inheritsLoose$2(Plugin, _AbstractRendererPlug);
|
|
3250
|
+
|
|
3138
3251
|
function Plugin() {
|
|
3139
|
-
|
|
3252
|
+
var _this;
|
|
3253
|
+
|
|
3254
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3255
|
+
args[_key] = arguments[_key];
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
3259
|
+
_this.name = 'svg-renderer';
|
|
3260
|
+
return _this;
|
|
3140
3261
|
}
|
|
3141
3262
|
|
|
3142
3263
|
var _proto = Plugin.prototype;
|
|
3143
3264
|
|
|
3144
|
-
_proto.init = function init(
|
|
3145
|
-
container.load(containerModule$1, true);
|
|
3265
|
+
_proto.init = function init() {
|
|
3266
|
+
this.container.load(containerModule$1, true);
|
|
3146
3267
|
};
|
|
3147
3268
|
|
|
3148
|
-
_proto.destroy = function destroy(
|
|
3149
|
-
container.unload(containerModule$1);
|
|
3269
|
+
_proto.destroy = function destroy() {
|
|
3270
|
+
this.container.unload(containerModule$1);
|
|
3150
3271
|
};
|
|
3151
3272
|
|
|
3152
3273
|
return Plugin;
|
|
3153
|
-
}();
|
|
3274
|
+
}(g.AbstractRendererPlugin);
|
|
3154
3275
|
|
|
3155
3276
|
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
3156
3277
|
__proto__: null,
|
|
@@ -3560,6 +3681,21 @@
|
|
|
3560
3681
|
};
|
|
3561
3682
|
}
|
|
3562
3683
|
|
|
3684
|
+
function _inheritsLoose$3(subClass, superClass) {
|
|
3685
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
3686
|
+
subClass.prototype.constructor = subClass;
|
|
3687
|
+
|
|
3688
|
+
_setPrototypeOf$3(subClass, superClass);
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
function _setPrototypeOf$3(o, p) {
|
|
3692
|
+
_setPrototypeOf$3 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
3693
|
+
o.__proto__ = p;
|
|
3694
|
+
return o;
|
|
3695
|
+
};
|
|
3696
|
+
return _setPrototypeOf$3(o, p);
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3563
3699
|
function _unsupportedIterableToArray(o, minLen) {
|
|
3564
3700
|
if (!o) return;
|
|
3565
3701
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -3714,23 +3850,33 @@
|
|
|
3714
3850
|
register(SVGPickerPlugin);
|
|
3715
3851
|
});
|
|
3716
3852
|
|
|
3717
|
-
var Plugin$2 = /*#__PURE__*/function () {
|
|
3853
|
+
var Plugin$2 = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
3854
|
+
_inheritsLoose$3(Plugin, _AbstractRendererPlug);
|
|
3855
|
+
|
|
3718
3856
|
function Plugin() {
|
|
3719
|
-
|
|
3857
|
+
var _this;
|
|
3858
|
+
|
|
3859
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3860
|
+
args[_key] = arguments[_key];
|
|
3861
|
+
}
|
|
3862
|
+
|
|
3863
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
3864
|
+
_this.name = 'svg-picker';
|
|
3865
|
+
return _this;
|
|
3720
3866
|
}
|
|
3721
3867
|
|
|
3722
3868
|
var _proto = Plugin.prototype;
|
|
3723
3869
|
|
|
3724
|
-
_proto.init = function init(
|
|
3725
|
-
container.load(containerModule$2, true);
|
|
3870
|
+
_proto.init = function init() {
|
|
3871
|
+
this.container.load(containerModule$2, true);
|
|
3726
3872
|
};
|
|
3727
3873
|
|
|
3728
|
-
_proto.destroy = function destroy(
|
|
3729
|
-
container.unload(containerModule$2);
|
|
3874
|
+
_proto.destroy = function destroy() {
|
|
3875
|
+
this.container.unload(containerModule$2);
|
|
3730
3876
|
};
|
|
3731
3877
|
|
|
3732
3878
|
return Plugin;
|
|
3733
|
-
}();
|
|
3879
|
+
}(g.AbstractRendererPlugin);
|
|
3734
3880
|
|
|
3735
3881
|
var index_esm$2 = /*#__PURE__*/Object.freeze({
|
|
3736
3882
|
__proto__: null,
|
|
@@ -3873,23 +4019,33 @@
|
|
|
3873
4019
|
*/
|
|
3874
4020
|
register(SVGContextService);
|
|
3875
4021
|
});
|
|
3876
|
-
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
4022
|
+
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
4023
|
+
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
4024
|
+
|
|
3877
4025
|
function ContextRegisterPlugin() {
|
|
3878
|
-
|
|
4026
|
+
var _this;
|
|
4027
|
+
|
|
4028
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4029
|
+
args[_key] = arguments[_key];
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
4033
|
+
_this.name = 'svg-context-register';
|
|
4034
|
+
return _this;
|
|
3879
4035
|
}
|
|
3880
4036
|
|
|
3881
4037
|
var _proto = ContextRegisterPlugin.prototype;
|
|
3882
4038
|
|
|
3883
|
-
_proto.init = function init(
|
|
3884
|
-
container.load(containerModule$3, true);
|
|
4039
|
+
_proto.init = function init() {
|
|
4040
|
+
this.container.load(containerModule$3, true);
|
|
3885
4041
|
};
|
|
3886
4042
|
|
|
3887
|
-
_proto.destroy = function destroy(
|
|
3888
|
-
container.unload(containerModule$3);
|
|
4043
|
+
_proto.destroy = function destroy() {
|
|
4044
|
+
this.container.unload(containerModule$3);
|
|
3889
4045
|
};
|
|
3890
4046
|
|
|
3891
4047
|
return ContextRegisterPlugin;
|
|
3892
|
-
}();
|
|
4048
|
+
}(g.AbstractRendererPlugin);
|
|
3893
4049
|
|
|
3894
4050
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
3895
4051
|
_inheritsLoose(Renderer, _AbstractRenderer);
|