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