@antv/g-canvas 1.9.14 → 1.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +89 -180
- package/dist/index.js +89 -180
- package/dist/index.umd.js +3287 -4034
- package/dist/index.umd.min.js +1 -13
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -39,20 +39,19 @@ var HTMLRenderer__namespace = /*#__PURE__*/_interopNamespace(HTMLRenderer);
|
|
|
39
39
|
var ImageLoader__namespace = /*#__PURE__*/_interopNamespace(ImageLoader);
|
|
40
40
|
|
|
41
41
|
function _regeneratorRuntime() {
|
|
42
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
43
|
-
|
|
44
42
|
_regeneratorRuntime = function () {
|
|
45
43
|
return exports;
|
|
46
44
|
};
|
|
47
|
-
|
|
48
45
|
var exports = {},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
Op = Object.prototype,
|
|
47
|
+
hasOwn = Op.hasOwnProperty,
|
|
48
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
49
|
+
obj[key] = desc.value;
|
|
50
|
+
},
|
|
51
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
52
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
53
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
54
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
56
55
|
function define(obj, key, value) {
|
|
57
56
|
return Object.defineProperty(obj, key, {
|
|
58
57
|
value: value,
|
|
@@ -61,7 +60,6 @@ function _regeneratorRuntime() {
|
|
|
61
60
|
writable: !0
|
|
62
61
|
}), obj[key];
|
|
63
62
|
}
|
|
64
|
-
|
|
65
63
|
try {
|
|
66
64
|
define({}, "");
|
|
67
65
|
} catch (err) {
|
|
@@ -69,54 +67,14 @@ function _regeneratorRuntime() {
|
|
|
69
67
|
return obj[key] = value;
|
|
70
68
|
};
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
74
71
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return generator
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
81
|
-
|
|
82
|
-
if ("completed" === state) {
|
|
83
|
-
if ("throw" === method) throw arg;
|
|
84
|
-
return doneResult();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
for (context.method = method, context.arg = arg;;) {
|
|
88
|
-
var delegate = context.delegate;
|
|
89
|
-
|
|
90
|
-
if (delegate) {
|
|
91
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
92
|
-
|
|
93
|
-
if (delegateResult) {
|
|
94
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
95
|
-
return delegateResult;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
100
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
101
|
-
context.dispatchException(context.arg);
|
|
102
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
103
|
-
state = "executing";
|
|
104
|
-
var record = tryCatch(innerFn, self, context);
|
|
105
|
-
|
|
106
|
-
if ("normal" === record.type) {
|
|
107
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
108
|
-
return {
|
|
109
|
-
value: record.arg,
|
|
110
|
-
done: context.done
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}(innerFn, self, context), generator;
|
|
72
|
+
generator = Object.create(protoGenerator.prototype),
|
|
73
|
+
context = new Context(tryLocsList || []);
|
|
74
|
+
return defineProperty(generator, "_invoke", {
|
|
75
|
+
value: makeInvokeMethod(innerFn, self, context)
|
|
76
|
+
}), generator;
|
|
118
77
|
}
|
|
119
|
-
|
|
120
78
|
function tryCatch(fn, obj, arg) {
|
|
121
79
|
try {
|
|
122
80
|
return {
|
|
@@ -130,25 +88,19 @@ function _regeneratorRuntime() {
|
|
|
130
88
|
};
|
|
131
89
|
}
|
|
132
90
|
}
|
|
133
|
-
|
|
134
91
|
exports.wrap = wrap;
|
|
135
92
|
var ContinueSentinel = {};
|
|
136
|
-
|
|
137
93
|
function Generator() {}
|
|
138
|
-
|
|
139
94
|
function GeneratorFunction() {}
|
|
140
|
-
|
|
141
95
|
function GeneratorFunctionPrototype() {}
|
|
142
|
-
|
|
143
96
|
var IteratorPrototype = {};
|
|
144
97
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
145
98
|
return this;
|
|
146
99
|
});
|
|
147
100
|
var getProto = Object.getPrototypeOf,
|
|
148
|
-
|
|
101
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
149
102
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
150
103
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
151
|
-
|
|
152
104
|
function defineIteratorMethods(prototype) {
|
|
153
105
|
["next", "throw", "return"].forEach(function (method) {
|
|
154
106
|
define(prototype, method, function (arg) {
|
|
@@ -156,14 +108,12 @@ function _regeneratorRuntime() {
|
|
|
156
108
|
});
|
|
157
109
|
});
|
|
158
110
|
}
|
|
159
|
-
|
|
160
111
|
function AsyncIterator(generator, PromiseImpl) {
|
|
161
112
|
function invoke(method, arg, resolve, reject) {
|
|
162
113
|
var record = tryCatch(generator[method], generator, arg);
|
|
163
|
-
|
|
164
114
|
if ("throw" !== record.type) {
|
|
165
115
|
var result = record.arg,
|
|
166
|
-
|
|
116
|
+
value = result.value;
|
|
167
117
|
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
168
118
|
invoke("next", value, resolve, reject);
|
|
169
119
|
}, function (err) {
|
|
@@ -174,90 +124,114 @@ function _regeneratorRuntime() {
|
|
|
174
124
|
return invoke("throw", error, resolve, reject);
|
|
175
125
|
});
|
|
176
126
|
}
|
|
177
|
-
|
|
178
127
|
reject(record.arg);
|
|
179
128
|
}
|
|
180
|
-
|
|
181
129
|
var previousPromise;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
130
|
+
defineProperty(this, "_invoke", {
|
|
131
|
+
value: function (method, arg) {
|
|
132
|
+
function callInvokeWithMethodAndArg() {
|
|
133
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
134
|
+
invoke(method, arg, resolve, reject);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
142
|
+
var state = "suspendedStart";
|
|
143
|
+
return function (method, arg) {
|
|
144
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
145
|
+
if ("completed" === state) {
|
|
146
|
+
if ("throw" === method) throw arg;
|
|
147
|
+
return doneResult();
|
|
148
|
+
}
|
|
149
|
+
for (context.method = method, context.arg = arg;;) {
|
|
150
|
+
var delegate = context.delegate;
|
|
151
|
+
if (delegate) {
|
|
152
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
153
|
+
if (delegateResult) {
|
|
154
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
155
|
+
return delegateResult;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
159
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
160
|
+
context.dispatchException(context.arg);
|
|
161
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
162
|
+
state = "executing";
|
|
163
|
+
var record = tryCatch(innerFn, self, context);
|
|
164
|
+
if ("normal" === record.type) {
|
|
165
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
166
|
+
return {
|
|
167
|
+
value: record.arg,
|
|
168
|
+
done: context.done
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
188
172
|
}
|
|
189
|
-
|
|
190
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
191
173
|
};
|
|
192
174
|
}
|
|
193
|
-
|
|
194
175
|
function maybeInvokeDelegate(delegate, context) {
|
|
195
176
|
var method = delegate.iterator[context.method];
|
|
196
|
-
|
|
197
177
|
if (undefined === method) {
|
|
198
178
|
if (context.delegate = null, "throw" === context.method) {
|
|
199
179
|
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
200
180
|
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
201
181
|
}
|
|
202
|
-
|
|
203
182
|
return ContinueSentinel;
|
|
204
183
|
}
|
|
205
|
-
|
|
206
184
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
207
185
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
208
186
|
var info = record.arg;
|
|
209
187
|
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);
|
|
210
188
|
}
|
|
211
|
-
|
|
212
189
|
function pushTryEntry(locs) {
|
|
213
190
|
var entry = {
|
|
214
191
|
tryLoc: locs[0]
|
|
215
192
|
};
|
|
216
193
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
217
194
|
}
|
|
218
|
-
|
|
219
195
|
function resetTryEntry(entry) {
|
|
220
196
|
var record = entry.completion || {};
|
|
221
197
|
record.type = "normal", delete record.arg, entry.completion = record;
|
|
222
198
|
}
|
|
223
|
-
|
|
224
199
|
function Context(tryLocsList) {
|
|
225
200
|
this.tryEntries = [{
|
|
226
201
|
tryLoc: "root"
|
|
227
202
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
228
203
|
}
|
|
229
|
-
|
|
230
204
|
function values(iterable) {
|
|
231
205
|
if (iterable) {
|
|
232
206
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
233
207
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
234
208
|
if ("function" == typeof iterable.next) return iterable;
|
|
235
|
-
|
|
236
209
|
if (!isNaN(iterable.length)) {
|
|
237
210
|
var i = -1,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
243
|
-
|
|
211
|
+
next = function next() {
|
|
212
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
213
|
+
return next.value = undefined, next.done = !0, next;
|
|
214
|
+
};
|
|
244
215
|
return next.next = next;
|
|
245
216
|
}
|
|
246
217
|
}
|
|
247
|
-
|
|
248
218
|
return {
|
|
249
219
|
next: doneResult
|
|
250
220
|
};
|
|
251
221
|
}
|
|
252
|
-
|
|
253
222
|
function doneResult() {
|
|
254
223
|
return {
|
|
255
224
|
value: undefined,
|
|
256
225
|
done: !0
|
|
257
226
|
};
|
|
258
227
|
}
|
|
259
|
-
|
|
260
|
-
|
|
228
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
229
|
+
value: GeneratorFunctionPrototype,
|
|
230
|
+
configurable: !0
|
|
231
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
232
|
+
value: GeneratorFunction,
|
|
233
|
+
configurable: !0
|
|
234
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
261
235
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
262
236
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
263
237
|
}, exports.mark = function (genFun) {
|
|
@@ -278,17 +252,15 @@ function _regeneratorRuntime() {
|
|
|
278
252
|
return this;
|
|
279
253
|
}), define(Gp, "toString", function () {
|
|
280
254
|
return "[object Generator]";
|
|
281
|
-
}), exports.keys = function (
|
|
282
|
-
var
|
|
283
|
-
|
|
255
|
+
}), exports.keys = function (val) {
|
|
256
|
+
var object = Object(val),
|
|
257
|
+
keys = [];
|
|
284
258
|
for (var key in object) keys.push(key);
|
|
285
|
-
|
|
286
259
|
return keys.reverse(), function next() {
|
|
287
260
|
for (; keys.length;) {
|
|
288
261
|
var key = keys.pop();
|
|
289
262
|
if (key in object) return next.value = key, next.done = !1, next;
|
|
290
263
|
}
|
|
291
|
-
|
|
292
264
|
return next.done = !0, next;
|
|
293
265
|
};
|
|
294
266
|
}, exports.values = values, Context.prototype = {
|
|
@@ -305,20 +277,16 @@ function _regeneratorRuntime() {
|
|
|
305
277
|
dispatchException: function (exception) {
|
|
306
278
|
if (this.done) throw exception;
|
|
307
279
|
var context = this;
|
|
308
|
-
|
|
309
280
|
function handle(loc, caught) {
|
|
310
281
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
311
282
|
}
|
|
312
|
-
|
|
313
283
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
314
284
|
var entry = this.tryEntries[i],
|
|
315
|
-
|
|
285
|
+
record = entry.completion;
|
|
316
286
|
if ("root" === entry.tryLoc) return handle("end");
|
|
317
|
-
|
|
318
287
|
if (entry.tryLoc <= this.prev) {
|
|
319
288
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
320
|
-
|
|
321
|
-
|
|
289
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
322
290
|
if (hasCatch && hasFinally) {
|
|
323
291
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
324
292
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
@@ -334,13 +302,11 @@ function _regeneratorRuntime() {
|
|
|
334
302
|
abrupt: function (type, arg) {
|
|
335
303
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
336
304
|
var entry = this.tryEntries[i];
|
|
337
|
-
|
|
338
305
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
339
306
|
var finallyEntry = entry;
|
|
340
307
|
break;
|
|
341
308
|
}
|
|
342
309
|
}
|
|
343
|
-
|
|
344
310
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
345
311
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
346
312
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
@@ -358,19 +324,15 @@ function _regeneratorRuntime() {
|
|
|
358
324
|
catch: function (tryLoc) {
|
|
359
325
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
360
326
|
var entry = this.tryEntries[i];
|
|
361
|
-
|
|
362
327
|
if (entry.tryLoc === tryLoc) {
|
|
363
328
|
var record = entry.completion;
|
|
364
|
-
|
|
365
329
|
if ("throw" === record.type) {
|
|
366
330
|
var thrown = record.arg;
|
|
367
331
|
resetTryEntry(entry);
|
|
368
332
|
}
|
|
369
|
-
|
|
370
333
|
return thrown;
|
|
371
334
|
}
|
|
372
335
|
}
|
|
373
|
-
|
|
374
336
|
throw new Error("illegal catch attempt");
|
|
375
337
|
},
|
|
376
338
|
delegateYield: function (iterable, resultName, nextLoc) {
|
|
@@ -382,7 +344,6 @@ function _regeneratorRuntime() {
|
|
|
382
344
|
}
|
|
383
345
|
}, exports;
|
|
384
346
|
}
|
|
385
|
-
|
|
386
347
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
387
348
|
try {
|
|
388
349
|
var info = gen[key](arg);
|
|
@@ -391,41 +352,33 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
391
352
|
reject(error);
|
|
392
353
|
return;
|
|
393
354
|
}
|
|
394
|
-
|
|
395
355
|
if (info.done) {
|
|
396
356
|
resolve(value);
|
|
397
357
|
} else {
|
|
398
358
|
Promise.resolve(value).then(_next, _throw);
|
|
399
359
|
}
|
|
400
360
|
}
|
|
401
|
-
|
|
402
361
|
function _asyncToGenerator(fn) {
|
|
403
362
|
return function () {
|
|
404
363
|
var self = this,
|
|
405
|
-
|
|
364
|
+
args = arguments;
|
|
406
365
|
return new Promise(function (resolve, reject) {
|
|
407
366
|
var gen = fn.apply(self, args);
|
|
408
|
-
|
|
409
367
|
function _next(value) {
|
|
410
368
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
411
369
|
}
|
|
412
|
-
|
|
413
370
|
function _throw(err) {
|
|
414
371
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
415
372
|
}
|
|
416
|
-
|
|
417
373
|
_next(undefined);
|
|
418
374
|
});
|
|
419
375
|
};
|
|
420
376
|
}
|
|
421
|
-
|
|
422
377
|
function _inheritsLoose(subClass, superClass) {
|
|
423
378
|
subClass.prototype = Object.create(superClass.prototype);
|
|
424
379
|
subClass.prototype.constructor = subClass;
|
|
425
|
-
|
|
426
380
|
_setPrototypeOf(subClass, superClass);
|
|
427
381
|
}
|
|
428
|
-
|
|
429
382
|
function _setPrototypeOf(o, p) {
|
|
430
383
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
431
384
|
o.__proto__ = p;
|
|
@@ -445,48 +398,37 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
445
398
|
this.renderingContext = context.renderingContext;
|
|
446
399
|
this.canvasConfig = context.config;
|
|
447
400
|
}
|
|
448
|
-
|
|
449
401
|
var _proto = Canvas2DContextService.prototype;
|
|
450
|
-
|
|
451
402
|
_proto.init = /*#__PURE__*/function () {
|
|
452
403
|
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
453
404
|
var _this$canvasConfig, container, canvas, $canvas;
|
|
454
|
-
|
|
455
405
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
456
406
|
while (1) {
|
|
457
407
|
switch (_context.prev = _context.next) {
|
|
458
408
|
case 0:
|
|
459
409
|
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
460
|
-
|
|
461
410
|
if (canvas) {
|
|
462
411
|
this.$canvas = canvas;
|
|
463
|
-
|
|
464
412
|
if (container && canvas.parentElement !== container) {
|
|
465
413
|
container.appendChild(canvas);
|
|
466
414
|
}
|
|
467
|
-
|
|
468
415
|
this.$container = canvas.parentElement;
|
|
469
416
|
this.canvasConfig.container = this.$container;
|
|
470
417
|
} else if (container) {
|
|
471
418
|
// create container
|
|
472
419
|
this.$container = util.isString(container) ? document.getElementById(container) : container;
|
|
473
|
-
|
|
474
420
|
if (this.$container) {
|
|
475
421
|
// create canvas
|
|
476
422
|
$canvas = document.createElement('canvas');
|
|
477
423
|
this.$container.appendChild($canvas);
|
|
478
|
-
|
|
479
424
|
if (!this.$container.style.position) {
|
|
480
425
|
this.$container.style.position = 'relative';
|
|
481
426
|
}
|
|
482
|
-
|
|
483
427
|
this.$canvas = $canvas;
|
|
484
428
|
}
|
|
485
429
|
}
|
|
486
|
-
|
|
487
430
|
this.context = this.$canvas.getContext('2d');
|
|
488
431
|
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
489
|
-
|
|
490
432
|
case 4:
|
|
491
433
|
case "end":
|
|
492
434
|
return _context.stop();
|
|
@@ -494,32 +436,25 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
494
436
|
}
|
|
495
437
|
}, _callee, this);
|
|
496
438
|
}));
|
|
497
|
-
|
|
498
439
|
function init() {
|
|
499
440
|
return _init.apply(this, arguments);
|
|
500
441
|
}
|
|
501
|
-
|
|
502
442
|
return init;
|
|
503
443
|
}();
|
|
504
|
-
|
|
505
444
|
_proto.getContext = function getContext() {
|
|
506
445
|
return this.context;
|
|
507
446
|
};
|
|
508
|
-
|
|
509
447
|
_proto.getDomElement = function getDomElement() {
|
|
510
448
|
return this.$canvas;
|
|
511
449
|
};
|
|
512
|
-
|
|
513
450
|
_proto.getDPR = function getDPR() {
|
|
514
451
|
return this.dpr;
|
|
515
452
|
};
|
|
516
|
-
|
|
517
453
|
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
518
454
|
if (this.$canvas.getBoundingClientRect) {
|
|
519
455
|
return this.$canvas.getBoundingClientRect();
|
|
520
456
|
}
|
|
521
457
|
};
|
|
522
|
-
|
|
523
458
|
_proto.destroy = function destroy() {
|
|
524
459
|
// @ts-ignore
|
|
525
460
|
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
@@ -528,20 +463,19 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
528
463
|
this.$container.removeChild(this.$canvas);
|
|
529
464
|
}
|
|
530
465
|
};
|
|
531
|
-
|
|
532
466
|
_proto.resize = function resize(width, height) {
|
|
533
|
-
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
534
|
-
|
|
467
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
468
|
+
// use user-defined dpr first
|
|
535
469
|
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
536
470
|
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
537
471
|
this.dpr = dpr;
|
|
538
|
-
|
|
539
472
|
if (this.$canvas) {
|
|
540
473
|
// set canvas width & height
|
|
541
474
|
this.$canvas.width = this.dpr * width;
|
|
542
|
-
this.$canvas.height = this.dpr * height;
|
|
543
|
-
|
|
544
|
-
gLite.setDOMSize(this.$canvas, width, height);
|
|
475
|
+
this.$canvas.height = this.dpr * height;
|
|
476
|
+
// set CSS style width & height
|
|
477
|
+
gLite.setDOMSize(this.$canvas, width, height);
|
|
478
|
+
// const dpr = this.getDPR();
|
|
545
479
|
// scale all drawing operations by the dpr
|
|
546
480
|
// @see https://www.html5rocks.com/en/tutorials/canvas/hidpi/
|
|
547
481
|
// this.context.scale(dpr, dpr);
|
|
@@ -549,17 +483,14 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
549
483
|
|
|
550
484
|
this.renderingContext.renderReasons.add(gLite.RenderReason.CAMERA_CHANGED);
|
|
551
485
|
};
|
|
552
|
-
|
|
553
486
|
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
554
487
|
if (this.$container && this.$container.style) {
|
|
555
488
|
this.$container.style.cursor = cursor;
|
|
556
489
|
}
|
|
557
490
|
};
|
|
558
|
-
|
|
559
491
|
_proto.toDataURL = /*#__PURE__*/function () {
|
|
560
492
|
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
561
493
|
var _options, type, encoderOptions;
|
|
562
|
-
|
|
563
494
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
564
495
|
while (1) {
|
|
565
496
|
switch (_context2.prev = _context2.next) {
|
|
@@ -567,10 +498,8 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
567
498
|
if (options === void 0) {
|
|
568
499
|
options = {};
|
|
569
500
|
}
|
|
570
|
-
|
|
571
501
|
_options = options, type = _options.type, encoderOptions = _options.encoderOptions;
|
|
572
502
|
return _context2.abrupt("return", this.context.canvas.toDataURL(type, encoderOptions));
|
|
573
|
-
|
|
574
503
|
case 3:
|
|
575
504
|
case "end":
|
|
576
505
|
return _context2.stop();
|
|
@@ -578,73 +507,53 @@ var Canvas2DContextService = /*#__PURE__*/function () {
|
|
|
578
507
|
}
|
|
579
508
|
}, _callee2, this);
|
|
580
509
|
}));
|
|
581
|
-
|
|
582
510
|
function toDataURL(_x) {
|
|
583
511
|
return _toDataURL.apply(this, arguments);
|
|
584
512
|
}
|
|
585
|
-
|
|
586
513
|
return toDataURL;
|
|
587
514
|
}();
|
|
588
|
-
|
|
589
515
|
return Canvas2DContextService;
|
|
590
516
|
}();
|
|
591
517
|
|
|
592
518
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
593
519
|
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
594
|
-
|
|
595
520
|
function ContextRegisterPlugin() {
|
|
596
521
|
var _this;
|
|
597
|
-
|
|
598
522
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
599
523
|
args[_key] = arguments[_key];
|
|
600
524
|
}
|
|
601
|
-
|
|
602
525
|
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
603
526
|
_this.name = 'canvas-context-register';
|
|
604
527
|
return _this;
|
|
605
528
|
}
|
|
606
|
-
|
|
607
529
|
var _proto = ContextRegisterPlugin.prototype;
|
|
608
|
-
|
|
609
530
|
_proto.init = function init() {
|
|
610
531
|
this.context.ContextService = Canvas2DContextService;
|
|
611
532
|
};
|
|
612
|
-
|
|
613
533
|
_proto.destroy = function destroy() {
|
|
614
534
|
delete this.context.ContextService;
|
|
615
535
|
};
|
|
616
|
-
|
|
617
536
|
return ContextRegisterPlugin;
|
|
618
537
|
}(gLite.AbstractRendererPlugin);
|
|
619
538
|
|
|
620
539
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
621
540
|
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
622
|
-
|
|
623
541
|
function Renderer(config) {
|
|
624
542
|
var _this;
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
543
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
544
|
+
// register Canvas2DContext
|
|
628
545
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
629
|
-
|
|
630
546
|
_this.registerPlugin(new ImageLoader.Plugin());
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
547
|
+
_this.registerPlugin(new CanvasPathGenerator.Plugin());
|
|
548
|
+
// enable rendering with Canvas2D API
|
|
635
549
|
_this.registerPlugin(new CanvasRenderer.Plugin());
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
_this.registerPlugin(new CanvasPicker.Plugin()); // render HTML component
|
|
641
|
-
|
|
642
|
-
|
|
550
|
+
_this.registerPlugin(new DomInteraction.Plugin());
|
|
551
|
+
// enable picking with Canvas2D API
|
|
552
|
+
_this.registerPlugin(new CanvasPicker.Plugin());
|
|
553
|
+
// render HTML component
|
|
643
554
|
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
644
|
-
|
|
645
555
|
return _this;
|
|
646
556
|
}
|
|
647
|
-
|
|
648
557
|
return Renderer;
|
|
649
558
|
}(gLite.AbstractRenderer);
|
|
650
559
|
|