jmgraph 3.2.1 → 3.2.3
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/README.md +4 -4
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +3077 -362
- package/dist/jmgraph.min.js +1 -1
- package/index.js +4 -0
- package/package.json +4 -4
- package/src/core/jmControl.js +97 -57
- package/src/core/jmGradient.js +29 -14
- package/src/core/jmGraph.js +71 -26
- package/src/core/jmObject.js +2 -3
- package/src/core/jmPath.js +19 -3
- package/src/core/jmProperty.js +29 -14
- package/src/core/jmUtils.js +218 -31
- package/src/lib/earcut.js +680 -0
- package/src/lib/earcut.md +73 -0
- package/src/lib/webgl/base.js +201 -0
- package/src/lib/webgl/core/buffer.js +48 -0
- package/src/lib/webgl/core/mapSize.js +40 -0
- package/src/lib/webgl/core/mapType.js +43 -0
- package/src/lib/webgl/core/program.js +139 -0
- package/src/lib/webgl/core/shader.js +14 -0
- package/src/lib/webgl/core/texture.js +61 -0
- package/src/lib/webgl/gradient.js +196 -0
- package/src/lib/webgl/index.js +11 -0
- package/src/lib/webgl/path.js +679 -0
- package/src/shapes/jmArc.js +15 -11
- package/src/shapes/jmArrow.js +10 -10
- package/src/shapes/jmBezier.js +2 -2
- package/src/shapes/jmCircle.js +8 -1
- package/src/shapes/jmHArc.js +17 -15
- package/src/shapes/jmImage.js +68 -38
- package/src/shapes/jmLabel.js +11 -10
- package/src/shapes/jmLine.js +20 -12
- package/src/shapes/jmPrismatic.js +4 -2
- package/src/shapes/jmRect.js +5 -4
- package/src/shapes/jmResize.js +6 -4
package/dist/jmgraph.js
CHANGED
|
@@ -146,6 +146,10 @@ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _c
|
|
|
146
146
|
|
|
147
147
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
148
148
|
|
|
149
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
150
|
+
|
|
151
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
152
|
+
|
|
149
153
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
150
154
|
|
|
151
155
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -206,6 +210,13 @@ var jmGraph = /*#__PURE__*/function (_jmGraphCore) {
|
|
|
206
210
|
return _super.call(this, canvas, option, callback);
|
|
207
211
|
}
|
|
208
212
|
|
|
213
|
+
_createClass(jmGraph, null, [{
|
|
214
|
+
key: "create",
|
|
215
|
+
value: function create() {
|
|
216
|
+
return createJmGraph.apply(void 0, arguments);
|
|
217
|
+
}
|
|
218
|
+
}]);
|
|
219
|
+
|
|
209
220
|
return jmGraph;
|
|
210
221
|
}(_jmGraph.jmGraph); //创建实例
|
|
211
222
|
|
|
@@ -222,7 +233,7 @@ var createJmGraph = function createJmGraph() {
|
|
|
222
233
|
|
|
223
234
|
exports.create = createJmGraph;
|
|
224
235
|
|
|
225
|
-
},{"./src/core/jmGraph.js":5,"./src/shapes/jmArc.js":
|
|
236
|
+
},{"./src/core/jmGraph.js":5,"./src/shapes/jmArc.js":22,"./src/shapes/jmArrow.js":23,"./src/shapes/jmArrowLine.js":24,"./src/shapes/jmBezier.js":25,"./src/shapes/jmCircle.js":26,"./src/shapes/jmHArc.js":27,"./src/shapes/jmImage.js":28,"./src/shapes/jmLabel.js":29,"./src/shapes/jmLine.js":30,"./src/shapes/jmPrismatic.js":31,"./src/shapes/jmRect.js":32,"./src/shapes/jmResize.js":33}],2:[function(require,module,exports){
|
|
226
237
|
"use strict";
|
|
227
238
|
|
|
228
239
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -240,10 +251,22 @@ var _jmShadow = require("./jmShadow.js");
|
|
|
240
251
|
|
|
241
252
|
var _jmProperty2 = require("./jmProperty.js");
|
|
242
253
|
|
|
254
|
+
var _path = _interopRequireDefault(require("../lib/webgl/path.js"));
|
|
255
|
+
|
|
256
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
257
|
+
|
|
243
258
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
244
259
|
|
|
260
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
261
|
+
|
|
262
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
263
|
+
|
|
245
264
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
246
265
|
|
|
266
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
267
|
+
|
|
268
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
269
|
+
|
|
247
270
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
248
271
|
|
|
249
272
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -271,6 +294,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
271
294
|
//样式名称,也当做白名单使用
|
|
272
295
|
var jmStyleMap = {
|
|
273
296
|
'fill': 'fillStyle',
|
|
297
|
+
'fillImage': 'fillImage',
|
|
274
298
|
'stroke': 'strokeStyle',
|
|
275
299
|
'shadow.blur': 'shadowBlur',
|
|
276
300
|
'shadow.x': 'shadowOffsetX',
|
|
@@ -312,9 +336,9 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
312
336
|
_classCallCheck(this, jmControl);
|
|
313
337
|
|
|
314
338
|
params = params || {};
|
|
315
|
-
_this2 = _super.call(this);
|
|
339
|
+
_this2 = _super.call(this, params);
|
|
316
340
|
|
|
317
|
-
_this2.
|
|
341
|
+
_this2.property('type', t || (this instanceof jmControl ? this.constructor : void 0).name);
|
|
318
342
|
|
|
319
343
|
_this2.style = params && params.style ? params.style : {}; //this.position = params.position || {x:0,y:0};
|
|
320
344
|
|
|
@@ -327,7 +351,15 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
327
351
|
|
|
328
352
|
_this2.graph = params.graph || null;
|
|
329
353
|
_this2.zIndex = params.zIndex || 0;
|
|
330
|
-
_this2.interactive = typeof params.interactive == 'undefined' ? true : params.interactive;
|
|
354
|
+
_this2.interactive = typeof params.interactive == 'undefined' ? true : params.interactive; // webgl模式
|
|
355
|
+
|
|
356
|
+
if (_this2.mode === 'webgl') {
|
|
357
|
+
_this2.webglControl = new _path["default"](_this2.graph, {
|
|
358
|
+
style: _this2.style,
|
|
359
|
+
isRegular: params.isRegular,
|
|
360
|
+
needCut: params.needCut
|
|
361
|
+
});
|
|
362
|
+
}
|
|
331
363
|
|
|
332
364
|
_this2.initializing();
|
|
333
365
|
|
|
@@ -347,7 +379,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
347
379
|
_createClass(jmControl, [{
|
|
348
380
|
key: "type",
|
|
349
381
|
get: function get() {
|
|
350
|
-
return this.
|
|
382
|
+
return this.property('type');
|
|
351
383
|
}
|
|
352
384
|
/**
|
|
353
385
|
* 当前canvas的context
|
|
@@ -358,17 +390,16 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
358
390
|
}, {
|
|
359
391
|
key: "context",
|
|
360
392
|
get: function get() {
|
|
361
|
-
var s = this.
|
|
362
|
-
|
|
393
|
+
var s = this.property('context');
|
|
363
394
|
if (s) return s;else if (this.is('jmGraph') && this.canvas && this.canvas.getContext) {
|
|
364
|
-
return this.context = this.canvas.getContext('2d');
|
|
395
|
+
return this.context = this.canvas.getContext(this.mode || '2d');
|
|
365
396
|
}
|
|
366
397
|
var g = this.graph;
|
|
367
398
|
if (g) return g.context;
|
|
368
|
-
return g.canvas.getContext('2d');
|
|
399
|
+
return g.canvas.getContext(this.mode || '2d');
|
|
369
400
|
},
|
|
370
401
|
set: function set(v) {
|
|
371
|
-
return this.
|
|
402
|
+
return this.property('context', v);
|
|
372
403
|
}
|
|
373
404
|
/**
|
|
374
405
|
* 样式
|
|
@@ -379,14 +410,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
379
410
|
}, {
|
|
380
411
|
key: "style",
|
|
381
412
|
get: function get() {
|
|
382
|
-
var s = this.
|
|
383
|
-
|
|
384
|
-
if (!s) s = this.__pro('style', {});
|
|
413
|
+
var s = this.property('style');
|
|
414
|
+
if (!s) s = this.property('style', {});
|
|
385
415
|
return s;
|
|
386
416
|
},
|
|
387
417
|
set: function set(v) {
|
|
388
418
|
this.needUpdate = true;
|
|
389
|
-
return this.
|
|
419
|
+
return this.property('style', v);
|
|
390
420
|
}
|
|
391
421
|
/**
|
|
392
422
|
* 当前控件是否可见
|
|
@@ -398,14 +428,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
398
428
|
}, {
|
|
399
429
|
key: "visible",
|
|
400
430
|
get: function get() {
|
|
401
|
-
var s = this.
|
|
402
|
-
|
|
403
|
-
if (typeof s == 'undefined') s = this.__pro('visible', true);
|
|
431
|
+
var s = this.property('visible');
|
|
432
|
+
if (typeof s == 'undefined') s = this.property('visible', true);
|
|
404
433
|
return s;
|
|
405
434
|
},
|
|
406
435
|
set: function set(v) {
|
|
407
436
|
this.needUpdate = true;
|
|
408
|
-
return this.
|
|
437
|
+
return this.property('visible', v);
|
|
409
438
|
}
|
|
410
439
|
/**
|
|
411
440
|
* 当前控件是否是交互式的,如果是则会响应鼠标或touch事件。
|
|
@@ -418,12 +447,11 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
418
447
|
}, {
|
|
419
448
|
key: "interactive",
|
|
420
449
|
get: function get() {
|
|
421
|
-
var s = this.
|
|
422
|
-
|
|
450
|
+
var s = this.property('interactive');
|
|
423
451
|
return s;
|
|
424
452
|
},
|
|
425
453
|
set: function set(v) {
|
|
426
|
-
return this.
|
|
454
|
+
return this.property('interactive', v);
|
|
427
455
|
}
|
|
428
456
|
/**
|
|
429
457
|
* 当前控件的子控件集合
|
|
@@ -434,14 +462,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
434
462
|
}, {
|
|
435
463
|
key: "children",
|
|
436
464
|
get: function get() {
|
|
437
|
-
var s = this.
|
|
438
|
-
|
|
439
|
-
if (!s) s = this.__pro('children', new _jmList.jmList());
|
|
465
|
+
var s = this.property('children');
|
|
466
|
+
if (!s) s = this.property('children', new _jmList.jmList());
|
|
440
467
|
return s;
|
|
441
468
|
},
|
|
442
469
|
set: function set(v) {
|
|
443
470
|
this.needUpdate = true;
|
|
444
|
-
return this.
|
|
471
|
+
return this.property('children', v);
|
|
445
472
|
}
|
|
446
473
|
/**
|
|
447
474
|
* 宽度
|
|
@@ -452,14 +479,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
452
479
|
}, {
|
|
453
480
|
key: "width",
|
|
454
481
|
get: function get() {
|
|
455
|
-
var s = this.
|
|
456
|
-
|
|
457
|
-
if (typeof s == 'undefined') s = this.__pro('width', 0);
|
|
482
|
+
var s = this.property('width');
|
|
483
|
+
if (typeof s == 'undefined') s = this.property('width', 0);
|
|
458
484
|
return s;
|
|
459
485
|
},
|
|
460
486
|
set: function set(v) {
|
|
461
487
|
this.needUpdate = true;
|
|
462
|
-
return this.
|
|
488
|
+
return this.property('width', v);
|
|
463
489
|
}
|
|
464
490
|
/**
|
|
465
491
|
* 高度
|
|
@@ -470,14 +496,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
470
496
|
}, {
|
|
471
497
|
key: "height",
|
|
472
498
|
get: function get() {
|
|
473
|
-
var s = this.
|
|
474
|
-
|
|
475
|
-
if (typeof s == 'undefined') s = this.__pro('height', 0);
|
|
499
|
+
var s = this.property('height');
|
|
500
|
+
if (typeof s == 'undefined') s = this.property('height', 0);
|
|
476
501
|
return s;
|
|
477
502
|
},
|
|
478
503
|
set: function set(v) {
|
|
479
504
|
this.needUpdate = true;
|
|
480
|
-
return this.
|
|
505
|
+
return this.property('height', v);
|
|
481
506
|
}
|
|
482
507
|
/**
|
|
483
508
|
* 控件层级关系,发生改变时,需要重新调整排序
|
|
@@ -488,16 +513,13 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
488
513
|
}, {
|
|
489
514
|
key: "zIndex",
|
|
490
515
|
get: function get() {
|
|
491
|
-
var s = this.
|
|
492
|
-
|
|
493
|
-
if (!s) s = this.__pro('zIndex', 0);
|
|
516
|
+
var s = this.property('zIndex');
|
|
517
|
+
if (!s) s = this.property('zIndex', 0);
|
|
494
518
|
return s;
|
|
495
519
|
},
|
|
496
520
|
set: function set(v) {
|
|
497
521
|
this.needUpdate = true;
|
|
498
|
-
|
|
499
|
-
this.__pro('zIndex', v);
|
|
500
|
-
|
|
522
|
+
this.property('zIndex', v);
|
|
501
523
|
this.children.sort(); //层级发生改变,需要重新排序
|
|
502
524
|
|
|
503
525
|
this.needUpdate = true;
|
|
@@ -695,13 +717,23 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
695
717
|
|
|
696
718
|
__setStyle(styleValue.toGradient(_this3), mpname || name);
|
|
697
719
|
} else if (mpname) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
720
|
+
if (_this3.webglControl) {
|
|
721
|
+
//只有存在白名单中才处理
|
|
722
|
+
//颜色转换
|
|
723
|
+
if (t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
|
|
724
|
+
styleValue = _jmUtils.jmUtils.hexToRGBA(styleValue);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
_this3.webglControl.setStyle(mpname, styleValue);
|
|
728
|
+
} else {
|
|
729
|
+
//只有存在白名单中才处理
|
|
730
|
+
//颜色转换
|
|
731
|
+
if (t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
|
|
732
|
+
styleValue = _jmUtils.jmUtils.toColor(styleValue);
|
|
733
|
+
}
|
|
703
734
|
|
|
704
|
-
|
|
735
|
+
_this3.context[mpname] = styleValue;
|
|
736
|
+
}
|
|
705
737
|
} else {
|
|
706
738
|
switch (name) {
|
|
707
739
|
//阴影样式
|
|
@@ -723,8 +755,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
723
755
|
|
|
724
756
|
case 'translate':
|
|
725
757
|
{
|
|
726
|
-
_this3.context.translate(styleValue.x, styleValue.y);
|
|
727
|
-
|
|
758
|
+
_this3.context.translate && _this3.context.translate(styleValue.x, styleValue.y);
|
|
728
759
|
break;
|
|
729
760
|
}
|
|
730
761
|
//旋转
|
|
@@ -744,11 +775,11 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
744
775
|
tranY = styleValue.rotateY + bounds.top;
|
|
745
776
|
}
|
|
746
777
|
|
|
747
|
-
if (tranX != 0 || tranY != 0) _this3.context.translate(tranX, tranY);
|
|
778
|
+
if (tranX != 0 || tranY != 0) _this3.context.translate && _this3.context.translate(tranX, tranY);
|
|
748
779
|
|
|
749
780
|
_this3.context.rotate(styleValue.angle);
|
|
750
781
|
|
|
751
|
-
if (tranX != 0 || tranY != 0) _this3.context.translate(-tranX, -tranY);
|
|
782
|
+
if (tranX != 0 || tranY != 0) _this3.context.translate && _this3.context.translate(-tranX, -tranY);
|
|
752
783
|
break;
|
|
753
784
|
}
|
|
754
785
|
|
|
@@ -1154,7 +1185,8 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1154
1185
|
value: function beginDraw() {
|
|
1155
1186
|
this.getLocation(true); //重置位置信息
|
|
1156
1187
|
|
|
1157
|
-
this.context.beginPath();
|
|
1188
|
+
this.context.beginPath && this.context.beginPath();
|
|
1189
|
+
if (this.webglControl && this.webglControl.beginDraw) this.webglControl.beginDraw();
|
|
1158
1190
|
}
|
|
1159
1191
|
/**
|
|
1160
1192
|
* 结束控件绘制
|
|
@@ -1167,17 +1199,21 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1167
1199
|
value: function endDraw() {
|
|
1168
1200
|
//如果当前为封闭路径
|
|
1169
1201
|
if (this.style.close) {
|
|
1170
|
-
this.context.closePath();
|
|
1202
|
+
if (this.webglControl) this.webglControl.closePath();else this.context.closePath && this.context.closePath();
|
|
1171
1203
|
}
|
|
1172
1204
|
|
|
1173
1205
|
if (this.style['fill']) {
|
|
1174
|
-
this.
|
|
1206
|
+
if (this.webglControl) {
|
|
1207
|
+
var bounds = this.getBounds();
|
|
1208
|
+
this.webglControl.fill(bounds);
|
|
1209
|
+
} else this.context.fill && this.context.fill();
|
|
1175
1210
|
}
|
|
1176
1211
|
|
|
1177
|
-
if (this.style['stroke'] || !this.style['fill']) {
|
|
1178
|
-
this.context.stroke();
|
|
1212
|
+
if (this.style['stroke'] || !this.style['fill'] && !this.is('jmGraph')) {
|
|
1213
|
+
if (this.webglControl) this.webglControl.stroke();else this.context.stroke && this.context.stroke();
|
|
1179
1214
|
}
|
|
1180
1215
|
|
|
1216
|
+
if (this.webglControl && this.webglControl.endDraw) this.webglControl.endDraw();
|
|
1181
1217
|
this.needUpdate = false;
|
|
1182
1218
|
}
|
|
1183
1219
|
/**
|
|
@@ -1193,16 +1229,22 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1193
1229
|
if (this.points && this.points.length > 0) {
|
|
1194
1230
|
//获取当前控件的绝对位置
|
|
1195
1231
|
var bounds = this.parent && this.parent.absoluteBounds ? this.parent.absoluteBounds : this.absoluteBounds;
|
|
1196
|
-
this.context.moveTo(this.points[0].x + bounds.left, this.points[0].y + bounds.top);
|
|
1197
|
-
var len = this.points.length;
|
|
1198
1232
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1233
|
+
if (this.webglControl) {
|
|
1234
|
+
this.webglControl.setParentBounds(bounds);
|
|
1235
|
+
this.webglControl.draw(_toConsumableArray(this.points));
|
|
1236
|
+
} else if (this.context && this.context.moveTo) {
|
|
1237
|
+
this.context.moveTo(this.points[0].x + bounds.left, this.points[0].y + bounds.top);
|
|
1238
|
+
var len = this.points.length;
|
|
1201
1239
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1240
|
+
for (var i = 1; i < len; i++) {
|
|
1241
|
+
var p = this.points[i]; //移至当前坐标
|
|
1242
|
+
|
|
1243
|
+
if (p.m) {
|
|
1244
|
+
this.context.moveTo(p.x + bounds.left, p.y + bounds.top);
|
|
1245
|
+
} else {
|
|
1246
|
+
this.context.lineTo(p.x + bounds.left, p.y + bounds.top);
|
|
1247
|
+
}
|
|
1206
1248
|
}
|
|
1207
1249
|
}
|
|
1208
1250
|
}
|
|
@@ -1228,7 +1270,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1228
1270
|
if (this.absoluteBounds.left >= this.graph.width) needDraw = false;else if (this.absoluteBounds.top >= this.graph.height) needDraw = false;else if (this.absoluteBounds.right <= 0) needDraw = false;else if (this.absoluteBounds.bottom <= 0) needDraw = false;
|
|
1229
1271
|
}
|
|
1230
1272
|
|
|
1231
|
-
this.context.save();
|
|
1273
|
+
this.context.save && this.context.save();
|
|
1232
1274
|
this.emit('beginDraw', this);
|
|
1233
1275
|
this.setStyle(); //设定样式
|
|
1234
1276
|
|
|
@@ -1243,7 +1285,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1243
1285
|
}
|
|
1244
1286
|
|
|
1245
1287
|
this.emit('endDraw', this);
|
|
1246
|
-
this.context.restore();
|
|
1288
|
+
this.context.restore && this.context.restore();
|
|
1247
1289
|
this.needUpdate = false;
|
|
1248
1290
|
}
|
|
1249
1291
|
}
|
|
@@ -1845,7 +1887,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1845
1887
|
exports.jmControl = exports["default"] = jmControl;
|
|
1846
1888
|
;
|
|
1847
1889
|
|
|
1848
|
-
},{"./jmGradient.js":4,"./jmList.js":6,"./jmProperty.js":9,"./jmShadow.js":10,"./jmUtils.js":11}],3:[function(require,module,exports){
|
|
1890
|
+
},{"../lib/webgl/path.js":21,"./jmGradient.js":4,"./jmList.js":6,"./jmProperty.js":9,"./jmShadow.js":10,"./jmUtils.js":11}],3:[function(require,module,exports){
|
|
1849
1891
|
"use strict";
|
|
1850
1892
|
|
|
1851
1893
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -2272,7 +2314,11 @@ var jmGradient = /*#__PURE__*/function () {
|
|
|
2272
2314
|
var sy2 = Number(y2) + bounds.top;
|
|
2273
2315
|
|
|
2274
2316
|
if (this.type === 'linear') {
|
|
2275
|
-
|
|
2317
|
+
if (control.mode === 'webgl' && control.webglControl) {
|
|
2318
|
+
gradient = control.webglControl.createLinearGradient(x1, y1, x2, y2, bounds);
|
|
2319
|
+
} else {
|
|
2320
|
+
context.createLinearGradient && (gradient = context.createLinearGradient(sx1, sy1, sx2, sy2));
|
|
2321
|
+
}
|
|
2276
2322
|
} else if (this.type === 'radial') {
|
|
2277
2323
|
var r1 = this.r1 || 0;
|
|
2278
2324
|
var r2 = this.r2;
|
|
@@ -2285,24 +2331,32 @@ var jmGradient = /*#__PURE__*/function () {
|
|
|
2285
2331
|
if (_jmUtils.jmUtils.checkPercent(r2)) {
|
|
2286
2332
|
r2 = _jmUtils.jmUtils.percentToNumber(r2);
|
|
2287
2333
|
r2 = d * r2;
|
|
2288
|
-
}
|
|
2289
|
-
//小程序的接口特殊
|
|
2290
|
-
|
|
2334
|
+
}
|
|
2291
2335
|
|
|
2292
|
-
if (
|
|
2293
|
-
gradient =
|
|
2294
|
-
}
|
|
2336
|
+
if (control.mode === 'webgl' && control.webglControl) {
|
|
2337
|
+
gradient = control.webglControl.createRadialGradient(x1, y1, r1, x2, y2, r2, bounds);
|
|
2338
|
+
} //offsetLine = Math.abs(r2 - r1);//二圆半径差
|
|
2339
|
+
else if (context.createRadialGradient) {
|
|
2295
2340
|
gradient = context.createRadialGradient(sx1, sy1, r1, sx2, sy2, r2);
|
|
2341
|
+
} //小程序的接口特殊
|
|
2342
|
+
else if (context.createCircularGradient) {
|
|
2343
|
+
gradient = context.createCircularGradient(sx1, sy1, r2);
|
|
2296
2344
|
}
|
|
2297
2345
|
} //颜色渐变
|
|
2298
2346
|
|
|
2299
2347
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2348
|
+
if (gradient) {
|
|
2349
|
+
this.stops.each(function (i, s) {
|
|
2350
|
+
var c = _jmUtils.jmUtils.toColor(s.color); //s.offset 0.0 ~ 1.0
|
|
2302
2351
|
|
|
2303
2352
|
|
|
2304
|
-
|
|
2305
|
-
|
|
2353
|
+
gradient && gradient.addColorStop(s.offset, c);
|
|
2354
|
+
});
|
|
2355
|
+
} else {
|
|
2356
|
+
var s = this.stops.get(0);
|
|
2357
|
+
return s && s.color || '#000';
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2306
2360
|
return gradient;
|
|
2307
2361
|
}
|
|
2308
2362
|
/**
|
|
@@ -2389,14 +2443,14 @@ var jmGradient = /*#__PURE__*/function () {
|
|
|
2389
2443
|
var str = this.type + '-gradient(';
|
|
2390
2444
|
|
|
2391
2445
|
if (this.type == 'linear') {
|
|
2392
|
-
str += this.x1 + ' ' + this.y1 + ' ' + this.x2 + ' ' + this.y2;
|
|
2446
|
+
str += this.x1.toFixed(2) + ' ' + this.y1.toFixed(2) + ' ' + this.x2.toFixed(2) + ' ' + this.y2.toFixed(2);
|
|
2393
2447
|
} else {
|
|
2394
|
-
str += this.x1 + ' ' + this.y1 + ' ' + this.r1 + ' ' + this.x2 + ' ' + this.y2 + ' ' + this.r2;
|
|
2448
|
+
str += this.x1.toFixed(2) + ' ' + this.y1.toFixed(2) + ' ' + this.r1.toFixed(2) + ' ' + this.x2.toFixed(2) + ' ' + this.y2.toFixed(2) + ' ' + this.r2.toFixed(2);
|
|
2395
2449
|
} //颜色渐变
|
|
2396
2450
|
|
|
2397
2451
|
|
|
2398
2452
|
this.stops.each(function (i, s) {
|
|
2399
|
-
str += ',' + s.color + ' ' + s.offset;
|
|
2453
|
+
str += ',' + s.color + ' ' + s.offset.toFixed(2);
|
|
2400
2454
|
});
|
|
2401
2455
|
return str + ')';
|
|
2402
2456
|
}
|
|
@@ -2483,6 +2537,12 @@ var _jmPath = require("./jmPath.js");
|
|
|
2483
2537
|
|
|
2484
2538
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
2485
2539
|
|
|
2540
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2541
|
+
|
|
2542
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
2543
|
+
|
|
2544
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2545
|
+
|
|
2486
2546
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2487
2547
|
|
|
2488
2548
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -2533,6 +2593,8 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2533
2593
|
option.mode = option.mode || '2d'; // webgl | 2d
|
|
2534
2594
|
|
|
2535
2595
|
option.interactive = true;
|
|
2596
|
+
option.isRegular = true; // 规则的
|
|
2597
|
+
|
|
2536
2598
|
_this = _super.call(this, option, 'jmGraph');
|
|
2537
2599
|
_this.option = option || {};
|
|
2538
2600
|
_this.devicePixelRatio = 1; // 根据屏幕的缩放倍数
|
|
@@ -2543,11 +2605,15 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2543
2605
|
* @type {jmUtils}
|
|
2544
2606
|
*/
|
|
2545
2607
|
|
|
2546
|
-
_this.util = _this.utils = _jmUtils.jmUtils;
|
|
2608
|
+
_this.util = _this.utils = _jmUtils.jmUtils; // 模式 webgl | 2d
|
|
2609
|
+
|
|
2610
|
+
_this.mode = option.mode; //如果是小程序
|
|
2547
2611
|
|
|
2548
2612
|
if (typeof wx != 'undefined' && wx.canIUse && wx.canIUse('canvas')) {
|
|
2549
2613
|
if (typeof canvas === 'string') canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
2550
2614
|
_this.isWXMiniApp = true; // 微信小程序平台
|
|
2615
|
+
|
|
2616
|
+
_this.container = canvas;
|
|
2551
2617
|
} else {
|
|
2552
2618
|
if (typeof canvas === 'string' && typeof document != 'undefined') {
|
|
2553
2619
|
canvas = document.getElementById(canvas);
|
|
@@ -2568,7 +2634,29 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2568
2634
|
}
|
|
2569
2635
|
|
|
2570
2636
|
_this.canvas = canvas;
|
|
2571
|
-
_this.context = canvas.getContext(
|
|
2637
|
+
_this.context = canvas.getContext(_this.mode);
|
|
2638
|
+
_this.textureCanvas = option.textureCanvas || null; // webgl模式
|
|
2639
|
+
|
|
2640
|
+
if (_this.mode === 'webgl') {
|
|
2641
|
+
_this.context.enable(_this.context.BLEND); // 开启混合功能:(注意,它不可和gl.DEPTH_TEST一起使用)
|
|
2642
|
+
|
|
2643
|
+
|
|
2644
|
+
_this.context.blendFunc(_this.context.SRC_ALPHA, _this.context.ONE_MINUS_SRC_ALPHA); // 指定混合函数:
|
|
2645
|
+
// webglcontextlost webglcontextrestored
|
|
2646
|
+
|
|
2647
|
+
|
|
2648
|
+
_jmUtils.jmUtils.bindEvent(canvas, 'webglcontextlost', function (e) {
|
|
2649
|
+
console.log('canvas webglcontextlost', e);
|
|
2650
|
+
|
|
2651
|
+
_this.emit('webglcontextlost', e);
|
|
2652
|
+
});
|
|
2653
|
+
|
|
2654
|
+
_jmUtils.jmUtils.bindEvent(canvas, 'webglcontextrestored', function (e) {
|
|
2655
|
+
console.log('canvas webglcontextrestored', e);
|
|
2656
|
+
|
|
2657
|
+
_this.emit('webglcontextrestored', e);
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2572
2660
|
|
|
2573
2661
|
_this.__init(callback);
|
|
2574
2662
|
|
|
@@ -2597,14 +2685,14 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2597
2685
|
*/
|
|
2598
2686
|
|
|
2599
2687
|
this.on('beginDraw', function () {
|
|
2600
|
-
this.context.translate(0.5, 0.5);
|
|
2688
|
+
this.context.translate && this.context.translate(0.5, 0.5);
|
|
2601
2689
|
});
|
|
2602
2690
|
/**
|
|
2603
2691
|
* 结束控件绘制 为了解决一像素线条问题
|
|
2604
2692
|
*/
|
|
2605
2693
|
|
|
2606
2694
|
this.on('endDraw', function () {
|
|
2607
|
-
this.context.translate(-0.5, -0.5);
|
|
2695
|
+
this.context.translate && this.context.translate(-0.5, -0.5);
|
|
2608
2696
|
}); // devicePixelRatio初始化
|
|
2609
2697
|
|
|
2610
2698
|
var dpr = typeof window != 'undefined' && window.devicePixelRatio > 1 ? window.devicePixelRatio : 1;
|
|
@@ -2642,9 +2730,17 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2642
2730
|
if (h) this.__normalSize.height = h;
|
|
2643
2731
|
this.css('width', w + "px");
|
|
2644
2732
|
this.css('height', h + "px");
|
|
2645
|
-
|
|
2646
|
-
this.
|
|
2647
|
-
|
|
2733
|
+
|
|
2734
|
+
if (this.mode === '2d') {
|
|
2735
|
+
this.canvas.height = h * this.dprScaleSize;
|
|
2736
|
+
this.canvas.width = w * this.dprScaleSize;
|
|
2737
|
+
if (this.dprScaleSize !== 1) this.context.scale && this.context.scale(this.dprScaleSize, this.dprScaleSize);
|
|
2738
|
+
} else {
|
|
2739
|
+
this.canvas.width = w;
|
|
2740
|
+
this.canvas.height = h;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
this.context.viewport && this.context.viewport(0, 0, w, h);
|
|
2648
2744
|
}
|
|
2649
2745
|
/**
|
|
2650
2746
|
* 内部坐标转为页面坐标,这里主要是有devicePixelRatio倍数问题
|
|
@@ -2886,24 +2982,38 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2886
2982
|
w = w / this.scaleSize.x;
|
|
2887
2983
|
h = h / this.scaleSize.y;
|
|
2888
2984
|
}*/
|
|
2889
|
-
}
|
|
2985
|
+
}
|
|
2890
2986
|
|
|
2987
|
+
if (this.context.clearRect) {
|
|
2988
|
+
if (this.style && this.style.fill) {
|
|
2989
|
+
this.points = [{
|
|
2990
|
+
x: 0,
|
|
2991
|
+
y: 0
|
|
2992
|
+
}, {
|
|
2993
|
+
x: w,
|
|
2994
|
+
y: 0
|
|
2995
|
+
}, {
|
|
2996
|
+
x: w,
|
|
2997
|
+
y: h
|
|
2998
|
+
}, {
|
|
2999
|
+
x: 0,
|
|
3000
|
+
y: h
|
|
3001
|
+
}];
|
|
3002
|
+
this.style.close = true; // 封闭填充
|
|
3003
|
+
}
|
|
2891
3004
|
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
y: h
|
|
2905
|
-
}];
|
|
2906
|
-
} else if (this.context.clearRect) this.context.clearRect(0, 0, w, h);
|
|
3005
|
+
this.context.clearRect(0, 0, w, h);
|
|
3006
|
+
} else if (this.mode === 'webgl' && this.context.clear) {
|
|
3007
|
+
var color = this.style && this.style.fill ? this.utils.hexToRGBA(this.style.fill) : {
|
|
3008
|
+
r: 0,
|
|
3009
|
+
g: 0,
|
|
3010
|
+
b: 0,
|
|
3011
|
+
a: 0
|
|
3012
|
+
};
|
|
3013
|
+
this.context.clearColor(color.r, color.g, color.b, color.a); // 设置清空颜色缓冲时的颜色值
|
|
3014
|
+
|
|
3015
|
+
this.context.clear(this.context.COLOR_BUFFER_BIT); // 清空颜色缓冲区,也就是清空画布
|
|
3016
|
+
}
|
|
2907
3017
|
}
|
|
2908
3018
|
/**
|
|
2909
3019
|
* 设置画布样式,此处只是设置其css样式
|
|
@@ -2933,10 +3043,11 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2933
3043
|
}, {
|
|
2934
3044
|
key: "createPath",
|
|
2935
3045
|
value: function createPath(points, style) {
|
|
2936
|
-
var
|
|
3046
|
+
var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3047
|
+
var path = this.createShape('path', _objectSpread({
|
|
2937
3048
|
points: points,
|
|
2938
3049
|
style: style
|
|
2939
|
-
});
|
|
3050
|
+
}, option));
|
|
2940
3051
|
return path;
|
|
2941
3052
|
}
|
|
2942
3053
|
/**
|
|
@@ -3351,7 +3462,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
3351
3462
|
|
|
3352
3463
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
3353
3464
|
|
|
3354
|
-
var
|
|
3465
|
+
var control_id_counter = 0;
|
|
3355
3466
|
/**
|
|
3356
3467
|
* 所有jm对象的基础对象
|
|
3357
3468
|
*
|
|
@@ -3366,8 +3477,9 @@ var jmObject = /*#__PURE__*/function () {
|
|
|
3366
3477
|
|
|
3367
3478
|
if (g && g.type == 'jmGraph') {
|
|
3368
3479
|
this.graph = g;
|
|
3369
|
-
}
|
|
3480
|
+
}
|
|
3370
3481
|
|
|
3482
|
+
this.id = ++control_id_counter; //生成一个唯一id
|
|
3371
3483
|
}
|
|
3372
3484
|
/**
|
|
3373
3485
|
* 检 查对象是否为指定类型
|
|
@@ -3526,6 +3638,7 @@ var jmPath = /*#__PURE__*/function (_jmControl) {
|
|
|
3526
3638
|
|
|
3527
3639
|
_this = _super.call(this, params, t);
|
|
3528
3640
|
_this.points = params && params.points ? params.points : [];
|
|
3641
|
+
_this.polygonIndices = params && params.polygonIndices ? params.polygonIndices : [];
|
|
3529
3642
|
return _this;
|
|
3530
3643
|
}
|
|
3531
3644
|
/**
|
|
@@ -3539,13 +3652,28 @@ var jmPath = /*#__PURE__*/function (_jmControl) {
|
|
|
3539
3652
|
_createClass(jmPath, [{
|
|
3540
3653
|
key: "points",
|
|
3541
3654
|
get: function get() {
|
|
3542
|
-
var s = this.
|
|
3655
|
+
var s = this.property('points');
|
|
3656
|
+
return s;
|
|
3657
|
+
},
|
|
3658
|
+
set: function set(v) {
|
|
3659
|
+
this.needUpdate = true;
|
|
3660
|
+
return this.property('points', v);
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* 顶点数组索引,对应points中的顶点
|
|
3664
|
+
* @property polygonIndices
|
|
3665
|
+
* @type {array}
|
|
3666
|
+
*/
|
|
3543
3667
|
|
|
3668
|
+
}, {
|
|
3669
|
+
key: "polygonIndices",
|
|
3670
|
+
get: function get() {
|
|
3671
|
+
var s = this.property('polygonIndices');
|
|
3544
3672
|
return s;
|
|
3545
3673
|
},
|
|
3546
3674
|
set: function set(v) {
|
|
3547
3675
|
this.needUpdate = true;
|
|
3548
|
-
return this.
|
|
3676
|
+
return this.property('polygonIndices', v);
|
|
3549
3677
|
}
|
|
3550
3678
|
}]);
|
|
3551
3679
|
|
|
@@ -3602,18 +3730,19 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3602
3730
|
|
|
3603
3731
|
var _super = _createSuper(jmProperty);
|
|
3604
3732
|
|
|
3605
|
-
function jmProperty() {
|
|
3733
|
+
function jmProperty(params) {
|
|
3606
3734
|
var _this;
|
|
3607
3735
|
|
|
3608
3736
|
_classCallCheck(this, jmProperty);
|
|
3609
3737
|
|
|
3610
3738
|
_this = _super.call(this);
|
|
3611
3739
|
_this[PROPERTY_KEY] = {};
|
|
3740
|
+
if (params && params.mode) _this.mode = params.mode;
|
|
3612
3741
|
return _this;
|
|
3613
3742
|
}
|
|
3614
3743
|
/**
|
|
3615
3744
|
* 基础属性读写接口
|
|
3616
|
-
* @method
|
|
3745
|
+
* @method property
|
|
3617
3746
|
* @param {string} name 属性名
|
|
3618
3747
|
* @param {any} value 属性的值
|
|
3619
3748
|
* @returns {any} 属性的值
|
|
@@ -3621,8 +3750,8 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3621
3750
|
|
|
3622
3751
|
|
|
3623
3752
|
_createClass(jmProperty, [{
|
|
3624
|
-
key: "
|
|
3625
|
-
value: function
|
|
3753
|
+
key: "property",
|
|
3754
|
+
value: function property() {
|
|
3626
3755
|
for (var _len = arguments.length, pars = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3627
3756
|
pars[_key] = arguments[_key];
|
|
3628
3757
|
}
|
|
@@ -3640,7 +3769,7 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3640
3769
|
pros[name] = pars[1];
|
|
3641
3770
|
if (this.emit) this.emit('propertyChange', name, args);
|
|
3642
3771
|
return pars[1];
|
|
3643
|
-
} else if (
|
|
3772
|
+
} else if (name) {
|
|
3644
3773
|
return pros[name];
|
|
3645
3774
|
}
|
|
3646
3775
|
}
|
|
@@ -3654,11 +3783,10 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3654
3783
|
}, {
|
|
3655
3784
|
key: "needUpdate",
|
|
3656
3785
|
get: function get() {
|
|
3657
|
-
return this.
|
|
3786
|
+
return this.property('needUpdate');
|
|
3658
3787
|
},
|
|
3659
3788
|
set: function set(v) {
|
|
3660
|
-
this.
|
|
3661
|
-
|
|
3789
|
+
this.property('needUpdate', v); //子控件属性改变,需要更新整个画板
|
|
3662
3790
|
|
|
3663
3791
|
if (v && !this.is('jmGraph') && this.graph) {
|
|
3664
3792
|
this.graph.needUpdate = true;
|
|
@@ -3673,13 +3801,28 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3673
3801
|
}, {
|
|
3674
3802
|
key: "graph",
|
|
3675
3803
|
get: function get() {
|
|
3676
|
-
var g = this.
|
|
3677
|
-
|
|
3678
|
-
g = g || this.__pro('graph', this.findParent('jmGraph'));
|
|
3804
|
+
var g = this.property('graph');
|
|
3805
|
+
g = g || this.property('graph', this.findParent('jmGraph'));
|
|
3679
3806
|
return g;
|
|
3680
3807
|
},
|
|
3681
3808
|
set: function set(v) {
|
|
3682
|
-
return this.
|
|
3809
|
+
return this.property('graph', v);
|
|
3810
|
+
}
|
|
3811
|
+
/**
|
|
3812
|
+
* 绘制模式 2d/webgl
|
|
3813
|
+
* @property mode
|
|
3814
|
+
* @type {string}
|
|
3815
|
+
*/
|
|
3816
|
+
|
|
3817
|
+
}, {
|
|
3818
|
+
key: "mode",
|
|
3819
|
+
get: function get() {
|
|
3820
|
+
var m = this.property('mode');
|
|
3821
|
+
if (m) return m;else if (this.is('jmGraph')) return this.property('mode');
|
|
3822
|
+
return this.graph.mode;
|
|
3823
|
+
},
|
|
3824
|
+
set: function set(v) {
|
|
3825
|
+
return this.property('mode', v);
|
|
3683
3826
|
}
|
|
3684
3827
|
/**
|
|
3685
3828
|
* 在下次进行重绘时执行
|
|
@@ -3820,6 +3963,150 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
3820
3963
|
|
|
3821
3964
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
3822
3965
|
|
|
3966
|
+
var colorKeywords = {
|
|
3967
|
+
aliceblue: "#f0f8ff",
|
|
3968
|
+
antiquewhite: "#faebd7",
|
|
3969
|
+
aqua: "#00ffff",
|
|
3970
|
+
aquamarine: "#7fffd4",
|
|
3971
|
+
azure: "#f0ffff",
|
|
3972
|
+
beige: "#f5f5dc",
|
|
3973
|
+
bisque: "#ffe4c4",
|
|
3974
|
+
black: "#000000",
|
|
3975
|
+
blanchedalmond: "#ffebcd",
|
|
3976
|
+
blue: "#0000ff",
|
|
3977
|
+
blueviolet: "#8a2be2",
|
|
3978
|
+
brown: "#a52a2a",
|
|
3979
|
+
burlywood: "#deb887",
|
|
3980
|
+
cadetblue: "#5f9ea0",
|
|
3981
|
+
chartreuse: "#7fff00",
|
|
3982
|
+
chocolate: "#d2691e",
|
|
3983
|
+
coral: "#ff7f50",
|
|
3984
|
+
cornflowerblue: "#6495ed",
|
|
3985
|
+
cornsilk: "#fff8dc",
|
|
3986
|
+
crimson: "#dc143c",
|
|
3987
|
+
cyan: "#00ffff",
|
|
3988
|
+
darkblue: "#00008b",
|
|
3989
|
+
darkcyan: "#008b8b",
|
|
3990
|
+
darkgoldenrod: "#b8860b",
|
|
3991
|
+
darkgray: "#a9a9a9",
|
|
3992
|
+
darkgreen: "#006400",
|
|
3993
|
+
darkkhaki: "#bdb76b",
|
|
3994
|
+
darkmagenta: "#8b008b",
|
|
3995
|
+
darkolivegreen: "#556b2f",
|
|
3996
|
+
darkorange: "#ff8c00",
|
|
3997
|
+
darkorchid: "#9932cc",
|
|
3998
|
+
darkred: "#8b0000",
|
|
3999
|
+
darksalmon: "#e9967a",
|
|
4000
|
+
darkseagreen: "#8fbc8f",
|
|
4001
|
+
darkslateblue: "#483d8b",
|
|
4002
|
+
darkslategray: "#2f4f4f",
|
|
4003
|
+
darkturquoise: "#00ced1",
|
|
4004
|
+
darkviolet: "#9400d3",
|
|
4005
|
+
deeppink: "#ff1493",
|
|
4006
|
+
deepskyblue: "#00bfff",
|
|
4007
|
+
dimgray: "#696969",
|
|
4008
|
+
dodgerblue: "#1e90ff",
|
|
4009
|
+
firebrick: "#b22222",
|
|
4010
|
+
floralwhite: "#fffaf0",
|
|
4011
|
+
forestgreen: "#228b22",
|
|
4012
|
+
fuchsia: "#ff00ff",
|
|
4013
|
+
gainsboro: "#dcdcdc",
|
|
4014
|
+
ghostwhite: "#f8f8ff",
|
|
4015
|
+
gold: "#ffd700",
|
|
4016
|
+
goldenrod: "#daa520",
|
|
4017
|
+
gray: "#808080",
|
|
4018
|
+
green: "#008000",
|
|
4019
|
+
greenyellow: "#adff2f",
|
|
4020
|
+
grey: "#808080",
|
|
4021
|
+
honeydew: "#f0fff0",
|
|
4022
|
+
hotpink: "#ff69b4",
|
|
4023
|
+
indianred: "#cd5c5c",
|
|
4024
|
+
indigo: "#4b0082",
|
|
4025
|
+
ivory: "#fffff0",
|
|
4026
|
+
khaki: "#f0e68c",
|
|
4027
|
+
lavender: "#e6e6fa",
|
|
4028
|
+
lavenderblush: "#fff0f5",
|
|
4029
|
+
lawngreen: "#7cfc00",
|
|
4030
|
+
lemonchiffon: "#fffacd",
|
|
4031
|
+
lightblue: "#add8e6",
|
|
4032
|
+
lightcoral: "#f08080",
|
|
4033
|
+
lightcyan: "#e0ffff",
|
|
4034
|
+
lightgoldenrodyellow: "#fafad2",
|
|
4035
|
+
lightgrey: "#d3d3d3",
|
|
4036
|
+
lightgreen: "#90ee90",
|
|
4037
|
+
lightpink: "#ffb6c1",
|
|
4038
|
+
lightsalmon: "#ffa07a",
|
|
4039
|
+
lightseagreen: "#20b2aa",
|
|
4040
|
+
lightskyblue: "#87cefa",
|
|
4041
|
+
lightslategray: "#778899",
|
|
4042
|
+
lightsteelblue: "#b0c4de",
|
|
4043
|
+
lightyellow: "#ffffe0",
|
|
4044
|
+
lime: "#00ff00",
|
|
4045
|
+
limegreen: "#32cd32",
|
|
4046
|
+
linen: "#faf0e6",
|
|
4047
|
+
magenta: "#ff00ff",
|
|
4048
|
+
maroon: "#800000",
|
|
4049
|
+
mediumaquamarine: "#66cdaa",
|
|
4050
|
+
mediumblue: "#0000cd",
|
|
4051
|
+
mediumorchid: "#ba55d3",
|
|
4052
|
+
mediumpurple: "#9370d8",
|
|
4053
|
+
mediumseagreen: "#3cb371",
|
|
4054
|
+
mediumslateblue: "#7b68ee",
|
|
4055
|
+
mediumspringgreen: "#00fa9a",
|
|
4056
|
+
mediumturquoise: "#48d1cc",
|
|
4057
|
+
mediumvioletred: "#c71585",
|
|
4058
|
+
midnightblue: "#191970",
|
|
4059
|
+
mintcream: "#f5fffa",
|
|
4060
|
+
mistyrose: "#ffe4e1",
|
|
4061
|
+
moccasin: "#ffe4b5",
|
|
4062
|
+
navajowhite: "#ffdead",
|
|
4063
|
+
navy: "#000080",
|
|
4064
|
+
oldlace: "#fdf5e6",
|
|
4065
|
+
olive: "#808000",
|
|
4066
|
+
olivedrab: "#6b8e23",
|
|
4067
|
+
orange: "#ffa500",
|
|
4068
|
+
orangered: "#ff4500",
|
|
4069
|
+
orchid: "#da70d6",
|
|
4070
|
+
palegoldenrod: "#eee8aa",
|
|
4071
|
+
palegreen: "#98fb98",
|
|
4072
|
+
paleturquoise: "#afeeee",
|
|
4073
|
+
palevioletred: "#d87093",
|
|
4074
|
+
papayawhip: "#ffefd5",
|
|
4075
|
+
peachpuff: "#ffdab9",
|
|
4076
|
+
peru: "#cd853f",
|
|
4077
|
+
pink: "#ffc0cb",
|
|
4078
|
+
plum: "#dda0dd",
|
|
4079
|
+
powderblue: "#b0e0e6",
|
|
4080
|
+
purple: "#800080",
|
|
4081
|
+
red: "#ff0000",
|
|
4082
|
+
rosybrown: "#bc8f8f",
|
|
4083
|
+
royalblue: "#4169e1",
|
|
4084
|
+
saddlebrown: "#8b4513",
|
|
4085
|
+
salmon: "#fa8072",
|
|
4086
|
+
sandybrown: "#f4a460",
|
|
4087
|
+
seagreen: "#2e8b57",
|
|
4088
|
+
seashell: "#fff5ee",
|
|
4089
|
+
sienna: "#a0522d",
|
|
4090
|
+
silver: "#c0c0c0",
|
|
4091
|
+
skyblue: "#87ceeb",
|
|
4092
|
+
slateblue: "#6a5acd",
|
|
4093
|
+
slategray: "#708090",
|
|
4094
|
+
snow: "#fffafa",
|
|
4095
|
+
springgreen: "#00ff7f",
|
|
4096
|
+
steelblue: "#4682b4",
|
|
4097
|
+
tan: "#d2b48c",
|
|
4098
|
+
teal: "#008080",
|
|
4099
|
+
thistle: "#d8bfd8",
|
|
4100
|
+
tomato: "#ff6347",
|
|
4101
|
+
turquoise: "#40e0d0",
|
|
4102
|
+
violet: "#ee82ee",
|
|
4103
|
+
wheat: "#f5deb3",
|
|
4104
|
+
white: "#ffffff",
|
|
4105
|
+
whitesmoke: "#f5f5f5",
|
|
4106
|
+
yellow: "#ffff00",
|
|
4107
|
+
yellowgreen: "#9acd32",
|
|
4108
|
+
transparent: "rgba(0,0,0,0)"
|
|
4109
|
+
};
|
|
3823
4110
|
/**
|
|
3824
4111
|
* 画图基础对象
|
|
3825
4112
|
* 当前库的工具类
|
|
@@ -3827,6 +4114,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
3827
4114
|
* @class jmUtils
|
|
3828
4115
|
* @static
|
|
3829
4116
|
*/
|
|
4117
|
+
|
|
3830
4118
|
var jmUtils = /*#__PURE__*/function () {
|
|
3831
4119
|
function jmUtils() {
|
|
3832
4120
|
_classCallCheck(this, jmUtils);
|
|
@@ -3895,7 +4183,11 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
3895
4183
|
if (k === 'constructor') continue;
|
|
3896
4184
|
var v = source[k]; // 不复制页面元素和class对象
|
|
3897
4185
|
|
|
3898
|
-
if (v && (v.tagName || v.getContext))
|
|
4186
|
+
if (v && (v.tagName || v.getContext)) {
|
|
4187
|
+
target[k] = v;
|
|
4188
|
+
continue;
|
|
4189
|
+
} // 如果不是对象和空,则采用target的属性
|
|
4190
|
+
|
|
3899
4191
|
|
|
3900
4192
|
if (_typeof(target[k]) === 'object' || typeof target[k] === 'undefined') {
|
|
3901
4193
|
target[k] = this.clone(v, target[k], deep, copyHandler, deepIndex);
|
|
@@ -4502,62 +4794,102 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4502
4794
|
}, {
|
|
4503
4795
|
key: "hexToRGBA",
|
|
4504
4796
|
value: function hexToRGBA(hex) {
|
|
4505
|
-
hex = this.trim(hex);
|
|
4797
|
+
if (typeof hex === 'string') hex = this.trim(hex);else return hex; // 如果缓存存在,则直接返回
|
|
4798
|
+
|
|
4799
|
+
this.__hexToRGBA_Cache = this.__hexToRGBA_Cache || {};
|
|
4800
|
+
if (this.__hexToRGBA_Cache[hex]) return this.__hexToRGBA_Cache[hex];
|
|
4801
|
+
var res = hex; // 系统颜色
|
|
4506
4802
|
|
|
4507
|
-
if (
|
|
4803
|
+
if (colorKeywords[res]) res = colorKeywords[res]; //当为7位时,表示需要转为带透明度的rgba
|
|
4804
|
+
|
|
4805
|
+
if (res[0] == '#') {
|
|
4508
4806
|
var color = {
|
|
4509
4807
|
a: 1
|
|
4510
4808
|
};
|
|
4511
4809
|
|
|
4512
|
-
if (
|
|
4513
|
-
color.a =
|
|
4514
|
-
color.g =
|
|
4515
|
-
color.b =
|
|
4516
|
-
color.r =
|
|
4810
|
+
if (res.length >= 8) {
|
|
4811
|
+
color.a = res.substr(1, 2);
|
|
4812
|
+
color.g = res.substr(5, 2);
|
|
4813
|
+
color.b = res.substr(7, 2);
|
|
4814
|
+
color.r = res.substr(3, 2); //透明度
|
|
4517
4815
|
|
|
4518
|
-
color.a = (this.hexToNumber(color.a) / 255).toFixed(4);
|
|
4816
|
+
color.a = Number((this.hexToNumber(color.a) / 255).toFixed(4));
|
|
4519
4817
|
color.r = this.hexToNumber(color.r || 0);
|
|
4520
4818
|
color.g = this.hexToNumber(color.g || 0);
|
|
4521
4819
|
color.b = this.hexToNumber(color.b || 0);
|
|
4522
|
-
|
|
4820
|
+
res = color;
|
|
4523
4821
|
} // #cccccc || #ccc
|
|
4524
|
-
else if (
|
|
4822
|
+
else if (res.length === 7 || res.length === 4) {
|
|
4525
4823
|
// #ccc这种情况,把每个位复制一份
|
|
4526
|
-
if (
|
|
4527
|
-
color.g =
|
|
4824
|
+
if (res.length === 4) {
|
|
4825
|
+
color.g = res.substr(2, 1);
|
|
4528
4826
|
color.g = color.g + color.g;
|
|
4529
|
-
color.b =
|
|
4827
|
+
color.b = res.substr(3, 1);
|
|
4530
4828
|
color.b = color.b + color.b;
|
|
4531
|
-
color.r =
|
|
4829
|
+
color.r = res.substr(1, 1);
|
|
4532
4830
|
color.r = color.r + color.r;
|
|
4533
4831
|
} else {
|
|
4534
|
-
color.g =
|
|
4832
|
+
color.g = res.substr(3, 2); //除#号外的第二位
|
|
4535
4833
|
|
|
4536
|
-
color.b =
|
|
4537
|
-
color.r =
|
|
4834
|
+
color.b = res.substr(5, 2);
|
|
4835
|
+
color.r = res.substr(1, 2);
|
|
4538
4836
|
}
|
|
4539
4837
|
|
|
4540
4838
|
color.r = this.hexToNumber(color.r || 0);
|
|
4541
4839
|
color.g = this.hexToNumber(color.g || 0);
|
|
4542
4840
|
color.b = this.hexToNumber(color.b || 0);
|
|
4543
|
-
|
|
4841
|
+
res = color;
|
|
4544
4842
|
} //如果是5位的话,# 则第2位表示A,后面依次是r,g,b
|
|
4545
|
-
else if (
|
|
4546
|
-
color.a =
|
|
4547
|
-
color.g =
|
|
4843
|
+
else if (res.length === 5) {
|
|
4844
|
+
color.a = res.substr(1, 1);
|
|
4845
|
+
color.g = res.substr(3, 1); //除#号外的第二位
|
|
4548
4846
|
|
|
4549
|
-
color.b =
|
|
4550
|
-
color.r =
|
|
4847
|
+
color.b = res.substr(4, 1);
|
|
4848
|
+
color.r = res.substr(2, 1);
|
|
4551
4849
|
color.r = this.hexToNumber(color.r || 0);
|
|
4552
4850
|
color.g = this.hexToNumber(color.g || 0);
|
|
4553
4851
|
color.b = this.hexToNumber(color.b || 0); //透明度
|
|
4554
4852
|
|
|
4555
|
-
color.a = (this.hexToNumber(color.a) / 255).toFixed(4);
|
|
4556
|
-
|
|
4853
|
+
color.a = Number((this.hexToNumber(color.a) / 255).toFixed(4));
|
|
4854
|
+
res = color;
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
|
|
4858
|
+
if (typeof res === 'string') {
|
|
4859
|
+
var m = res.match(/rgb(a)?\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)\s*,\s*([\d\.]+)\s*(,\s*[\d\.]+)?\s*\)/i);
|
|
4860
|
+
|
|
4861
|
+
if (m && m.length === 6) {
|
|
4862
|
+
var _color = {
|
|
4863
|
+
r: Number(m[2]),
|
|
4864
|
+
g: Number(m[3]),
|
|
4865
|
+
b: Number(m[4]),
|
|
4866
|
+
a: Number(this.trimStart(m[5] || '1', ','))
|
|
4867
|
+
};
|
|
4868
|
+
res = _color;
|
|
4557
4869
|
}
|
|
4558
4870
|
}
|
|
4559
4871
|
|
|
4560
|
-
return hex;
|
|
4872
|
+
return this.__hexToRGBA_Cache[hex] = res;
|
|
4873
|
+
}
|
|
4874
|
+
/**
|
|
4875
|
+
* 把255的rgb值转为0-1的值
|
|
4876
|
+
* @param {rgba} color 颜色
|
|
4877
|
+
*/
|
|
4878
|
+
|
|
4879
|
+
}, {
|
|
4880
|
+
key: "rgbToDecimal",
|
|
4881
|
+
value: function rgbToDecimal(color) {
|
|
4882
|
+
color = this.clone(color);
|
|
4883
|
+
color.r = this.byteToDecimal(color.r);
|
|
4884
|
+
color.g = this.byteToDecimal(color.g);
|
|
4885
|
+
color.b = this.byteToDecimal(color.b);
|
|
4886
|
+
return color;
|
|
4887
|
+
} //255值转为0-1的小数
|
|
4888
|
+
|
|
4889
|
+
}, {
|
|
4890
|
+
key: "byteToDecimal",
|
|
4891
|
+
value: function byteToDecimal(b) {
|
|
4892
|
+
return b / 255;
|
|
4561
4893
|
}
|
|
4562
4894
|
/**
|
|
4563
4895
|
* 转换颜色格式,如果输入r,g,b则转为hex格式,如果为hex则转为r,g,b格式
|
|
@@ -4577,10 +4909,10 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4577
4909
|
if (r[0] === '#' && (r.length === 4 || r.length === 7)) return r;
|
|
4578
4910
|
var color = this.hexToRGBA(r);
|
|
4579
4911
|
if (typeof color === 'string') return color;
|
|
4580
|
-
r = color.r
|
|
4581
|
-
g = color.g
|
|
4582
|
-
b = color.b
|
|
4583
|
-
a = color.a
|
|
4912
|
+
r = typeof color.r !== 'undefined' ? color.r : r;
|
|
4913
|
+
g = typeof color.g !== 'undefined' ? color.g : g;
|
|
4914
|
+
b = typeof color.b !== 'undefined' ? color.b : b;
|
|
4915
|
+
a = typeof color.a !== 'undefined' ? color.a : a;
|
|
4584
4916
|
}
|
|
4585
4917
|
|
|
4586
4918
|
if (typeof r != 'undefined' && typeof g != 'undefined' && typeof b != 'undefined') {
|
|
@@ -4614,150 +4946,2478 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4614
4946
|
exports.jmUtils = exports["default"] = jmUtils;
|
|
4615
4947
|
|
|
4616
4948
|
},{"./jmList.js":6}],12:[function(require,module,exports){
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4949
|
+
'use strict';
|
|
4620
4950
|
|
|
4621
4951
|
Object.defineProperty(exports, "__esModule", {
|
|
4622
4952
|
value: true
|
|
4623
4953
|
});
|
|
4624
|
-
exports
|
|
4954
|
+
exports["default"] = void 0;
|
|
4955
|
+
var _default = earcut;
|
|
4956
|
+
exports["default"] = _default;
|
|
4957
|
+
|
|
4958
|
+
function earcut(data, holeIndices, dim) {
|
|
4959
|
+
dim = dim || 2;
|
|
4960
|
+
var hasHoles = holeIndices && holeIndices.length,
|
|
4961
|
+
outerLen = hasHoles ? holeIndices[0] * dim : data.length,
|
|
4962
|
+
outerNode = linkedList(data, 0, outerLen, dim, true),
|
|
4963
|
+
triangles = [];
|
|
4964
|
+
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
|
|
4965
|
+
var minX, minY, maxX, maxY, x, y, invSize;
|
|
4966
|
+
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
4967
|
+
|
|
4968
|
+
if (data.length > 80 * dim) {
|
|
4969
|
+
minX = maxX = data[0];
|
|
4970
|
+
minY = maxY = data[1];
|
|
4971
|
+
|
|
4972
|
+
for (var i = dim; i < outerLen; i += dim) {
|
|
4973
|
+
x = data[i];
|
|
4974
|
+
y = data[i + 1];
|
|
4975
|
+
if (x < minX) minX = x;
|
|
4976
|
+
if (y < minY) minY = y;
|
|
4977
|
+
if (x > maxX) maxX = x;
|
|
4978
|
+
if (y > maxY) maxY = y;
|
|
4979
|
+
} // minX, minY and invSize are later used to transform coords into integers for z-order calculation
|
|
4980
|
+
|
|
4981
|
+
|
|
4982
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
4983
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
4984
|
+
}
|
|
4625
4985
|
|
|
4626
|
-
|
|
4986
|
+
earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
|
|
4987
|
+
return triangles;
|
|
4988
|
+
} // create a circular doubly linked list from polygon points in the specified winding order
|
|
4627
4989
|
|
|
4628
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4629
4990
|
|
|
4630
|
-
function
|
|
4991
|
+
function linkedList(data, start, end, dim, clockwise) {
|
|
4992
|
+
var i, last;
|
|
4631
4993
|
|
|
4632
|
-
|
|
4994
|
+
if (clockwise === signedArea(data, start, end, dim) > 0) {
|
|
4995
|
+
for (i = start; i < end; i += dim) {
|
|
4996
|
+
last = insertNode(i, data[i], data[i + 1], last);
|
|
4997
|
+
}
|
|
4998
|
+
} else {
|
|
4999
|
+
for (i = end - dim; i >= start; i -= dim) {
|
|
5000
|
+
last = insertNode(i, data[i], data[i + 1], last);
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
4633
5003
|
|
|
4634
|
-
|
|
5004
|
+
if (last && equals(last, last.next)) {
|
|
5005
|
+
removeNode(last);
|
|
5006
|
+
last = last.next;
|
|
5007
|
+
}
|
|
4635
5008
|
|
|
4636
|
-
|
|
5009
|
+
return last;
|
|
5010
|
+
} // eliminate colinear or duplicate points
|
|
4637
5011
|
|
|
4638
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
4639
5012
|
|
|
4640
|
-
function
|
|
5013
|
+
function filterPoints(start, end) {
|
|
5014
|
+
if (!start) return start;
|
|
5015
|
+
if (!end) end = start;
|
|
5016
|
+
var p = start,
|
|
5017
|
+
again;
|
|
4641
5018
|
|
|
4642
|
-
|
|
5019
|
+
do {
|
|
5020
|
+
again = false;
|
|
4643
5021
|
|
|
4644
|
-
|
|
5022
|
+
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
5023
|
+
removeNode(p);
|
|
5024
|
+
p = end = p.prev;
|
|
5025
|
+
if (p === p.next) break;
|
|
5026
|
+
again = true;
|
|
5027
|
+
} else {
|
|
5028
|
+
p = p.next;
|
|
5029
|
+
}
|
|
5030
|
+
} while (again || p !== end);
|
|
4645
5031
|
|
|
4646
|
-
|
|
5032
|
+
return end;
|
|
5033
|
+
} // main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
4647
5034
|
|
|
4648
|
-
/**
|
|
4649
|
-
* 圆弧图型 继承自jmPath
|
|
4650
|
-
*
|
|
4651
|
-
* @class jmArc
|
|
4652
|
-
* @extends jmPath
|
|
4653
|
-
* @param {object} params center=当前圆弧中心,radius=圆弧半径,start=圆弧起始角度,end=圆弧结束角度,anticlockwise= false 顺时针,true 逆时针
|
|
4654
|
-
*/
|
|
4655
|
-
var jmArc = /*#__PURE__*/function (_jmPath) {
|
|
4656
|
-
_inherits(jmArc, _jmPath);
|
|
4657
5035
|
|
|
4658
|
-
|
|
5036
|
+
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
|
|
5037
|
+
if (!ear) return; // interlink polygon nodes in z-order
|
|
4659
5038
|
|
|
4660
|
-
|
|
4661
|
-
|
|
5039
|
+
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
|
|
5040
|
+
var stop = ear,
|
|
5041
|
+
prev,
|
|
5042
|
+
next; // iterate through ears, slicing them one by one
|
|
4662
5043
|
|
|
4663
|
-
|
|
5044
|
+
while (ear.prev !== ear.next) {
|
|
5045
|
+
prev = ear.prev;
|
|
5046
|
+
next = ear.next;
|
|
4664
5047
|
|
|
4665
|
-
|
|
5048
|
+
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
5049
|
+
// cut off the triangle
|
|
5050
|
+
triangles.push(prev.i / dim | 0);
|
|
5051
|
+
triangles.push(ear.i / dim | 0);
|
|
5052
|
+
triangles.push(next.i / dim | 0);
|
|
5053
|
+
removeNode(ear); // skipping the next vertex leads to less sliver triangles
|
|
4666
5054
|
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
y: 0
|
|
4672
|
-
};
|
|
4673
|
-
_this.radius = params.radius || 0;
|
|
4674
|
-
_this.startAngle = params.start || params.startAngle || 0;
|
|
4675
|
-
_this.endAngle = params.end || params.endAngle || Math.PI * 2;
|
|
4676
|
-
_this.anticlockwise = params.anticlockwise || 0;
|
|
4677
|
-
_this.isFan = !!params.isFan;
|
|
4678
|
-
return _this;
|
|
4679
|
-
}
|
|
4680
|
-
/**
|
|
4681
|
-
* 中心点
|
|
4682
|
-
* point格式:{x:0,y:0,m:true}
|
|
4683
|
-
* @property center
|
|
4684
|
-
* @type {point}
|
|
4685
|
-
*/
|
|
5055
|
+
ear = next.next;
|
|
5056
|
+
stop = next.next;
|
|
5057
|
+
continue;
|
|
5058
|
+
}
|
|
4686
5059
|
|
|
5060
|
+
ear = next; // if we looped through the whole remaining polygon and can't find any more ears
|
|
4687
5061
|
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
* 半径
|
|
4699
|
-
* @property radius
|
|
4700
|
-
* @type {number}
|
|
4701
|
-
*/
|
|
5062
|
+
if (ear === stop) {
|
|
5063
|
+
// try filtering points and slicing again
|
|
5064
|
+
if (!pass) {
|
|
5065
|
+
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); // if this didn't work, try curing all small self-intersections locally
|
|
5066
|
+
} else if (pass === 1) {
|
|
5067
|
+
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
|
|
5068
|
+
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); // as a last resort, try splitting the remaining polygon into two
|
|
5069
|
+
} else if (pass === 2) {
|
|
5070
|
+
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
5071
|
+
}
|
|
4702
5072
|
|
|
4703
|
-
|
|
4704
|
-
key: "radius",
|
|
4705
|
-
get: function get() {
|
|
4706
|
-
return this.__pro('radius');
|
|
4707
|
-
},
|
|
4708
|
-
set: function set(v) {
|
|
4709
|
-
this.needUpdate = true;
|
|
4710
|
-
return this.__pro('radius', v);
|
|
5073
|
+
break;
|
|
4711
5074
|
}
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
5075
|
+
}
|
|
5076
|
+
} // check whether a polygon node forms a valid ear with adjacent nodes
|
|
5077
|
+
|
|
5078
|
+
|
|
5079
|
+
function isEar(ear) {
|
|
5080
|
+
var a = ear.prev,
|
|
5081
|
+
b = ear,
|
|
5082
|
+
c = ear.next;
|
|
5083
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
5084
|
+
// now make sure we don't have other points inside the potential ear
|
|
5085
|
+
|
|
5086
|
+
var ax = a.x,
|
|
5087
|
+
bx = b.x,
|
|
5088
|
+
cx = c.x,
|
|
5089
|
+
ay = a.y,
|
|
5090
|
+
by = b.y,
|
|
5091
|
+
cy = c.y; // triangle bbox; min & max are calculated like this for speed
|
|
5092
|
+
|
|
5093
|
+
var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
|
|
5094
|
+
y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
|
|
5095
|
+
x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
|
|
5096
|
+
y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
|
|
5097
|
+
var p = c.next;
|
|
5098
|
+
|
|
5099
|
+
while (p !== a) {
|
|
5100
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
5101
|
+
p = p.next;
|
|
5102
|
+
}
|
|
4717
5103
|
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
5104
|
+
return true;
|
|
5105
|
+
}
|
|
5106
|
+
|
|
5107
|
+
function isEarHashed(ear, minX, minY, invSize) {
|
|
5108
|
+
var a = ear.prev,
|
|
5109
|
+
b = ear,
|
|
5110
|
+
c = ear.next;
|
|
5111
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
5112
|
+
|
|
5113
|
+
var ax = a.x,
|
|
5114
|
+
bx = b.x,
|
|
5115
|
+
cx = c.x,
|
|
5116
|
+
ay = a.y,
|
|
5117
|
+
by = b.y,
|
|
5118
|
+
cy = c.y; // triangle bbox; min & max are calculated like this for speed
|
|
5119
|
+
|
|
5120
|
+
var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx,
|
|
5121
|
+
y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy,
|
|
5122
|
+
x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx,
|
|
5123
|
+
y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy; // z-order range for the current triangle bbox;
|
|
5124
|
+
|
|
5125
|
+
var minZ = zOrder(x0, y0, minX, minY, invSize),
|
|
5126
|
+
maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
5127
|
+
var p = ear.prevZ,
|
|
5128
|
+
n = ear.nextZ; // look for points inside the triangle in both directions
|
|
5129
|
+
|
|
5130
|
+
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
5131
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
5132
|
+
p = p.prevZ;
|
|
5133
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
5134
|
+
n = n.nextZ;
|
|
5135
|
+
} // look for remaining points in decreasing z-order
|
|
5136
|
+
|
|
5137
|
+
|
|
5138
|
+
while (p && p.z >= minZ) {
|
|
5139
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
|
|
5140
|
+
p = p.prevZ;
|
|
5141
|
+
} // look for remaining points in increasing z-order
|
|
5142
|
+
|
|
5143
|
+
|
|
5144
|
+
while (n && n.z <= maxZ) {
|
|
5145
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
|
|
5146
|
+
n = n.nextZ;
|
|
5147
|
+
}
|
|
4732
5148
|
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
get: function get() {
|
|
4736
|
-
return this.__pro('endAngle');
|
|
4737
|
-
},
|
|
4738
|
-
set: function set(v) {
|
|
4739
|
-
this.needUpdate = true;
|
|
4740
|
-
return this.__pro('endAngle', v);
|
|
4741
|
-
}
|
|
4742
|
-
/**
|
|
4743
|
-
* 可选。规定应该逆时针还是顺时针绘图
|
|
4744
|
-
* false 顺时针,true 逆时针
|
|
4745
|
-
* @property anticlockwise
|
|
4746
|
-
* @type {boolean}
|
|
4747
|
-
*/
|
|
5149
|
+
return true;
|
|
5150
|
+
} // go through all polygon nodes and cure small local self-intersections
|
|
4748
5151
|
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
5152
|
+
|
|
5153
|
+
function cureLocalIntersections(start, triangles, dim) {
|
|
5154
|
+
var p = start;
|
|
5155
|
+
|
|
5156
|
+
do {
|
|
5157
|
+
var a = p.prev,
|
|
5158
|
+
b = p.next.next;
|
|
5159
|
+
|
|
5160
|
+
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
5161
|
+
triangles.push(a.i / dim | 0);
|
|
5162
|
+
triangles.push(p.i / dim | 0);
|
|
5163
|
+
triangles.push(b.i / dim | 0); // remove two nodes involved
|
|
5164
|
+
|
|
5165
|
+
removeNode(p);
|
|
5166
|
+
removeNode(p.next);
|
|
5167
|
+
p = start = b;
|
|
4757
5168
|
}
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
5169
|
+
|
|
5170
|
+
p = p.next;
|
|
5171
|
+
} while (p !== start);
|
|
5172
|
+
|
|
5173
|
+
return filterPoints(p);
|
|
5174
|
+
} // try splitting polygon into two and triangulate them independently
|
|
5175
|
+
|
|
5176
|
+
|
|
5177
|
+
function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
5178
|
+
// look for a valid diagonal that divides the polygon into two
|
|
5179
|
+
var a = start;
|
|
5180
|
+
|
|
5181
|
+
do {
|
|
5182
|
+
var b = a.next.next;
|
|
5183
|
+
|
|
5184
|
+
while (b !== a.prev) {
|
|
5185
|
+
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
5186
|
+
// split the polygon in two by the diagonal
|
|
5187
|
+
var c = splitPolygon(a, b); // filter colinear points around the cuts
|
|
5188
|
+
|
|
5189
|
+
a = filterPoints(a, a.next);
|
|
5190
|
+
c = filterPoints(c, c.next); // run earcut on each half
|
|
5191
|
+
|
|
5192
|
+
earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
|
|
5193
|
+
earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
|
|
5194
|
+
return;
|
|
5195
|
+
}
|
|
5196
|
+
|
|
5197
|
+
b = b.next;
|
|
5198
|
+
}
|
|
5199
|
+
|
|
5200
|
+
a = a.next;
|
|
5201
|
+
} while (a !== start);
|
|
5202
|
+
} // link every hole into the outer loop, producing a single-ring polygon without holes
|
|
5203
|
+
|
|
5204
|
+
|
|
5205
|
+
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
5206
|
+
var queue = [],
|
|
5207
|
+
i,
|
|
5208
|
+
len,
|
|
5209
|
+
start,
|
|
5210
|
+
end,
|
|
5211
|
+
list;
|
|
5212
|
+
|
|
5213
|
+
for (i = 0, len = holeIndices.length; i < len; i++) {
|
|
5214
|
+
start = holeIndices[i] * dim;
|
|
5215
|
+
end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
5216
|
+
list = linkedList(data, start, end, dim, false);
|
|
5217
|
+
if (list === list.next) list.steiner = true;
|
|
5218
|
+
queue.push(getLeftmost(list));
|
|
5219
|
+
}
|
|
5220
|
+
|
|
5221
|
+
queue.sort(compareX); // process holes from left to right
|
|
5222
|
+
|
|
5223
|
+
for (i = 0; i < queue.length; i++) {
|
|
5224
|
+
outerNode = eliminateHole(queue[i], outerNode);
|
|
5225
|
+
}
|
|
5226
|
+
|
|
5227
|
+
return outerNode;
|
|
5228
|
+
}
|
|
5229
|
+
|
|
5230
|
+
function compareX(a, b) {
|
|
5231
|
+
return a.x - b.x;
|
|
5232
|
+
} // find a bridge between vertices that connects hole with an outer ring and and link it
|
|
5233
|
+
|
|
5234
|
+
|
|
5235
|
+
function eliminateHole(hole, outerNode) {
|
|
5236
|
+
var bridge = findHoleBridge(hole, outerNode);
|
|
5237
|
+
|
|
5238
|
+
if (!bridge) {
|
|
5239
|
+
return outerNode;
|
|
5240
|
+
}
|
|
5241
|
+
|
|
5242
|
+
var bridgeReverse = splitPolygon(bridge, hole); // filter collinear points around the cuts
|
|
5243
|
+
|
|
5244
|
+
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
5245
|
+
return filterPoints(bridge, bridge.next);
|
|
5246
|
+
} // David Eberly's algorithm for finding a bridge between hole and outer polygon
|
|
5247
|
+
|
|
5248
|
+
|
|
5249
|
+
function findHoleBridge(hole, outerNode) {
|
|
5250
|
+
var p = outerNode,
|
|
5251
|
+
hx = hole.x,
|
|
5252
|
+
hy = hole.y,
|
|
5253
|
+
qx = -Infinity,
|
|
5254
|
+
m; // find a segment intersected by a ray from the hole's leftmost point to the left;
|
|
5255
|
+
// segment's endpoint with lesser x will be potential connection point
|
|
5256
|
+
|
|
5257
|
+
do {
|
|
5258
|
+
if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
5259
|
+
var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
5260
|
+
|
|
5261
|
+
if (x <= hx && x > qx) {
|
|
5262
|
+
qx = x;
|
|
5263
|
+
m = p.x < p.next.x ? p : p.next;
|
|
5264
|
+
if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
|
|
5268
|
+
p = p.next;
|
|
5269
|
+
} while (p !== outerNode);
|
|
5270
|
+
|
|
5271
|
+
if (!m) return null; // look for points inside the triangle of hole point, segment intersection and endpoint;
|
|
5272
|
+
// if there are no points found, we have a valid connection;
|
|
5273
|
+
// otherwise choose the point of the minimum angle with the ray as connection point
|
|
5274
|
+
|
|
5275
|
+
var stop = m,
|
|
5276
|
+
mx = m.x,
|
|
5277
|
+
my = m.y,
|
|
5278
|
+
tanMin = Infinity,
|
|
5279
|
+
tan;
|
|
5280
|
+
p = m;
|
|
5281
|
+
|
|
5282
|
+
do {
|
|
5283
|
+
if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
5284
|
+
tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
|
|
5285
|
+
|
|
5286
|
+
if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
|
|
5287
|
+
m = p;
|
|
5288
|
+
tanMin = tan;
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
p = p.next;
|
|
5293
|
+
} while (p !== stop);
|
|
5294
|
+
|
|
5295
|
+
return m;
|
|
5296
|
+
} // whether sector in vertex m contains sector in vertex p in the same coordinates
|
|
5297
|
+
|
|
5298
|
+
|
|
5299
|
+
function sectorContainsSector(m, p) {
|
|
5300
|
+
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
5301
|
+
} // interlink polygon nodes in z-order
|
|
5302
|
+
|
|
5303
|
+
|
|
5304
|
+
function indexCurve(start, minX, minY, invSize) {
|
|
5305
|
+
var p = start;
|
|
5306
|
+
|
|
5307
|
+
do {
|
|
5308
|
+
if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
5309
|
+
p.prevZ = p.prev;
|
|
5310
|
+
p.nextZ = p.next;
|
|
5311
|
+
p = p.next;
|
|
5312
|
+
} while (p !== start);
|
|
5313
|
+
|
|
5314
|
+
p.prevZ.nextZ = null;
|
|
5315
|
+
p.prevZ = null;
|
|
5316
|
+
sortLinked(p);
|
|
5317
|
+
} // Simon Tatham's linked list merge sort algorithm
|
|
5318
|
+
// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
|
|
5319
|
+
|
|
5320
|
+
|
|
5321
|
+
function sortLinked(list) {
|
|
5322
|
+
var i,
|
|
5323
|
+
p,
|
|
5324
|
+
q,
|
|
5325
|
+
e,
|
|
5326
|
+
tail,
|
|
5327
|
+
numMerges,
|
|
5328
|
+
pSize,
|
|
5329
|
+
qSize,
|
|
5330
|
+
inSize = 1;
|
|
5331
|
+
|
|
5332
|
+
do {
|
|
5333
|
+
p = list;
|
|
5334
|
+
list = null;
|
|
5335
|
+
tail = null;
|
|
5336
|
+
numMerges = 0;
|
|
5337
|
+
|
|
5338
|
+
while (p) {
|
|
5339
|
+
numMerges++;
|
|
5340
|
+
q = p;
|
|
5341
|
+
pSize = 0;
|
|
5342
|
+
|
|
5343
|
+
for (i = 0; i < inSize; i++) {
|
|
5344
|
+
pSize++;
|
|
5345
|
+
q = q.nextZ;
|
|
5346
|
+
if (!q) break;
|
|
5347
|
+
}
|
|
5348
|
+
|
|
5349
|
+
qSize = inSize;
|
|
5350
|
+
|
|
5351
|
+
while (pSize > 0 || qSize > 0 && q) {
|
|
5352
|
+
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
5353
|
+
e = p;
|
|
5354
|
+
p = p.nextZ;
|
|
5355
|
+
pSize--;
|
|
5356
|
+
} else {
|
|
5357
|
+
e = q;
|
|
5358
|
+
q = q.nextZ;
|
|
5359
|
+
qSize--;
|
|
5360
|
+
}
|
|
5361
|
+
|
|
5362
|
+
if (tail) tail.nextZ = e;else list = e;
|
|
5363
|
+
e.prevZ = tail;
|
|
5364
|
+
tail = e;
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
p = q;
|
|
5368
|
+
}
|
|
5369
|
+
|
|
5370
|
+
tail.nextZ = null;
|
|
5371
|
+
inSize *= 2;
|
|
5372
|
+
} while (numMerges > 1);
|
|
5373
|
+
|
|
5374
|
+
return list;
|
|
5375
|
+
} // z-order of a point given coords and inverse of the longer side of data bbox
|
|
5376
|
+
|
|
5377
|
+
|
|
5378
|
+
function zOrder(x, y, minX, minY, invSize) {
|
|
5379
|
+
// coords are transformed into non-negative 15-bit integer range
|
|
5380
|
+
x = (x - minX) * invSize | 0;
|
|
5381
|
+
y = (y - minY) * invSize | 0;
|
|
5382
|
+
x = (x | x << 8) & 0x00FF00FF;
|
|
5383
|
+
x = (x | x << 4) & 0x0F0F0F0F;
|
|
5384
|
+
x = (x | x << 2) & 0x33333333;
|
|
5385
|
+
x = (x | x << 1) & 0x55555555;
|
|
5386
|
+
y = (y | y << 8) & 0x00FF00FF;
|
|
5387
|
+
y = (y | y << 4) & 0x0F0F0F0F;
|
|
5388
|
+
y = (y | y << 2) & 0x33333333;
|
|
5389
|
+
y = (y | y << 1) & 0x55555555;
|
|
5390
|
+
return x | y << 1;
|
|
5391
|
+
} // find the leftmost node of a polygon ring
|
|
5392
|
+
|
|
5393
|
+
|
|
5394
|
+
function getLeftmost(start) {
|
|
5395
|
+
var p = start,
|
|
5396
|
+
leftmost = start;
|
|
5397
|
+
|
|
5398
|
+
do {
|
|
5399
|
+
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
|
|
5400
|
+
p = p.next;
|
|
5401
|
+
} while (p !== start);
|
|
5402
|
+
|
|
5403
|
+
return leftmost;
|
|
5404
|
+
} // check if a point lies within a convex triangle
|
|
5405
|
+
|
|
5406
|
+
|
|
5407
|
+
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
5408
|
+
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
5409
|
+
} // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
|
|
5410
|
+
|
|
5411
|
+
|
|
5412
|
+
function isValidDiagonal(a, b) {
|
|
5413
|
+
return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
|
|
5414
|
+
equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
|
|
5415
|
+
} // signed area of a triangle
|
|
5416
|
+
|
|
5417
|
+
|
|
5418
|
+
function area(p, q, r) {
|
|
5419
|
+
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
5420
|
+
} // check if two points are equal
|
|
5421
|
+
|
|
5422
|
+
|
|
5423
|
+
function equals(p1, p2) {
|
|
5424
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
5425
|
+
} // check if two segments intersect
|
|
5426
|
+
|
|
5427
|
+
|
|
5428
|
+
function intersects(p1, q1, p2, q2) {
|
|
5429
|
+
var o1 = sign(area(p1, q1, p2));
|
|
5430
|
+
var o2 = sign(area(p1, q1, q2));
|
|
5431
|
+
var o3 = sign(area(p2, q2, p1));
|
|
5432
|
+
var o4 = sign(area(p2, q2, q1));
|
|
5433
|
+
if (o1 !== o2 && o3 !== o4) return true; // general case
|
|
5434
|
+
|
|
5435
|
+
if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1
|
|
5436
|
+
|
|
5437
|
+
if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1
|
|
5438
|
+
|
|
5439
|
+
if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2
|
|
5440
|
+
|
|
5441
|
+
if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2
|
|
5442
|
+
|
|
5443
|
+
return false;
|
|
5444
|
+
} // for collinear points p, q, r, check if point q lies on segment pr
|
|
5445
|
+
|
|
5446
|
+
|
|
5447
|
+
function onSegment(p, q, r) {
|
|
5448
|
+
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
5449
|
+
}
|
|
5450
|
+
|
|
5451
|
+
function sign(num) {
|
|
5452
|
+
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
5453
|
+
} // check if a polygon diagonal intersects any polygon segments
|
|
5454
|
+
|
|
5455
|
+
|
|
5456
|
+
function intersectsPolygon(a, b) {
|
|
5457
|
+
var p = a;
|
|
5458
|
+
|
|
5459
|
+
do {
|
|
5460
|
+
if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;
|
|
5461
|
+
p = p.next;
|
|
5462
|
+
} while (p !== a);
|
|
5463
|
+
|
|
5464
|
+
return false;
|
|
5465
|
+
} // check if a polygon diagonal is locally inside the polygon
|
|
5466
|
+
|
|
5467
|
+
|
|
5468
|
+
function locallyInside(a, b) {
|
|
5469
|
+
return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
5470
|
+
} // check if the middle point of a polygon diagonal is inside the polygon
|
|
5471
|
+
|
|
5472
|
+
|
|
5473
|
+
function middleInside(a, b) {
|
|
5474
|
+
var p = a,
|
|
5475
|
+
inside = false,
|
|
5476
|
+
px = (a.x + b.x) / 2,
|
|
5477
|
+
py = (a.y + b.y) / 2;
|
|
5478
|
+
|
|
5479
|
+
do {
|
|
5480
|
+
if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) inside = !inside;
|
|
5481
|
+
p = p.next;
|
|
5482
|
+
} while (p !== a);
|
|
5483
|
+
|
|
5484
|
+
return inside;
|
|
5485
|
+
} // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
|
|
5486
|
+
// if one belongs to the outer ring and another to a hole, it merges it into a single ring
|
|
5487
|
+
|
|
5488
|
+
|
|
5489
|
+
function splitPolygon(a, b) {
|
|
5490
|
+
var a2 = new Node(a.i, a.x, a.y),
|
|
5491
|
+
b2 = new Node(b.i, b.x, b.y),
|
|
5492
|
+
an = a.next,
|
|
5493
|
+
bp = b.prev;
|
|
5494
|
+
a.next = b;
|
|
5495
|
+
b.prev = a;
|
|
5496
|
+
a2.next = an;
|
|
5497
|
+
an.prev = a2;
|
|
5498
|
+
b2.next = a2;
|
|
5499
|
+
a2.prev = b2;
|
|
5500
|
+
bp.next = b2;
|
|
5501
|
+
b2.prev = bp;
|
|
5502
|
+
return b2;
|
|
5503
|
+
} // create a node and optionally link it with previous one (in a circular doubly linked list)
|
|
5504
|
+
|
|
5505
|
+
|
|
5506
|
+
function insertNode(i, x, y, last) {
|
|
5507
|
+
var p = new Node(i, x, y);
|
|
5508
|
+
|
|
5509
|
+
if (!last) {
|
|
5510
|
+
p.prev = p;
|
|
5511
|
+
p.next = p;
|
|
5512
|
+
} else {
|
|
5513
|
+
p.next = last.next;
|
|
5514
|
+
p.prev = last;
|
|
5515
|
+
last.next.prev = p;
|
|
5516
|
+
last.next = p;
|
|
5517
|
+
}
|
|
5518
|
+
|
|
5519
|
+
return p;
|
|
5520
|
+
}
|
|
5521
|
+
|
|
5522
|
+
function removeNode(p) {
|
|
5523
|
+
p.next.prev = p.prev;
|
|
5524
|
+
p.prev.next = p.next;
|
|
5525
|
+
if (p.prevZ) p.prevZ.nextZ = p.nextZ;
|
|
5526
|
+
if (p.nextZ) p.nextZ.prevZ = p.prevZ;
|
|
5527
|
+
}
|
|
5528
|
+
|
|
5529
|
+
function Node(i, x, y) {
|
|
5530
|
+
// vertex index in coordinates array
|
|
5531
|
+
this.i = i; // vertex coordinates
|
|
5532
|
+
|
|
5533
|
+
this.x = x;
|
|
5534
|
+
this.y = y; // previous and next vertex nodes in a polygon ring
|
|
5535
|
+
|
|
5536
|
+
this.prev = null;
|
|
5537
|
+
this.next = null; // z-order curve value
|
|
5538
|
+
|
|
5539
|
+
this.z = 0; // previous and next nodes in z-order
|
|
5540
|
+
|
|
5541
|
+
this.prevZ = null;
|
|
5542
|
+
this.nextZ = null; // indicates whether this is a steiner point
|
|
5543
|
+
|
|
5544
|
+
this.steiner = false;
|
|
5545
|
+
} // return a percentage difference between the polygon area and its triangulation area;
|
|
5546
|
+
// used to verify correctness of triangulation
|
|
5547
|
+
|
|
5548
|
+
|
|
5549
|
+
earcut.deviation = function (data, holeIndices, dim, triangles) {
|
|
5550
|
+
var hasHoles = holeIndices && holeIndices.length;
|
|
5551
|
+
var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
5552
|
+
var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
|
|
5553
|
+
|
|
5554
|
+
if (hasHoles) {
|
|
5555
|
+
for (var i = 0, len = holeIndices.length; i < len; i++) {
|
|
5556
|
+
var start = holeIndices[i] * dim;
|
|
5557
|
+
var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
5558
|
+
polygonArea -= Math.abs(signedArea(data, start, end, dim));
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
|
|
5562
|
+
var trianglesArea = 0;
|
|
5563
|
+
|
|
5564
|
+
for (i = 0; i < triangles.length; i += 3) {
|
|
5565
|
+
var a = triangles[i] * dim;
|
|
5566
|
+
var b = triangles[i + 1] * dim;
|
|
5567
|
+
var c = triangles[i + 2] * dim;
|
|
5568
|
+
trianglesArea += Math.abs((data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
|
|
5569
|
+
}
|
|
5570
|
+
|
|
5571
|
+
return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
|
|
5572
|
+
};
|
|
5573
|
+
|
|
5574
|
+
function signedArea(data, start, end, dim) {
|
|
5575
|
+
var sum = 0;
|
|
5576
|
+
|
|
5577
|
+
for (var i = start, j = end - dim; i < end; i += dim) {
|
|
5578
|
+
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
5579
|
+
j = i;
|
|
5580
|
+
}
|
|
5581
|
+
|
|
5582
|
+
return sum;
|
|
5583
|
+
} // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
|
|
5584
|
+
|
|
5585
|
+
|
|
5586
|
+
earcut.flatten = function (data) {
|
|
5587
|
+
var dim = data[0][0].length,
|
|
5588
|
+
result = {
|
|
5589
|
+
vertices: [],
|
|
5590
|
+
holes: [],
|
|
5591
|
+
dimensions: dim
|
|
5592
|
+
},
|
|
5593
|
+
holeIndex = 0;
|
|
5594
|
+
|
|
5595
|
+
for (var i = 0; i < data.length; i++) {
|
|
5596
|
+
for (var j = 0; j < data[i].length; j++) {
|
|
5597
|
+
for (var d = 0; d < dim; d++) {
|
|
5598
|
+
result.vertices.push(data[i][j][d]);
|
|
5599
|
+
}
|
|
5600
|
+
}
|
|
5601
|
+
|
|
5602
|
+
if (i > 0) {
|
|
5603
|
+
holeIndex += data[i - 1].length;
|
|
5604
|
+
result.holes.push(holeIndex);
|
|
5605
|
+
}
|
|
5606
|
+
}
|
|
5607
|
+
|
|
5608
|
+
return result;
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5611
|
+
},{}],13:[function(require,module,exports){
|
|
5612
|
+
"use strict";
|
|
5613
|
+
|
|
5614
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5615
|
+
value: true
|
|
5616
|
+
});
|
|
5617
|
+
exports["default"] = void 0;
|
|
5618
|
+
|
|
5619
|
+
var _earcut = _interopRequireDefault(require("../earcut.js"));
|
|
5620
|
+
|
|
5621
|
+
var _gradient = _interopRequireDefault(require("./gradient.js"));
|
|
5622
|
+
|
|
5623
|
+
var _program = require("./core/program.js");
|
|
5624
|
+
|
|
5625
|
+
var _buffer = require("./core/buffer.js");
|
|
5626
|
+
|
|
5627
|
+
var _texture = require("./core/texture.js");
|
|
5628
|
+
|
|
5629
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
5630
|
+
|
|
5631
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5632
|
+
|
|
5633
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5634
|
+
|
|
5635
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5636
|
+
|
|
5637
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5638
|
+
|
|
5639
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5640
|
+
|
|
5641
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
5642
|
+
|
|
5643
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5644
|
+
|
|
5645
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5646
|
+
|
|
5647
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5648
|
+
|
|
5649
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5650
|
+
|
|
5651
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
5652
|
+
|
|
5653
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
5654
|
+
|
|
5655
|
+
var WeblBase = /*#__PURE__*/function () {
|
|
5656
|
+
function WeblBase(graph, option) {
|
|
5657
|
+
_classCallCheck(this, WeblBase);
|
|
5658
|
+
|
|
5659
|
+
this.graph = graph;
|
|
5660
|
+
this.option = option || {};
|
|
5661
|
+
this.style = {
|
|
5662
|
+
globalAlpha: 1
|
|
5663
|
+
};
|
|
5664
|
+
}
|
|
5665
|
+
|
|
5666
|
+
_createClass(WeblBase, [{
|
|
5667
|
+
key: "context",
|
|
5668
|
+
get: function get() {
|
|
5669
|
+
if (this.graph) return this.graph.context;
|
|
5670
|
+
} // 创建程序
|
|
5671
|
+
|
|
5672
|
+
}, {
|
|
5673
|
+
key: "createProgram",
|
|
5674
|
+
value: function createProgram(vertexSrc, fragmentSrc) {
|
|
5675
|
+
return (0, _program.createProgram)(this.context, vertexSrc, fragmentSrc);
|
|
5676
|
+
} // 指定使用某个程序
|
|
5677
|
+
|
|
5678
|
+
}, {
|
|
5679
|
+
key: "useProgram",
|
|
5680
|
+
value: function useProgram() {
|
|
5681
|
+
var program = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.program;
|
|
5682
|
+
program = program.program || program;
|
|
5683
|
+
if (this.context.__curent_program === program) return program;
|
|
5684
|
+
(0, _program.useProgram)(this.context, program.program || program);
|
|
5685
|
+
this.context.__curent_program = program;
|
|
5686
|
+
return program;
|
|
5687
|
+
}
|
|
5688
|
+
}, {
|
|
5689
|
+
key: "getAttribLocation",
|
|
5690
|
+
value: function getAttribLocation(name) {
|
|
5691
|
+
return this.context.getAttribLocation(this.program.program, name);
|
|
5692
|
+
}
|
|
5693
|
+
}, {
|
|
5694
|
+
key: "getUniformLocation",
|
|
5695
|
+
value: function getUniformLocation(name) {
|
|
5696
|
+
return this.context.getUniformLocation(this.program.program, name);
|
|
5697
|
+
} // 把缓冲区的值写入变量
|
|
5698
|
+
// buffer: 缓冲区
|
|
5699
|
+
// size: 组成数量,必须是1,2,3或4. 每个单元由多少个数组成
|
|
5700
|
+
// strip: 步长 数组中一行长度,0 表示数据是紧密的没有空隙,让OpenGL决定具体步长
|
|
5701
|
+
// offset: 字节偏移量,必须是类型的字节长度的倍数。
|
|
5702
|
+
// dataType: 每个元素的数据类型
|
|
5703
|
+
|
|
5704
|
+
}, {
|
|
5705
|
+
key: "writeVertexAttrib",
|
|
5706
|
+
value: function writeVertexAttrib(buffer, attr) {
|
|
5707
|
+
var size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
|
|
5708
|
+
var strip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
5709
|
+
var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
5710
|
+
var dataType = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : this.context.FLOAT;
|
|
5711
|
+
buffer.attr = attr;
|
|
5712
|
+
return (0, _program.writeVertexAttrib)(this.context, buffer, attr, size, strip, offset, dataType);
|
|
5713
|
+
} // 禁用attri
|
|
5714
|
+
|
|
5715
|
+
}, {
|
|
5716
|
+
key: "disableVertexAttribArray",
|
|
5717
|
+
value: function disableVertexAttribArray(attr) {
|
|
5718
|
+
try {
|
|
5719
|
+
if (!attr) return attr;
|
|
5720
|
+
return (0, _program.disableVertexAttribArray)(this.context, attr);
|
|
5721
|
+
} catch (e) {
|
|
5722
|
+
console.error(e);
|
|
5723
|
+
}
|
|
5724
|
+
|
|
5725
|
+
return attr;
|
|
5726
|
+
} // 创建float32的buffer
|
|
5727
|
+
|
|
5728
|
+
}, {
|
|
5729
|
+
key: "createFloat32Buffer",
|
|
5730
|
+
value: function createFloat32Buffer(data) {
|
|
5731
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.context.ARRAY_BUFFER;
|
|
5732
|
+
var drawType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.context.STATIC_DRAW;
|
|
5733
|
+
var buffer = (0, _buffer.createFloat32Buffer)(this.context, data, type, drawType);
|
|
5734
|
+
return _objectSpread({
|
|
5735
|
+
data: data
|
|
5736
|
+
}, buffer);
|
|
5737
|
+
}
|
|
5738
|
+
}, {
|
|
5739
|
+
key: "createUint16Buffer",
|
|
5740
|
+
value: function createUint16Buffer(data) {
|
|
5741
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.context.ARRAY_BUFFER;
|
|
5742
|
+
var drawType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.context.STATIC_DRAW;
|
|
5743
|
+
var buffer = (0, _buffer.createUint16Buffer)(this.context, data, type, drawType);
|
|
5744
|
+
return _objectSpread({
|
|
5745
|
+
data: data
|
|
5746
|
+
}, buffer);
|
|
5747
|
+
} // 释放
|
|
5748
|
+
|
|
5749
|
+
}, {
|
|
5750
|
+
key: "deleteBuffer",
|
|
5751
|
+
value: function deleteBuffer(buffer) {
|
|
5752
|
+
try {
|
|
5753
|
+
if (!buffer) return;
|
|
5754
|
+
var bufferHandler = buffer.buffer || buffer;
|
|
5755
|
+
if (bufferHandler) return (0, _buffer.deleteBuffer)(this.context, bufferHandler);
|
|
5756
|
+
} catch (e) {
|
|
5757
|
+
console.log(buffer);
|
|
5758
|
+
console.error(e);
|
|
5759
|
+
}
|
|
5760
|
+
|
|
5761
|
+
return buffer;
|
|
5762
|
+
} // 生成纹理
|
|
5763
|
+
|
|
5764
|
+
}, {
|
|
5765
|
+
key: "create2DTexture",
|
|
5766
|
+
value: function create2DTexture() {
|
|
5767
|
+
return (0, _texture.create2DTexture)(this.context);
|
|
5768
|
+
} // 创建图片纹理
|
|
5769
|
+
|
|
5770
|
+
}, {
|
|
5771
|
+
key: "createImgTexture",
|
|
5772
|
+
value: function createImgTexture(img) {
|
|
5773
|
+
return (0, _texture.createImgTexture)(this.context, img);
|
|
5774
|
+
} // 根根像素值生成纹理
|
|
5775
|
+
|
|
5776
|
+
}, {
|
|
5777
|
+
key: "createDataTexture",
|
|
5778
|
+
value: function createDataTexture(data) {
|
|
5779
|
+
return (0, _texture.createDataTexture)(this.context, data);
|
|
5780
|
+
} // 删除纹理
|
|
5781
|
+
|
|
5782
|
+
}, {
|
|
5783
|
+
key: "deleteTexture",
|
|
5784
|
+
value: function deleteTexture(texture) {
|
|
5785
|
+
try {
|
|
5786
|
+
return (0, _texture.deleteTexture)(this.context, texture.texture || texture);
|
|
5787
|
+
} catch (e) {
|
|
5788
|
+
console.error(e);
|
|
5789
|
+
}
|
|
5790
|
+
|
|
5791
|
+
return texture;
|
|
5792
|
+
} // 多边切割, 得到三角形顶点索引数组
|
|
5793
|
+
// polygonIndices 顶点索引,
|
|
5794
|
+
|
|
5795
|
+
}, {
|
|
5796
|
+
key: "earCutPoints",
|
|
5797
|
+
value: function earCutPoints(points) {
|
|
5798
|
+
var arr = this.pointsToArray(points);
|
|
5799
|
+
var ps = (0, _earcut["default"])(arr); // 切割得到3角色顶点索引,
|
|
5800
|
+
|
|
5801
|
+
return ps;
|
|
5802
|
+
} // 多边切割, 得到三角形顶点
|
|
5803
|
+
// polygonIndices 顶点索引,
|
|
5804
|
+
|
|
5805
|
+
}, {
|
|
5806
|
+
key: "earCutPointsToTriangles",
|
|
5807
|
+
value: function earCutPointsToTriangles(points) {
|
|
5808
|
+
var ps = this.earCutPoints(points); // 切割得到3角色顶点索引,
|
|
5809
|
+
|
|
5810
|
+
var triangles = []; // 用顶点索引再组合成坐标数组
|
|
5811
|
+
|
|
5812
|
+
for (var i = 0; i < ps.length; i += 3) {
|
|
5813
|
+
var p1 = points[ps[i]];
|
|
5814
|
+
var p2 = points[ps[i + 1]];
|
|
5815
|
+
var p3 = points[ps[i + 2]];
|
|
5816
|
+
triangles.push([p1, p2, p3]); // 每三个顶点构成一个三角
|
|
5817
|
+
}
|
|
5818
|
+
|
|
5819
|
+
return triangles;
|
|
5820
|
+
} // 点坐标数组转为一维数组
|
|
5821
|
+
|
|
5822
|
+
}, {
|
|
5823
|
+
key: "pointsToArray",
|
|
5824
|
+
value: function pointsToArray(points) {
|
|
5825
|
+
var _ref;
|
|
5826
|
+
|
|
5827
|
+
return (_ref = []).concat.apply(_ref, _toConsumableArray(points.map(function (p) {
|
|
5828
|
+
return [p.x, p.y];
|
|
5829
|
+
}))); // 把x,y转为数组元素
|
|
5830
|
+
} // 每2位表示坐标x,y转为坐标点对象
|
|
5831
|
+
|
|
5832
|
+
}, {
|
|
5833
|
+
key: "arrayToPoints",
|
|
5834
|
+
value: function arrayToPoints(arr) {
|
|
5835
|
+
var points = [];
|
|
5836
|
+
|
|
5837
|
+
for (var i = 0; i < arr.length; i += 2) {
|
|
5838
|
+
points.push({
|
|
5839
|
+
x: arr[i],
|
|
5840
|
+
y: arr[i + 1]
|
|
5841
|
+
});
|
|
5842
|
+
}
|
|
5843
|
+
|
|
5844
|
+
return points;
|
|
5845
|
+
} // 创建线性渐变
|
|
5846
|
+
|
|
5847
|
+
}, {
|
|
5848
|
+
key: "createLinearGradient",
|
|
5849
|
+
value: function createLinearGradient(x1, y1, x2, y2, bounds) {
|
|
5850
|
+
return new _gradient["default"]('linear', {
|
|
5851
|
+
x1: x1,
|
|
5852
|
+
y1: y1,
|
|
5853
|
+
x2: x2,
|
|
5854
|
+
y2: y2,
|
|
5855
|
+
bounds: bounds,
|
|
5856
|
+
control: this
|
|
5857
|
+
});
|
|
5858
|
+
} // 创建放射性渐变
|
|
5859
|
+
|
|
5860
|
+
}, {
|
|
5861
|
+
key: "createRadialGradient",
|
|
5862
|
+
value: function createRadialGradient(x1, y1, r1, x2, y2, r2, bounds) {
|
|
5863
|
+
return new _gradient["default"]('radial', {
|
|
5864
|
+
x1: x1,
|
|
5865
|
+
y1: y1,
|
|
5866
|
+
r1: r1,
|
|
5867
|
+
x2: x2,
|
|
5868
|
+
y2: y2,
|
|
5869
|
+
r2: r2,
|
|
5870
|
+
bounds: bounds,
|
|
5871
|
+
control: this
|
|
5872
|
+
});
|
|
5873
|
+
} // 判断是否是一个渐变对象
|
|
5874
|
+
|
|
5875
|
+
}, {
|
|
5876
|
+
key: "isGradient",
|
|
5877
|
+
value: function isGradient(obj) {
|
|
5878
|
+
return obj && obj instanceof _gradient["default"];
|
|
5879
|
+
}
|
|
5880
|
+
}]);
|
|
5881
|
+
|
|
5882
|
+
return WeblBase;
|
|
5883
|
+
}();
|
|
5884
|
+
|
|
5885
|
+
var _default = WeblBase;
|
|
5886
|
+
exports["default"] = _default;
|
|
5887
|
+
|
|
5888
|
+
},{"../earcut.js":12,"./core/buffer.js":14,"./core/program.js":17,"./core/texture.js":19,"./gradient.js":20}],14:[function(require,module,exports){
|
|
5889
|
+
"use strict";
|
|
5890
|
+
|
|
5891
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5892
|
+
value: true
|
|
5893
|
+
});
|
|
5894
|
+
exports.createBuffer = createBuffer;
|
|
5895
|
+
exports.createUint16Buffer = createUint16Buffer;
|
|
5896
|
+
exports.createFloat32Buffer = createFloat32Buffer;
|
|
5897
|
+
exports.deleteBuffer = deleteBuffer;
|
|
5898
|
+
|
|
5899
|
+
// 创建缓冲区
|
|
5900
|
+
function createBuffer(gl, data) {
|
|
5901
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gl.ARRAY_BUFFER;
|
|
5902
|
+
var drawType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gl.STATIC_DRAW;
|
|
5903
|
+
//先创建一个缓存对象
|
|
5904
|
+
var buffer = gl.createBuffer();
|
|
5905
|
+
|
|
5906
|
+
if (!buffer) {
|
|
5907
|
+
throw Error('创建缓冲区对象失败');
|
|
5908
|
+
} //说明缓存对象保存的类型
|
|
5909
|
+
|
|
5910
|
+
|
|
5911
|
+
gl.bindBuffer(type, buffer); //写入坐标数据
|
|
5912
|
+
// 因为会将数据发送到 GPU,为了省去数据解析,这里使用 Float32Array 直接传送数据
|
|
5913
|
+
|
|
5914
|
+
gl.bufferData(type, data, drawType); // 表示缓冲区的内容不会经常更改
|
|
5915
|
+
|
|
5916
|
+
return {
|
|
5917
|
+
type: type,
|
|
5918
|
+
drawType: drawType,
|
|
5919
|
+
buffer: buffer,
|
|
5920
|
+
// 获取到数组中单个元素的字节数
|
|
5921
|
+
unitSize: data.BYTES_PER_ELEMENT
|
|
5922
|
+
};
|
|
5923
|
+
} // 创建float32的buffer
|
|
5924
|
+
|
|
5925
|
+
|
|
5926
|
+
function createFloat32Buffer(gl, data) {
|
|
5927
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gl.ARRAY_BUFFER;
|
|
5928
|
+
var drawType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gl.STATIC_DRAW;
|
|
5929
|
+
var vertices = new Float32Array(data);
|
|
5930
|
+
var buffer = createBuffer(gl, vertices, type, drawType);
|
|
5931
|
+
return buffer;
|
|
5932
|
+
} // 创建uint16的bugger
|
|
5933
|
+
|
|
5934
|
+
|
|
5935
|
+
function createUint16Buffer(gl, data) {
|
|
5936
|
+
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gl.ARRAY_BUFFER;
|
|
5937
|
+
var drawType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gl.STATIC_DRAW;
|
|
5938
|
+
var vertices = new Uint16Array(data);
|
|
5939
|
+
var buffer = createBuffer(gl, vertices, type, drawType);
|
|
5940
|
+
return buffer;
|
|
5941
|
+
} // 释放
|
|
5942
|
+
|
|
5943
|
+
|
|
5944
|
+
function deleteBuffer(gl, buffer) {
|
|
5945
|
+
gl.deleteBuffer(buffer.buffer || buffer);
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
},{}],15:[function(require,module,exports){
|
|
5949
|
+
"use strict";
|
|
5950
|
+
|
|
5951
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5952
|
+
value: true
|
|
5953
|
+
});
|
|
5954
|
+
exports.mapSize = void 0;
|
|
5955
|
+
var GLSL_TO_SIZE = {
|
|
5956
|
+
'float': 1,
|
|
5957
|
+
'vec2': 2,
|
|
5958
|
+
'vec3': 3,
|
|
5959
|
+
'vec4': 4,
|
|
5960
|
+
'int': 1,
|
|
5961
|
+
'ivec2': 2,
|
|
5962
|
+
'ivec3': 3,
|
|
5963
|
+
'ivec4': 4,
|
|
5964
|
+
'bool': 1,
|
|
5965
|
+
'bvec2': 2,
|
|
5966
|
+
'bvec3': 3,
|
|
5967
|
+
'bvec4': 4,
|
|
5968
|
+
'mat2': 4,
|
|
5969
|
+
'mat3': 9,
|
|
5970
|
+
'mat4': 16,
|
|
5971
|
+
'sampler2D': 1
|
|
5972
|
+
};
|
|
5973
|
+
/**
|
|
5974
|
+
* @class
|
|
5975
|
+
* @memberof PIXI.glCore.shader
|
|
5976
|
+
* @param type {String}
|
|
5977
|
+
* @return {Number}
|
|
5978
|
+
*/
|
|
5979
|
+
|
|
5980
|
+
var mapSize = function mapSize(type) {
|
|
5981
|
+
return GLSL_TO_SIZE[type];
|
|
5982
|
+
};
|
|
5983
|
+
|
|
5984
|
+
exports.mapSize = mapSize;
|
|
5985
|
+
|
|
5986
|
+
},{}],16:[function(require,module,exports){
|
|
5987
|
+
"use strict";
|
|
5988
|
+
|
|
5989
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5990
|
+
value: true
|
|
5991
|
+
});
|
|
5992
|
+
exports.mapType = void 0;
|
|
5993
|
+
var GL_TABLE = null;
|
|
5994
|
+
var GL_TO_GLSL_TYPES = {
|
|
5995
|
+
'FLOAT': 'float',
|
|
5996
|
+
'FLOAT_VEC2': 'vec2',
|
|
5997
|
+
'FLOAT_VEC3': 'vec3',
|
|
5998
|
+
'FLOAT_VEC4': 'vec4',
|
|
5999
|
+
'INT': 'int',
|
|
6000
|
+
'INT_VEC2': 'ivec2',
|
|
6001
|
+
'INT_VEC3': 'ivec3',
|
|
6002
|
+
'INT_VEC4': 'ivec4',
|
|
6003
|
+
'BOOL': 'bool',
|
|
6004
|
+
'BOOL_VEC2': 'bvec2',
|
|
6005
|
+
'BOOL_VEC3': 'bvec3',
|
|
6006
|
+
'BOOL_VEC4': 'bvec4',
|
|
6007
|
+
'FLOAT_MAT2': 'mat2',
|
|
6008
|
+
'FLOAT_MAT3': 'mat3',
|
|
6009
|
+
'FLOAT_MAT4': 'mat4',
|
|
6010
|
+
'SAMPLER_2D': 'sampler2D'
|
|
6011
|
+
};
|
|
6012
|
+
|
|
6013
|
+
var mapType = function mapType(gl, type) {
|
|
6014
|
+
if (!GL_TABLE) {
|
|
6015
|
+
var typeNames = Object.keys(GL_TO_GLSL_TYPES);
|
|
6016
|
+
GL_TABLE = {};
|
|
6017
|
+
|
|
6018
|
+
for (var i = 0; i < typeNames.length; ++i) {
|
|
6019
|
+
var tn = typeNames[i];
|
|
6020
|
+
GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
|
|
6024
|
+
return GL_TABLE[type];
|
|
6025
|
+
};
|
|
6026
|
+
|
|
6027
|
+
exports.mapType = mapType;
|
|
6028
|
+
|
|
6029
|
+
},{}],17:[function(require,module,exports){
|
|
6030
|
+
"use strict";
|
|
6031
|
+
|
|
6032
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6033
|
+
value: true
|
|
6034
|
+
});
|
|
6035
|
+
exports.createProgram = createProgram;
|
|
6036
|
+
exports.useProgram = useProgram;
|
|
6037
|
+
exports.getAttribLocation = getAttribLocation;
|
|
6038
|
+
exports.getUniformLocation = getUniformLocation;
|
|
6039
|
+
exports.extractAttributes = extractAttributes;
|
|
6040
|
+
exports.extractUniforms = extractUniforms;
|
|
6041
|
+
exports.writeVertexAttrib = writeVertexAttrib;
|
|
6042
|
+
exports.disableVertexAttribArray = disableVertexAttribArray;
|
|
6043
|
+
|
|
6044
|
+
var _shader = require("./shader.js");
|
|
6045
|
+
|
|
6046
|
+
var _mapSize = require("./mapSize.js");
|
|
6047
|
+
|
|
6048
|
+
var _mapType = require("./mapType.js");
|
|
6049
|
+
|
|
6050
|
+
// 创建程序
|
|
6051
|
+
function createProgram(gl, vertexSrc, fragmentSrc) {
|
|
6052
|
+
// 创建顶点着色器
|
|
6053
|
+
var vertexShader = (0, _shader.createShader)(gl, gl.VERTEX_SHADER, vertexSrc); // 创建片段着色器
|
|
6054
|
+
|
|
6055
|
+
var fragmentShader = (0, _shader.createShader)(gl, gl.FRAGMENT_SHADER, fragmentSrc);
|
|
6056
|
+
var program = gl.createProgram(); // 创建一个程序
|
|
6057
|
+
|
|
6058
|
+
gl.attachShader(program, vertexShader); // 添加顶点着色器
|
|
6059
|
+
|
|
6060
|
+
gl.attachShader(program, fragmentShader); // 添加片元着色器
|
|
6061
|
+
|
|
6062
|
+
gl.linkProgram(program); // 连接 program 中的着色器
|
|
6063
|
+
// 检查程序链接状态
|
|
6064
|
+
|
|
6065
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
6066
|
+
console.error('PError: Could not initialize shader.');
|
|
6067
|
+
console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS));
|
|
6068
|
+
console.error('gl.getError()', gl.getError()); // if there is a program info log, log it
|
|
6069
|
+
|
|
6070
|
+
if (gl.getProgramInfoLog(program) !== '') {
|
|
6071
|
+
console.warn('Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));
|
|
6072
|
+
}
|
|
6073
|
+
|
|
6074
|
+
gl.deleteProgram(program);
|
|
6075
|
+
}
|
|
6076
|
+
|
|
6077
|
+
useProgram(gl, program); // clean up some shaders
|
|
6078
|
+
|
|
6079
|
+
gl.deleteShader(vertexShader);
|
|
6080
|
+
gl.deleteShader(fragmentShader);
|
|
6081
|
+
var attrs = extractAttributes(gl, program);
|
|
6082
|
+
var uniforms = extractUniforms(gl, program);
|
|
6083
|
+
return {
|
|
6084
|
+
program: program,
|
|
6085
|
+
attrs: attrs,
|
|
6086
|
+
uniforms: uniforms
|
|
6087
|
+
};
|
|
6088
|
+
} // 采用program
|
|
6089
|
+
|
|
6090
|
+
|
|
6091
|
+
function useProgram(gl, program) {
|
|
6092
|
+
return gl.useProgram(program); // 告诉 webgl 用这个 program 进行渲染
|
|
6093
|
+
}
|
|
6094
|
+
|
|
6095
|
+
function extractAttributes(gl, program) {
|
|
6096
|
+
var attributes = {};
|
|
6097
|
+
var count = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
6098
|
+
|
|
6099
|
+
for (var i = 0; i < count; i++) {
|
|
6100
|
+
var attribData = gl.getActiveAttrib(program, i);
|
|
6101
|
+
var type = (0, _mapType.mapType)(gl, attribData.type);
|
|
6102
|
+
attributes[attribData.name] = {
|
|
6103
|
+
attribData: attribData,
|
|
6104
|
+
size: (0, _mapSize.mapSize)(type),
|
|
6105
|
+
type: type,
|
|
6106
|
+
location: gl.getAttribLocation(program, attribData.name)
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
return attributes;
|
|
6111
|
+
}
|
|
6112
|
+
|
|
6113
|
+
function extractUniforms(gl, program) {
|
|
6114
|
+
var uniforms = {};
|
|
6115
|
+
var count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
6116
|
+
|
|
6117
|
+
for (var i = 0; i < count; i++) {
|
|
6118
|
+
var uniformData = gl.getActiveUniform(program, i);
|
|
6119
|
+
var name = uniformData.name.replace(/\[.*?\]/, "");
|
|
6120
|
+
var type = (0, _mapType.mapType)(gl, uniformData.type);
|
|
6121
|
+
uniforms[name] = {
|
|
6122
|
+
uniformData: uniformData,
|
|
6123
|
+
type: type,
|
|
6124
|
+
size: uniformData.size,
|
|
6125
|
+
location: gl.getUniformLocation(program, name)
|
|
6126
|
+
};
|
|
6127
|
+
}
|
|
6128
|
+
|
|
6129
|
+
return uniforms;
|
|
6130
|
+
}
|
|
6131
|
+
|
|
6132
|
+
; // 把缓冲区的值写入变量
|
|
6133
|
+
// size: 组成数量,必须是1,2,3或4. 每个单元由多少个数组成
|
|
6134
|
+
// strip: 步长 数组中一行长度,0 表示数据是紧密的没有空隙,让OpenGL决定具体步长
|
|
6135
|
+
// offset: 字节偏移量,必须是类型的字节长度的倍数。
|
|
6136
|
+
// dataType: 每个元素的数据类型
|
|
6137
|
+
|
|
6138
|
+
function writeVertexAttrib(gl, buffer, attr) {
|
|
6139
|
+
var size = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
|
|
6140
|
+
var strip = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
6141
|
+
var offset = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
6142
|
+
var dataType = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gl.FLOAT;
|
|
6143
|
+
gl.bindBuffer(buffer.type, buffer.buffer);
|
|
6144
|
+
gl.vertexAttribPointer( // 告诉 OpenGL 如何从 Buffer 中获取数据
|
|
6145
|
+
attr.location, // 顶点属性的索引
|
|
6146
|
+
size, // 组成数量,必须是1,2,3或4。我们只提供了 x 和 y
|
|
6147
|
+
dataType, false, // 是否归一化到特定的范围,对 FLOAT 类型数据设置无效
|
|
6148
|
+
strip * buffer.unitSize, offset);
|
|
6149
|
+
gl.enableVertexAttribArray(attr.location);
|
|
6150
|
+
return buffer;
|
|
6151
|
+
}
|
|
6152
|
+
|
|
6153
|
+
function disableVertexAttribArray(gl, attr) {
|
|
6154
|
+
return gl.disableVertexAttribArray(attr.location);
|
|
6155
|
+
}
|
|
6156
|
+
|
|
6157
|
+
function getAttribLocation(gl, program, name) {
|
|
6158
|
+
return gl.getAttribLocation(program, name);
|
|
6159
|
+
}
|
|
6160
|
+
|
|
6161
|
+
function getUniformLocation(gl, program, name) {
|
|
6162
|
+
return gl.getUniformLocation(program, name);
|
|
6163
|
+
}
|
|
6164
|
+
|
|
6165
|
+
},{"./mapSize.js":15,"./mapType.js":16,"./shader.js":18}],18:[function(require,module,exports){
|
|
6166
|
+
"use strict";
|
|
6167
|
+
|
|
6168
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6169
|
+
value: true
|
|
6170
|
+
});
|
|
6171
|
+
exports.createShader = createShader;
|
|
6172
|
+
|
|
6173
|
+
// 生成着色器
|
|
6174
|
+
// type: gl.VERTEX_SHADER 顶点着色器 , gl.FRAGMENT_SHADER 片段着色器
|
|
6175
|
+
// src: 着色器代码
|
|
6176
|
+
function createShader(gl, type, src) {
|
|
6177
|
+
var shader = gl.createShader(type); // 创建一个顶点着色器
|
|
6178
|
+
|
|
6179
|
+
gl.shaderSource(shader, src); // 编写顶点着色器代码
|
|
6180
|
+
|
|
6181
|
+
gl.compileShader(shader); // 编译着色器
|
|
6182
|
+
|
|
6183
|
+
return shader;
|
|
6184
|
+
}
|
|
6185
|
+
|
|
6186
|
+
},{}],19:[function(require,module,exports){
|
|
6187
|
+
"use strict";
|
|
6188
|
+
|
|
6189
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6190
|
+
value: true
|
|
6191
|
+
});
|
|
6192
|
+
exports.create2DTexture = create2DTexture;
|
|
6193
|
+
exports.createImgTexture = createImgTexture;
|
|
6194
|
+
exports.createDataTexture = createDataTexture;
|
|
6195
|
+
exports.deleteTexture = deleteTexture;
|
|
6196
|
+
|
|
6197
|
+
// 生成纹理
|
|
6198
|
+
function create2DTexture(gl) {
|
|
6199
|
+
var texture = gl.createTexture();
|
|
6200
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); // 图像反转Y轴
|
|
6201
|
+
|
|
6202
|
+
gl.activeTexture(gl.TEXTURE0); // 激活纹理单元
|
|
6203
|
+
|
|
6204
|
+
gl.bindTexture(gl.TEXTURE_2D, texture); // 绑定纹理对象
|
|
6205
|
+
|
|
6206
|
+
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); // 放大处理方式
|
|
6207
|
+
|
|
6208
|
+
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); // 缩小处理方式
|
|
6209
|
+
|
|
6210
|
+
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); // 水平平铺方式
|
|
6211
|
+
|
|
6212
|
+
gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); // 竖直平铺方式
|
|
6213
|
+
|
|
6214
|
+
return texture;
|
|
6215
|
+
} // 创建图片纹理
|
|
6216
|
+
|
|
6217
|
+
|
|
6218
|
+
function createImgTexture(gl, img) {
|
|
6219
|
+
var texture = create2DTexture(gl);
|
|
6220
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img); // 配置纹理图像
|
|
6221
|
+
|
|
6222
|
+
return {
|
|
6223
|
+
texture: texture
|
|
6224
|
+
};
|
|
6225
|
+
} // 用像素值来绘制纹理
|
|
6226
|
+
|
|
6227
|
+
|
|
6228
|
+
function createDataTexture(gl, pixels) {
|
|
6229
|
+
var data = new Uint8Array(pixels.data || pixels);
|
|
6230
|
+
var texture = create2DTexture(gl);
|
|
6231
|
+
gl.texImage2D(gl.TEXTURE_2D, // 纹理目标
|
|
6232
|
+
0, // 细节级别,指定详细级别。0 级是基本图像等级,n 级是第 n 个金字塔简化级。
|
|
6233
|
+
gl.RGBA, // 纹理内部格式
|
|
6234
|
+
pixels.width || 1, // 指定纹理的宽度
|
|
6235
|
+
pixels.height || 1, // 指定纹理的高度
|
|
6236
|
+
0, // 指定纹理的边框宽度。必须为 0。
|
|
6237
|
+
gl.RGBA, // 源图像数据格式
|
|
6238
|
+
gl.UNSIGNED_BYTE, // 纹理数据类型
|
|
6239
|
+
data // 数据
|
|
6240
|
+
);
|
|
6241
|
+
return {
|
|
6242
|
+
texture: texture
|
|
6243
|
+
};
|
|
6244
|
+
} // 删除纹理
|
|
6245
|
+
|
|
6246
|
+
|
|
6247
|
+
function deleteTexture(gl, texture) {
|
|
6248
|
+
return gl.deleteTexture(texture);
|
|
6249
|
+
}
|
|
6250
|
+
|
|
6251
|
+
},{}],20:[function(require,module,exports){
|
|
6252
|
+
"use strict";
|
|
6253
|
+
|
|
6254
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6255
|
+
value: true
|
|
6256
|
+
});
|
|
6257
|
+
exports["default"] = void 0;
|
|
6258
|
+
|
|
6259
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6260
|
+
|
|
6261
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6262
|
+
|
|
6263
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6264
|
+
|
|
6265
|
+
var WebglGradientTextureCache = {}; // 渐变
|
|
6266
|
+
|
|
6267
|
+
var WeblGradient = /*#__PURE__*/function () {
|
|
6268
|
+
// type:[linear= 线性渐变,radial=放射性渐变]
|
|
6269
|
+
function WeblGradient() {
|
|
6270
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'linear';
|
|
6271
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6272
|
+
|
|
6273
|
+
_classCallCheck(this, WeblGradient);
|
|
6274
|
+
|
|
6275
|
+
this.type = type || 'linear';
|
|
6276
|
+
this.x1 = params.x1 || 0;
|
|
6277
|
+
this.y1 = params.y1 || 0;
|
|
6278
|
+
this.r1 = params.r1 || 0;
|
|
6279
|
+
this.x2 = params.x2 || 0;
|
|
6280
|
+
this.y2 = params.y2 || 0;
|
|
6281
|
+
this.r2 = params.r2 || 0;
|
|
6282
|
+
this.bounds = params.bounds || {
|
|
6283
|
+
left: 0,
|
|
6284
|
+
top: 0,
|
|
6285
|
+
width: 0,
|
|
6286
|
+
height: 0
|
|
6287
|
+
};
|
|
6288
|
+
this.control = params.control;
|
|
6289
|
+
this.stops = [];
|
|
6290
|
+
this.init();
|
|
6291
|
+
}
|
|
6292
|
+
|
|
6293
|
+
_createClass(WeblGradient, [{
|
|
6294
|
+
key: "init",
|
|
6295
|
+
value: function init() {
|
|
6296
|
+
var dx = this.x2 - this.x1;
|
|
6297
|
+
var dy = this.y2 - this.y1;
|
|
6298
|
+
|
|
6299
|
+
if (this.type === 'radial') {
|
|
6300
|
+
this.length = this.r2 - this.r1;
|
|
6301
|
+
} else if (dx === 0 && dy === 0) {
|
|
6302
|
+
this.length = 0;
|
|
6303
|
+
} else {
|
|
6304
|
+
// 渐变中心的距离
|
|
6305
|
+
this.length = Math.sqrt(Math.pow(dx, 2), Math.pow(dy, 2));
|
|
6306
|
+
this.sin = dy / this.length;
|
|
6307
|
+
this.cos = dx / this.length;
|
|
6308
|
+
}
|
|
6309
|
+
} // 渐变颜色
|
|
6310
|
+
|
|
6311
|
+
}, {
|
|
6312
|
+
key: "addColorStop",
|
|
6313
|
+
value: function addColorStop(offset, color) {
|
|
6314
|
+
this.stops.push({
|
|
6315
|
+
offset: offset,
|
|
6316
|
+
color: color
|
|
6317
|
+
});
|
|
6318
|
+
} // 转为渐变为纹理
|
|
6319
|
+
|
|
6320
|
+
}, {
|
|
6321
|
+
key: "toImageData",
|
|
6322
|
+
value: function toImageData(control, bounds) {
|
|
6323
|
+
var key = this.toString() + "-".concat(bounds.width.toFixed(4), "x").concat(bounds.height.toFixed(4));
|
|
6324
|
+
if (WebglGradientTextureCache[key]) return WebglGradientTextureCache[key];
|
|
6325
|
+
var canvas = control.graph.textureCanvas;
|
|
6326
|
+
|
|
6327
|
+
if (!canvas) {
|
|
6328
|
+
canvas = control.graph.textureCanvas = document.createElement('canvas');
|
|
6329
|
+
}
|
|
6330
|
+
|
|
6331
|
+
canvas.width = bounds.width;
|
|
6332
|
+
canvas.height = bounds.height;
|
|
6333
|
+
|
|
6334
|
+
if (!canvas.width || !canvas.height) {
|
|
6335
|
+
return null;
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6338
|
+
var ctx = canvas.getContext('2d', {
|
|
6339
|
+
willReadFrequently: true
|
|
6340
|
+
});
|
|
6341
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
6342
|
+
var gradient = null;
|
|
6343
|
+
|
|
6344
|
+
if (this.type === 'linear') {
|
|
6345
|
+
gradient = ctx.createLinearGradient(this.x1, this.y1, this.x2, this.y2);
|
|
6346
|
+
} else {
|
|
6347
|
+
gradient = ctx.createRadialGradient(this.x1, this.y1, this.r1, this.x2, this.y2, this.r2);
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
this.stops.forEach(function (s, i) {
|
|
6351
|
+
var c = control.graph.utils.toColor(s.color);
|
|
6352
|
+
gradient && gradient.addColorStop(s.offset, c);
|
|
6353
|
+
});
|
|
6354
|
+
ctx.fillStyle = gradient;
|
|
6355
|
+
ctx.beginPath();
|
|
6356
|
+
ctx.moveTo(0, 0);
|
|
6357
|
+
ctx.lineTo(bounds.width, 0);
|
|
6358
|
+
ctx.lineTo(bounds.width, bounds.height);
|
|
6359
|
+
ctx.lineTo(0, bounds.height);
|
|
6360
|
+
ctx.lineTo(0, 0);
|
|
6361
|
+
ctx.closePath();
|
|
6362
|
+
ctx.fill();
|
|
6363
|
+
var data = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
6364
|
+
WebglGradientTextureCache[key] = data;
|
|
6365
|
+
return data;
|
|
6366
|
+
} // 根据绘制图形的坐标计算出对应点的颜色
|
|
6367
|
+
|
|
6368
|
+
/*
|
|
6369
|
+
toPointColors(points) {
|
|
6370
|
+
const stops = this.getStops();
|
|
6371
|
+
const colors = [];
|
|
6372
|
+
for(let i=0; i<points.length; i+=2) {
|
|
6373
|
+
const p = {
|
|
6374
|
+
x: points[i],
|
|
6375
|
+
y: points[i+1]
|
|
6376
|
+
}
|
|
6377
|
+
if(this.type === 'radial') {
|
|
6378
|
+
const dx = p.x - this.x1;
|
|
6379
|
+
const dy = p.y - this.y1;
|
|
6380
|
+
const len = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
6381
|
+
const rang = this.getStopRange(len, stops);
|
|
6382
|
+
if(!rang.start && rang.end) {
|
|
6383
|
+
colors.push(rang.end.color);
|
|
6384
|
+
}
|
|
6385
|
+
else if(!rang.end && rang.start) {
|
|
6386
|
+
colors.push(rang.start.color);
|
|
6387
|
+
}
|
|
6388
|
+
else {
|
|
6389
|
+
const rangLength = rang.end.length - rang.start.length;
|
|
6390
|
+
const offlen = len - rang.start.length;
|
|
6391
|
+
const per = offlen / rangLength;
|
|
6392
|
+
const color = {
|
|
6393
|
+
r: rang.start.color.r + (rang.end.color.r - rang.start.color.r) * per,
|
|
6394
|
+
g: rang.start.color.g + (rang.end.color.g - rang.start.color.g) * per,
|
|
6395
|
+
b: rang.start.color.b + (rang.end.color.b - rang.start.color.b) * per,
|
|
6396
|
+
a: rang.start.color.a + (rang.end.color.a - rang.start.color.a) * per,
|
|
6397
|
+
};
|
|
6398
|
+
colors.push(color);
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
return colors;
|
|
6403
|
+
}
|
|
6404
|
+
*/
|
|
6405
|
+
// 根据起点距离获取边界stop
|
|
6406
|
+
|
|
6407
|
+
/*
|
|
6408
|
+
getStopRange(len, stops) {
|
|
6409
|
+
const res = {};
|
|
6410
|
+
for(const s of stops) {
|
|
6411
|
+
if(s.length <= len) {
|
|
6412
|
+
res.start = s;
|
|
6413
|
+
}
|
|
6414
|
+
else {
|
|
6415
|
+
res.end = s;
|
|
6416
|
+
}
|
|
6417
|
+
}
|
|
6418
|
+
return res;
|
|
6419
|
+
}
|
|
6420
|
+
// 根据stop计算offset长度
|
|
6421
|
+
getStops() {
|
|
6422
|
+
const stops = this.stops.sort((p1, p2) => p1.offset - p2.offset); // 渐变色排序从小于大
|
|
6423
|
+
for(const s of stops) {
|
|
6424
|
+
|
|
6425
|
+
const color = typeof s.color === 'string'? this.control.graph.utils.hexToRGBA(s.color) : s.color;
|
|
6426
|
+
console.log(s, color);
|
|
6427
|
+
s.color = this.control.graph.utils.rgbToDecimal(color);
|
|
6428
|
+
s.length = s.offset * this.length;
|
|
6429
|
+
}
|
|
6430
|
+
return stops;
|
|
6431
|
+
}
|
|
6432
|
+
*/
|
|
6433
|
+
|
|
6434
|
+
/**
|
|
6435
|
+
* 转换为渐变的字符串表达
|
|
6436
|
+
*
|
|
6437
|
+
* @method toString
|
|
6438
|
+
* @for jmGradient
|
|
6439
|
+
* @return {string} linear-gradient(x1 y1 x2 y2, color1 step, color2 step, ...); //radial-gradient(x1 y1 r1 x2 y2 r2, color1 step,color2 step, ...);
|
|
6440
|
+
*/
|
|
6441
|
+
|
|
6442
|
+
}, {
|
|
6443
|
+
key: "toString",
|
|
6444
|
+
value: function toString() {
|
|
6445
|
+
var str = this.type + '-gradient(';
|
|
6446
|
+
|
|
6447
|
+
if (this.type == 'linear') {
|
|
6448
|
+
str += this.x1 + ' ' + this.y1 + ' ' + this.x2 + ' ' + this.y2;
|
|
6449
|
+
} else {
|
|
6450
|
+
str += this.x1 + ' ' + this.y1 + ' ' + this.r1 + ' ' + this.x2 + ' ' + this.y2 + ' ' + this.r2;
|
|
6451
|
+
} //颜色渐变
|
|
6452
|
+
|
|
6453
|
+
|
|
6454
|
+
this.stops.forEach(function (s) {
|
|
6455
|
+
str += ',' + s.color + ' ' + s.offset;
|
|
6456
|
+
});
|
|
6457
|
+
return str + ')';
|
|
6458
|
+
}
|
|
6459
|
+
}]);
|
|
6460
|
+
|
|
6461
|
+
return WeblGradient;
|
|
6462
|
+
}();
|
|
6463
|
+
|
|
6464
|
+
var _default = WeblGradient;
|
|
6465
|
+
exports["default"] = _default;
|
|
6466
|
+
|
|
6467
|
+
},{}],21:[function(require,module,exports){
|
|
6468
|
+
"use strict";
|
|
6469
|
+
|
|
6470
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
6471
|
+
|
|
6472
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6473
|
+
value: true
|
|
6474
|
+
});
|
|
6475
|
+
exports["default"] = void 0;
|
|
6476
|
+
|
|
6477
|
+
var _base = _interopRequireDefault(require("./base.js"));
|
|
6478
|
+
|
|
6479
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6480
|
+
|
|
6481
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6482
|
+
|
|
6483
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6484
|
+
|
|
6485
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6486
|
+
|
|
6487
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6488
|
+
|
|
6489
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
6490
|
+
|
|
6491
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6492
|
+
|
|
6493
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6494
|
+
|
|
6495
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6496
|
+
|
|
6497
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6498
|
+
|
|
6499
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6500
|
+
|
|
6501
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6502
|
+
|
|
6503
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6504
|
+
|
|
6505
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6506
|
+
|
|
6507
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6508
|
+
|
|
6509
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
6510
|
+
|
|
6511
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
6512
|
+
|
|
6513
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
6514
|
+
|
|
6515
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
6516
|
+
|
|
6517
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
6518
|
+
|
|
6519
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
6520
|
+
|
|
6521
|
+
// 把canvas坐标转为webgl坐标系
|
|
6522
|
+
var convertPointSource = "\n vec4 translatePosition(vec4 point, float x, float y) {\n point.x = (point.x-x)/x;\n point.y = (y-point.y)/y;\n return point;\n }"; // 把纹理的canvas坐标转为纹理的坐标系
|
|
6523
|
+
|
|
6524
|
+
var convertTexturePosition = "\n vec2 translateTexturePosition(in vec2 point, vec4 bounds) {\n point.x = (point.x-bounds.x)/bounds.z; // \u79BB\u5DE6\u4E0A\u89D2\u4F4D\u7F6E\u7684X\u957F\u6BD4\u4E0A\u7EB9\u7406\u5BBD 0-1\n point.y = 1.0-(point.y-bounds.y)/bounds.w; // \u79BB\u5DE6\u4E0A\u89D2\u4F4D\u7F6E\u7684Y\u957F\u6BD4\u4E0A\u9AD8\uFF0C\u56E0\u4E3A\u7EB9\u7406\u5750\u6807\u662F\u5DE6\u4E0B\u89D2\u8D77\uFF0C\u6240\u4EE5\u8981\u75281-\n return point;\n }"; // path顶点着色器源码
|
|
6525
|
+
|
|
6526
|
+
var pathVertexSource = "\n attribute vec4 a_position;\n attribute vec4 a_color;\n attribute vec2 a_text_coord;\n uniform vec2 a_center_point; // \u5F53\u524Dcanvas\u7684\u4E2D\u5FC3\u4F4D\u7F6E\n uniform float a_point_size; // \u70B9\u7684\u5927\u5C0F\n uniform int a_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n varying float v_type;\n\n ".concat(convertPointSource, "\n\n void main() {\n gl_PointSize = a_point_size == 0.0? 1.0 : a_point_size;\n v_type = float(a_type);\n vec4 pos = translatePosition(a_position, a_center_point.x, a_center_point.y);\n gl_Position = pos;\n v_color = a_color;\n if(a_type == 2) {\n v_text_coord = a_text_coord;\n }\n }\n"); // path 片段着色器源码
|
|
6527
|
+
|
|
6528
|
+
var pathFragmentSource = "\n precision highp float;\n uniform sampler2D u_sample;\n uniform vec4 v_texture_bounds; // \u7EB9\u7406\u7684\u5DE6\u4E0A\u5750\u6807\u548C\u5927\u5C0F x,y,z,w\n uniform vec4 v_single_color;\n varying float v_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n\n ".concat(convertTexturePosition, "\n\n void main() {\n // \u5982\u679C\u662Ffill\uFF0C\u5219\u76F4\u63A5\u586B\u5145\u989C\u8272\n if(v_type == 1.0) {\n gl_FragColor = v_single_color;\n }\n // \u6E10\u53D8\u8272\n else if(v_type == 3.0) {\n gl_FragColor = v_color;\n }\n else if(v_type == 2.0) {\n vec2 pos = translateTexturePosition(v_text_coord, v_texture_bounds);\n gl_FragColor = texture2D(u_sample, pos);\n }\n else {\n float r = distance(gl_PointCoord, vec2(0.5, 0.5));\n //\u6839\u636E\u8DDD\u79BB\u8BBE\u7F6E\u7247\u5143\n if(r <= 0.5){\n // \u65B9\u5F62\u533A\u57DF\u7247\u5143\u8DDD\u79BB\u51E0\u4F55\u4E2D\u5FC3\u534A\u5F84\u5C0F\u4E8E0.5\uFF0C\u50CF\u7D20\u989C\u8272\u8BBE\u7F6E\u7EA2\u8272\n gl_FragColor = v_single_color;\n }else {\n // \u65B9\u5F62\u533A\u57DF\u8DDD\u79BB\u51E0\u4F55\u4E2D\u5FC3\u534A\u5F84\u4E0D\u5C0F\u4E8E0.5\u7684\u7247\u5143\u526A\u88C1\u820D\u5F03\u6389\uFF1A\n discard;\n }\n }\n }\n"); // path 绘制类
|
|
6529
|
+
|
|
6530
|
+
var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
6531
|
+
_inherits(WebglPath, _WebglBase);
|
|
6532
|
+
|
|
6533
|
+
var _super = _createSuper(WebglPath);
|
|
6534
|
+
|
|
6535
|
+
function WebglPath(graph, option) {
|
|
6536
|
+
var _this;
|
|
6537
|
+
|
|
6538
|
+
_classCallCheck(this, WebglPath);
|
|
6539
|
+
|
|
6540
|
+
_this = _super.call(this, graph, option); // 是否是规则的,不规则的处理方式更为复杂和耗性能
|
|
6541
|
+
|
|
6542
|
+
_this.isRegular = option.isRegular || false;
|
|
6543
|
+
_this.needCut = option.needCut || false;
|
|
6544
|
+
_this.points = [];
|
|
6545
|
+
return _this;
|
|
6546
|
+
} // i当前程序
|
|
6547
|
+
|
|
6548
|
+
|
|
6549
|
+
_createClass(WebglPath, [{
|
|
6550
|
+
key: "program",
|
|
6551
|
+
get: function get() {
|
|
6552
|
+
// 默认所有path用同一个编译好的program
|
|
6553
|
+
return this.graph.context.pathProgram || (this.graph.context.pathProgram = this.createProgram(pathVertexSource, pathFragmentSource));
|
|
6554
|
+
} // 设置样式
|
|
6555
|
+
|
|
6556
|
+
}, {
|
|
6557
|
+
key: "setStyle",
|
|
6558
|
+
value: function setStyle() {
|
|
6559
|
+
var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.style;
|
|
6560
|
+
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
6561
|
+
this.useProgram();
|
|
6562
|
+
|
|
6563
|
+
if (typeof style === 'string') {
|
|
6564
|
+
var obj = {};
|
|
6565
|
+
obj[style] = value;
|
|
6566
|
+
style = obj;
|
|
6567
|
+
} // 设置线条颜色或填充色
|
|
6568
|
+
|
|
6569
|
+
|
|
6570
|
+
if (style.strokeStyle) {
|
|
6571
|
+
var color = style.strokeStyle;
|
|
6572
|
+
if (typeof color === 'string') color = this.graph.utils.hexToRGBA(color);
|
|
6573
|
+
this.style.strokeStyle = this.graph.utils.rgbToDecimal(color);
|
|
6574
|
+
delete style.strokeStyle;
|
|
6575
|
+
} else if (style.fillStyle) {
|
|
6576
|
+
var _color = style.fillStyle;
|
|
6577
|
+
|
|
6578
|
+
if (this.isGradient(_color)) {
|
|
6579
|
+
this.style.fillStyle = _color;
|
|
6580
|
+
} else {
|
|
6581
|
+
if (typeof _color === 'string') _color = this.graph.utils.hexToRGBA(_color);
|
|
6582
|
+
this.style.fillStyle = this.graph.utils.rgbToDecimal(_color);
|
|
6583
|
+
}
|
|
6584
|
+
|
|
6585
|
+
delete style.fillStyle;
|
|
6586
|
+
}
|
|
6587
|
+
|
|
6588
|
+
this.style = _objectSpread(_objectSpread({}, this.style), style);
|
|
6589
|
+
}
|
|
6590
|
+
}, {
|
|
6591
|
+
key: "setParentBounds",
|
|
6592
|
+
value: function setParentBounds() {
|
|
6593
|
+
var parentBounds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.parentAbsoluteBounds;
|
|
6594
|
+
//this.useProgram();
|
|
6595
|
+
if (parentBounds) this.parentAbsoluteBounds = parentBounds; // 写入当前canvas大小
|
|
6596
|
+
|
|
6597
|
+
this.context.uniform2f(this.program.uniforms.a_center_point.location, this.graph.width / 2, this.graph.height / 2);
|
|
6598
|
+
}
|
|
6599
|
+
}, {
|
|
6600
|
+
key: "setFragColor",
|
|
6601
|
+
value: function setFragColor(color) {
|
|
6602
|
+
if (!Array.isArray(color)) {
|
|
6603
|
+
if (typeof color === 'string') color = this.graph.utils.hexToRGBA(color);
|
|
6604
|
+
if (typeof color.a === 'undefined') color.a = 1;
|
|
6605
|
+
this.context.uniform4f(this.program.uniforms.v_single_color.location, color.r, color.g, color.b, color.a * this.style.globalAlpha);
|
|
6606
|
+
return null;
|
|
6607
|
+
}
|
|
6608
|
+
|
|
6609
|
+
var colorData = [];
|
|
6610
|
+
|
|
6611
|
+
var _iterator = _createForOfIteratorHelper(color),
|
|
6612
|
+
_step;
|
|
6613
|
+
|
|
6614
|
+
try {
|
|
6615
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
6616
|
+
var c = _step.value;
|
|
6617
|
+
if (typeof c === 'string') c = this.graph.utils.hexToRGBA(c);
|
|
6618
|
+
if (typeof c.a === 'undefined') c.a = 1;
|
|
6619
|
+
colorData.push(c.r, c.g, c.b, c.a * this.style.globalAlpha);
|
|
6620
|
+
}
|
|
6621
|
+
} catch (err) {
|
|
6622
|
+
_iterator.e(err);
|
|
6623
|
+
} finally {
|
|
6624
|
+
_iterator.f();
|
|
6625
|
+
}
|
|
6626
|
+
|
|
6627
|
+
var colorBuffer = this.createFloat32Buffer(colorData);
|
|
6628
|
+
this.writeVertexAttrib(colorBuffer, this.program.attrs.a_color, 4, 0, 0);
|
|
6629
|
+
colorBuffer.attr = this.program.attrs.a_color;
|
|
6630
|
+
return colorBuffer;
|
|
6631
|
+
}
|
|
6632
|
+
}, {
|
|
6633
|
+
key: "beginDraw",
|
|
6634
|
+
value: function beginDraw() {
|
|
6635
|
+
this.useProgram();
|
|
6636
|
+
} // 开始绘制
|
|
6637
|
+
|
|
6638
|
+
}, {
|
|
6639
|
+
key: "draw",
|
|
6640
|
+
value: function draw(points) {
|
|
6641
|
+
var parentBounds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.parentAbsoluteBounds;
|
|
6642
|
+
//this.useProgram();
|
|
6643
|
+
this.setParentBounds(parentBounds);
|
|
6644
|
+
this.points = points;
|
|
6645
|
+
}
|
|
6646
|
+
}, {
|
|
6647
|
+
key: "endDraw",
|
|
6648
|
+
value: function endDraw() {
|
|
6649
|
+
if (this.points) delete this.points;
|
|
6650
|
+
if (this.pathPoints) delete this.pathPoints;
|
|
6651
|
+
} // 图形封闭
|
|
6652
|
+
|
|
6653
|
+
}, {
|
|
6654
|
+
key: "closePath",
|
|
6655
|
+
value: function closePath() {
|
|
6656
|
+
if (this.points && this.points.length > 2 && this.points[0] !== this.points[this.points.length - 1]) {
|
|
6657
|
+
var start = this.points[0];
|
|
6658
|
+
var end = this.points[this.points.length - 1];
|
|
6659
|
+
if (start != end && !(start.x === end.x && start.y === end.y)) this.points.push(start);
|
|
6660
|
+
}
|
|
6661
|
+
} // 绘制点数组
|
|
6662
|
+
|
|
6663
|
+
}, {
|
|
6664
|
+
key: "writePoints",
|
|
6665
|
+
value: function writePoints(points) {
|
|
6666
|
+
var attr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.program.attrs.a_position;
|
|
6667
|
+
var fixedPoints = [];
|
|
6668
|
+
|
|
6669
|
+
var _iterator2 = _createForOfIteratorHelper(points),
|
|
6670
|
+
_step2;
|
|
6671
|
+
|
|
6672
|
+
try {
|
|
6673
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
6674
|
+
var p = _step2.value;
|
|
6675
|
+
fixedPoints.push(p.x + this.parentAbsoluteBounds.left, p.y + this.parentAbsoluteBounds.top);
|
|
6676
|
+
}
|
|
6677
|
+
} catch (err) {
|
|
6678
|
+
_iterator2.e(err);
|
|
6679
|
+
} finally {
|
|
6680
|
+
_iterator2.f();
|
|
6681
|
+
}
|
|
6682
|
+
|
|
6683
|
+
var vertexBuffer = this.createFloat32Buffer(fixedPoints);
|
|
6684
|
+
this.writeVertexAttrib(vertexBuffer, attr, 2, 0, 0);
|
|
6685
|
+
vertexBuffer.attr = attr;
|
|
6686
|
+
return vertexBuffer;
|
|
6687
|
+
} // 连接二个点
|
|
6688
|
+
|
|
6689
|
+
}, {
|
|
6690
|
+
key: "genLinePoints",
|
|
6691
|
+
value: function genLinePoints(start, end) {
|
|
6692
|
+
var points = [start];
|
|
6693
|
+
var dx = end.x - start.x;
|
|
6694
|
+
var dy = end.y - start.y;
|
|
6695
|
+
|
|
6696
|
+
if (dx !== 0 || dy !== 0) {
|
|
6697
|
+
var len = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
6698
|
+
var cos = dx / len;
|
|
6699
|
+
var sin = dy / len;
|
|
6700
|
+
var step = 0.5;
|
|
6701
|
+
|
|
6702
|
+
for (var l = step; l < len; l += step) {
|
|
6703
|
+
var x = start.x + cos * l;
|
|
6704
|
+
var y = start.y + sin * l;
|
|
6705
|
+
points.push({
|
|
6706
|
+
x: Number(x.toFixed(2)),
|
|
6707
|
+
y: Number(y.toFixed(2))
|
|
6708
|
+
});
|
|
6709
|
+
}
|
|
6710
|
+
}
|
|
6711
|
+
|
|
6712
|
+
points.push(end);
|
|
6713
|
+
return points;
|
|
6714
|
+
} // 把path坐标集合分解成一个个点,并且处理moveTo线段能力
|
|
6715
|
+
|
|
6716
|
+
}, {
|
|
6717
|
+
key: "pathToPoints",
|
|
6718
|
+
value: function pathToPoints() {
|
|
6719
|
+
var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.points;
|
|
6720
|
+
var start = null;
|
|
6721
|
+
var res = [];
|
|
6722
|
+
|
|
6723
|
+
for (var i = 0; i < points.length; i++) {
|
|
6724
|
+
var p = points[i];
|
|
6725
|
+
|
|
6726
|
+
if (start && !p.m) {
|
|
6727
|
+
var linePoints = this.genLinePoints(start, p);
|
|
6728
|
+
res.push.apply(res, _toConsumableArray(linePoints));
|
|
6729
|
+
} else if (start && !res.includes(start)) {
|
|
6730
|
+
res.push(start);
|
|
6731
|
+
}
|
|
6732
|
+
|
|
6733
|
+
start = p;
|
|
6734
|
+
}
|
|
6735
|
+
|
|
6736
|
+
if (!res.includes(start)) res.push(start);
|
|
6737
|
+
return res;
|
|
6738
|
+
} // 二点是否重合
|
|
6739
|
+
|
|
6740
|
+
}, {
|
|
6741
|
+
key: "equalPoint",
|
|
6742
|
+
value: function equalPoint(p1, p2) {
|
|
6743
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
6744
|
+
} // 把path坐标集合转为线段集
|
|
6745
|
+
|
|
6746
|
+
}, {
|
|
6747
|
+
key: "pathToLines",
|
|
6748
|
+
value: function pathToLines(points) {
|
|
6749
|
+
var start = null;
|
|
6750
|
+
var res = [];
|
|
6751
|
+
|
|
6752
|
+
for (var i = 0; i < points.length; i++) {
|
|
6753
|
+
var p = points[i]; // 不重合的二个点,组成线段
|
|
6754
|
+
|
|
6755
|
+
if (start && !p.m && !(start.x == p.x && start.y == p.y)) {
|
|
6756
|
+
var line = {
|
|
6757
|
+
start: start,
|
|
6758
|
+
end: p
|
|
6759
|
+
};
|
|
6760
|
+
res.push(line);
|
|
6761
|
+
}
|
|
6762
|
+
|
|
6763
|
+
start = p;
|
|
6764
|
+
}
|
|
6765
|
+
|
|
6766
|
+
return res;
|
|
6767
|
+
} // 裁剪线段,如果二段线段有交点,则分割成四段, 端头相交的线段不用分割
|
|
6768
|
+
|
|
6769
|
+
}, {
|
|
6770
|
+
key: "cutLines",
|
|
6771
|
+
value: function cutLines(lines) {
|
|
6772
|
+
var index1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
6773
|
+
var index2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
6774
|
+
if (lines && lines.length < 3) return lines;
|
|
6775
|
+
index2 = Math.max(index1 + 1, index2); //如果指定了比下一个更大的索引,则用更大的,说明前面的已经处理过了,不需要重复
|
|
6776
|
+
// 找出线段相交的点,并切割线段
|
|
6777
|
+
|
|
6778
|
+
while (index1 < lines.length) {
|
|
6779
|
+
var line1 = lines[index1];
|
|
6780
|
+
|
|
6781
|
+
while (index2 < lines.length) {
|
|
6782
|
+
var line2 = lines[index2]; // 如果二条线顶点有重合,则不用处理
|
|
6783
|
+
|
|
6784
|
+
if (this.equalPoint(line1.start, line2.start) || this.equalPoint(line1.end, line2.end) || this.equalPoint(line1.start, line2.end) || this.equalPoint(line1.end, line2.start)) {
|
|
6785
|
+
index2++;
|
|
6786
|
+
continue;
|
|
6787
|
+
}
|
|
6788
|
+
|
|
6789
|
+
var cuted = false;
|
|
6790
|
+
var intersection = this.getIntersection(line1, line2); // 计算交点
|
|
6791
|
+
|
|
6792
|
+
if (intersection) {
|
|
6793
|
+
// 如果交点不是线段的端点,则分割成二条线段
|
|
6794
|
+
if (!this.equalPoint(line1.start, intersection) && !this.equalPoint(line1.end, intersection)) {
|
|
6795
|
+
var sub1 = {
|
|
6796
|
+
start: line1.start,
|
|
6797
|
+
end: intersection
|
|
6798
|
+
};
|
|
6799
|
+
var sub2 = {
|
|
6800
|
+
start: intersection,
|
|
6801
|
+
end: line1.end
|
|
6802
|
+
}; // 从原数组中删除当前线段,替换成新的线段
|
|
6803
|
+
|
|
6804
|
+
lines.splice(index1, 1, sub1, sub2); // 当前线段被重新替换,需要重新从它开始处理
|
|
6805
|
+
|
|
6806
|
+
cuted = true;
|
|
6807
|
+
index2++; // 因为多加入了一个线段,则对比线索引需要加1
|
|
6808
|
+
} // 如果交点不是线段的端点,则分割成二条线段
|
|
6809
|
+
|
|
6810
|
+
|
|
6811
|
+
if (!this.equalPoint(line2.start, intersection) && !this.equalPoint(line2.end, intersection)) {
|
|
6812
|
+
var _sub = {
|
|
6813
|
+
start: line2.start,
|
|
6814
|
+
end: intersection
|
|
6815
|
+
};
|
|
6816
|
+
var _sub2 = {
|
|
6817
|
+
start: intersection,
|
|
6818
|
+
end: line2.end
|
|
6819
|
+
}; // 从原数组中删除当前线段,替换成新的线段
|
|
6820
|
+
|
|
6821
|
+
lines.splice(index2, 1, _sub, _sub2);
|
|
6822
|
+
index2++; // 线段2也切成了二段,对比索引要继续加1
|
|
6823
|
+
}
|
|
6824
|
+
}
|
|
6825
|
+
|
|
6826
|
+
index2++; // 如果已经分割了起始线段,则第一个子线段开始,重新对比后面还未对比完的。直接所有对比完成返回
|
|
6827
|
+
|
|
6828
|
+
if (cuted) return this.cutLines(lines, index1, index2);
|
|
6829
|
+
}
|
|
6830
|
+
|
|
6831
|
+
index1++;
|
|
6832
|
+
index2 = index1 + 1;
|
|
6833
|
+
}
|
|
6834
|
+
|
|
6835
|
+
return lines;
|
|
6836
|
+
} // 计算二个线段的交点
|
|
6837
|
+
|
|
6838
|
+
}, {
|
|
6839
|
+
key: "getIntersection",
|
|
6840
|
+
value: function getIntersection(line1, line2) {
|
|
6841
|
+
// 如果首尾相接,也认为是有交点
|
|
6842
|
+
if (this.equalPoint(line1.start, line2.start) || this.equalPoint(line1.start, line2.end)) return line1.start;
|
|
6843
|
+
if (this.equalPoint(line1.end, line2.start) || this.equalPoint(line1.end, line2.end)) return line1.end; // 三角形abc 面积的2倍
|
|
6844
|
+
|
|
6845
|
+
var area_abc = (line1.start.x - line2.start.x) * (line1.end.y - line2.start.y) - (line1.start.y - line2.start.y) * (line1.end.x - line2.start.x); // 三角形abd 面积的2倍
|
|
6846
|
+
|
|
6847
|
+
var area_abd = (line1.start.x - line2.end.x) * (line1.end.y - line2.end.y) - (line1.start.y - line2.end.y) * (line1.end.x - line2.end.x); // 面积符号相同则两点在线段同侧,不相交 (=0表示在线段顶点上);
|
|
6848
|
+
|
|
6849
|
+
if (area_abc * area_abd > 0) {
|
|
6850
|
+
return null;
|
|
6851
|
+
} // 三角形cda 面积的2倍
|
|
6852
|
+
|
|
6853
|
+
|
|
6854
|
+
var area_cda = (line2.start.x - line1.start.x) * (line2.end.y - line1.start.y) - (line2.start.y - line1.start.y) * (line2.end.x - line1.start.x); // 三角形cdb 面积的2倍
|
|
6855
|
+
// 注意: 这里有一个小优化.不需要再用公式计算面积,而是通过已知的三个面积加减得出.
|
|
6856
|
+
|
|
6857
|
+
var area_cdb = area_cda + area_abc - area_abd;
|
|
6858
|
+
|
|
6859
|
+
if (area_cda * area_cdb > 0) {
|
|
6860
|
+
return null;
|
|
6861
|
+
}
|
|
6862
|
+
|
|
6863
|
+
if (area_abd === area_abc) return null; //计算交点坐标
|
|
6864
|
+
|
|
6865
|
+
var t = area_cda / (area_abd - area_abc);
|
|
6866
|
+
var dx = t * (line1.end.x - line1.start.x);
|
|
6867
|
+
var dy = t * (line1.end.y - line1.start.y);
|
|
6868
|
+
return {
|
|
6869
|
+
x: Number((line1.start.x + dx).toFixed(2)),
|
|
6870
|
+
y: Number((line1.start.y + dy).toFixed(2))
|
|
6871
|
+
};
|
|
6872
|
+
} // 找出跟当前线段尾部相交的所有线段
|
|
6873
|
+
|
|
6874
|
+
}, {
|
|
6875
|
+
key: "getIntersectionLines",
|
|
6876
|
+
value: function getIntersectionLines(line, lines, index) {
|
|
6877
|
+
var point = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : line.end;
|
|
6878
|
+
var points = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
6879
|
+
var root = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
|
|
6880
|
+
var res = {
|
|
6881
|
+
line: line,
|
|
6882
|
+
polygons: []
|
|
6883
|
+
};
|
|
6884
|
+
points.push(point);
|
|
6885
|
+
|
|
6886
|
+
if (root && this.equalPoint(root.line.start, point)) {
|
|
6887
|
+
points.unshift(root.line.start); // 把起始地址加入进去
|
|
6888
|
+
|
|
6889
|
+
root.polygons.push(points);
|
|
6890
|
+
return res;
|
|
6891
|
+
}
|
|
6892
|
+
|
|
6893
|
+
for (; index < lines.length; index++) {
|
|
6894
|
+
var l = lines[index];
|
|
6895
|
+
|
|
6896
|
+
if (this.equalPoint(point, l.start)) {
|
|
6897
|
+
if (points.includes(l.end)) continue;
|
|
6898
|
+
this.getIntersectionLines(l, lines, index + 1, l.end, _toConsumableArray(points), root || res);
|
|
6899
|
+
} else if (this.equalPoint(point, l.end)) {
|
|
6900
|
+
if (points.includes(l.start)) continue;
|
|
6901
|
+
this.getIntersectionLines(l, lines, index + 1, l.start, _toConsumableArray(points), root || res);
|
|
6902
|
+
}
|
|
6903
|
+
}
|
|
6904
|
+
|
|
6905
|
+
return res;
|
|
6906
|
+
} // 根据路径点坐标,切割出封闭的多边形
|
|
6907
|
+
|
|
6908
|
+
}, {
|
|
6909
|
+
key: "getPolygon",
|
|
6910
|
+
value: function getPolygon(points) {
|
|
6911
|
+
var polygons = [];
|
|
6912
|
+
var lines = this.pathToLines(points); // 分解得到线段
|
|
6913
|
+
|
|
6914
|
+
if (lines && lines.length > 2) {
|
|
6915
|
+
lines = this.cutLines(lines); // 把所有相交点切割线段找出来
|
|
6916
|
+
|
|
6917
|
+
for (var i = 0; i < lines.length - 1; i++) {
|
|
6918
|
+
var line1 = lines[i];
|
|
6919
|
+
var polygon = []; // 当前图形
|
|
6920
|
+
|
|
6921
|
+
var treeLine = this.getIntersectionLines(line1, lines, i + 1);
|
|
6922
|
+
if (treeLine.polygons.length) polygons.push.apply(polygons, _toConsumableArray(treeLine.polygons));
|
|
6923
|
+
continue;
|
|
6924
|
+
var lastLine = line1; // 下一个还在连接状态的线
|
|
6925
|
+
|
|
6926
|
+
for (var j = i + 1; j < lines.length; j++) {
|
|
6927
|
+
var line2 = lines[j]; // 如果跟下一条线相接,则表示还在形成图形中
|
|
6928
|
+
|
|
6929
|
+
if (this.equalPoint(lastLine.end, line2.start)) {
|
|
6930
|
+
polygon.push(lastLine.end);
|
|
6931
|
+
lastLine = line2;
|
|
6932
|
+
if (i === j + 1) continue; //下一条相连 则不需要处理相交情况
|
|
6933
|
+
} else {
|
|
6934
|
+
polygon = [];
|
|
6935
|
+
} // 因为前面进行了分割线段,则里只有处理端点相连的情况
|
|
6936
|
+
|
|
6937
|
+
|
|
6938
|
+
var intersection = this.equalPoint(line1.start, line2.end) ? line1.start : null; //this.getIntersection(line1, line2);// 计算交点
|
|
6939
|
+
|
|
6940
|
+
if (intersection) {
|
|
6941
|
+
polygon.push(intersection); // 交叉点为图形顶点
|
|
6942
|
+
// 如果上一个连接线不是当前交叉线,则表示重新开始闭合
|
|
6943
|
+
// 如果上一个连接线是当前交叉线,形成了封闭的图形
|
|
6944
|
+
|
|
6945
|
+
if (lastLine === line2 && polygon.length > 1) {
|
|
6946
|
+
polygons.push(polygon); // 封闭后,下一个起始线条就是从交点开始计算起
|
|
6947
|
+
|
|
6948
|
+
/*lastLine = {
|
|
6949
|
+
start: intersection,
|
|
6950
|
+
end: line2.end
|
|
6951
|
+
};*/
|
|
6952
|
+
|
|
6953
|
+
polygon = []; // 重新开始新一轮找图形
|
|
6954
|
+
|
|
6955
|
+
/*
|
|
6956
|
+
// 如果交点是上一条线的终点,则新图形为空
|
|
6957
|
+
if(this.equalPoint(line2.end, intersection)) {
|
|
6958
|
+
polygon = [];// 重新开始新一轮找图形
|
|
6959
|
+
}
|
|
6960
|
+
else {
|
|
6961
|
+
// 同时交点也要加到上一个图形中第一个点,形成封闭
|
|
6962
|
+
polygon.unshift(intersection);
|
|
6963
|
+
polygon = [ intersection ];// 重新开始新一轮找图形
|
|
6964
|
+
}*/
|
|
6965
|
+
} else {
|
|
6966
|
+
lastLine = line2;
|
|
6967
|
+
}
|
|
6968
|
+
}
|
|
6969
|
+
}
|
|
6970
|
+
}
|
|
6971
|
+
} // 当有多个封闭图形时,再弟归一下,里面是不是有封闭图形内还有子封闭图形
|
|
6972
|
+
|
|
6973
|
+
/*if(polygons.length > 1) {
|
|
6974
|
+
const newPolygons = [];
|
|
6975
|
+
for(const polygon of polygons) {
|
|
6976
|
+
// 只有大于4才有可能有子封闭图形
|
|
6977
|
+
if(polygon.length > 4) {
|
|
6978
|
+
const childPolygons = this.getPolygon(polygon);
|
|
6979
|
+
// 当有多个子图形时,表示它不是最终封闭图形,跳过,
|
|
6980
|
+
// 因为它的子图形之前有加入的,不需要重复加入
|
|
6981
|
+
if(childPolygons.length > 1) {
|
|
6982
|
+
//newPolygons.push(...childPolygons);
|
|
6983
|
+
continue;
|
|
6984
|
+
}
|
|
6985
|
+
}
|
|
6986
|
+
newPolygons.push(polygon);
|
|
6987
|
+
}
|
|
6988
|
+
polygons = newPolygons;
|
|
6989
|
+
}*/
|
|
6990
|
+
|
|
6991
|
+
|
|
6992
|
+
return polygons;
|
|
6993
|
+
} // 画线条
|
|
6994
|
+
|
|
6995
|
+
}, {
|
|
6996
|
+
key: "stroke",
|
|
6997
|
+
value: function stroke() {
|
|
6998
|
+
var points = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.points;
|
|
6999
|
+
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.style.strokeStyle;
|
|
7000
|
+
var lineWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.style.lineWidth;
|
|
7001
|
+
if (!points || !points.length) return; // this.useProgram();
|
|
7002
|
+
|
|
7003
|
+
var colorBuffer = null;
|
|
7004
|
+
|
|
7005
|
+
if (color) {
|
|
7006
|
+
colorBuffer = this.setFragColor(color);
|
|
7007
|
+
} // 线宽
|
|
7008
|
+
|
|
7009
|
+
|
|
7010
|
+
if (lineWidth) {
|
|
7011
|
+
this.context.uniform1f(this.program.uniforms.a_point_size.location, lineWidth); // * this.graph.devicePixelRatio
|
|
7012
|
+
} // 标注为stroke
|
|
7013
|
+
|
|
7014
|
+
|
|
7015
|
+
if (this.program.uniforms.a_type) {
|
|
7016
|
+
// 4表示单画一个圆点,1表示方块形成的线条
|
|
7017
|
+
this.context.uniform1i(this.program.uniforms.a_type.location, points.length === 1 ? 4 : 1);
|
|
7018
|
+
}
|
|
7019
|
+
|
|
7020
|
+
if (points && points.length) {
|
|
7021
|
+
var regular = this.isRegular && lineWidth == 1;
|
|
7022
|
+
points = regular ? points : this.pathToPoints(points); //this.context.lineWidth(10);
|
|
7023
|
+
|
|
7024
|
+
var buffer = this.writePoints(points);
|
|
7025
|
+
this.context.drawArrays(regular ? this.context.LINES : this.context.POINTS, 0, points.length);
|
|
7026
|
+
this.deleteBuffer(buffer);
|
|
7027
|
+
}
|
|
7028
|
+
|
|
7029
|
+
colorBuffer && this.deleteBuffer(colorBuffer);
|
|
7030
|
+
colorBuffer && this.disableVertexAttribArray(colorBuffer.attr);
|
|
7031
|
+
} // 填充图形
|
|
7032
|
+
|
|
7033
|
+
}, {
|
|
7034
|
+
key: "fill",
|
|
7035
|
+
value: function fill() {
|
|
7036
|
+
var bounds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
7037
|
+
left: 0,
|
|
7038
|
+
top: 0,
|
|
7039
|
+
width: 0,
|
|
7040
|
+
height: 0
|
|
7041
|
+
};
|
|
7042
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
7043
|
+
|
|
7044
|
+
//this.useProgram();
|
|
7045
|
+
if (this.points && this.points.length) {
|
|
7046
|
+
// 如果是颜色rgba
|
|
7047
|
+
if (this.style.fillStyle) {
|
|
7048
|
+
var filled = false; // 是否成功填充
|
|
7049
|
+
// 3个以上的点,且非规则图形才需要切割
|
|
7050
|
+
|
|
7051
|
+
if (this.points.length > 3) {
|
|
7052
|
+
if (this.isRegular && this.needCut) {
|
|
7053
|
+
// 需要分割三角形,不然填充会有问题
|
|
7054
|
+
var triangles = this.earCutPointsToTriangles(this.points); // 切割得到三角形顶点二维数组
|
|
7055
|
+
|
|
7056
|
+
if (triangles && triangles.length) {
|
|
7057
|
+
var _iterator3 = _createForOfIteratorHelper(triangles),
|
|
7058
|
+
_step3;
|
|
7059
|
+
|
|
7060
|
+
try {
|
|
7061
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
7062
|
+
var triangle = _step3.value;
|
|
7063
|
+
this.fillColor(triangle, this.style.fillStyle, bounds, type); // 单独为每个分割的图形填充
|
|
7064
|
+
// 如果指定的是img,则采用填充图片的方式
|
|
7065
|
+
|
|
7066
|
+
if (this.style.fillImage) {
|
|
7067
|
+
this.fillImage(this.style.fillImage, triangle, bounds);
|
|
7068
|
+
}
|
|
7069
|
+
}
|
|
7070
|
+
} catch (err) {
|
|
7071
|
+
_iterator3.e(err);
|
|
7072
|
+
} finally {
|
|
7073
|
+
_iterator3.f();
|
|
7074
|
+
}
|
|
7075
|
+
|
|
7076
|
+
filled = true; // 表示已填充过了
|
|
7077
|
+
}
|
|
7078
|
+
} else if (!this.isRegular) {
|
|
7079
|
+
var polygons = this.getPolygon(this.points);
|
|
7080
|
+
|
|
7081
|
+
if (polygons.length) {
|
|
7082
|
+
var _iterator4 = _createForOfIteratorHelper(polygons),
|
|
7083
|
+
_step4;
|
|
7084
|
+
|
|
7085
|
+
try {
|
|
7086
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
7087
|
+
var polygon = _step4.value;
|
|
7088
|
+
|
|
7089
|
+
// 需要分割三角形,不然填充会有问题
|
|
7090
|
+
var _triangles = this.earCutPointsToTriangles(polygon); // 切割得到三角形顶点二维数组
|
|
7091
|
+
|
|
7092
|
+
|
|
7093
|
+
if (_triangles && _triangles.length) {
|
|
7094
|
+
var _iterator5 = _createForOfIteratorHelper(_triangles),
|
|
7095
|
+
_step5;
|
|
7096
|
+
|
|
7097
|
+
try {
|
|
7098
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
7099
|
+
var _triangle = _step5.value;
|
|
7100
|
+
this.fillColor(_triangle, this.style.fillStyle, bounds, type); // 单独为每个分割的图形填充
|
|
7101
|
+
// 如果指定的是img,则采用填充图片的方式
|
|
7102
|
+
|
|
7103
|
+
if (this.style.fillImage) {
|
|
7104
|
+
this.fillImage(this.style.fillImage, _triangle, bounds);
|
|
7105
|
+
}
|
|
7106
|
+
}
|
|
7107
|
+
} catch (err) {
|
|
7108
|
+
_iterator5.e(err);
|
|
7109
|
+
} finally {
|
|
7110
|
+
_iterator5.f();
|
|
7111
|
+
}
|
|
7112
|
+
|
|
7113
|
+
filled = true; // 表示已填充过了
|
|
7114
|
+
}
|
|
7115
|
+
}
|
|
7116
|
+
} catch (err) {
|
|
7117
|
+
_iterator4.e(err);
|
|
7118
|
+
} finally {
|
|
7119
|
+
_iterator4.f();
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7122
|
+
}
|
|
7123
|
+
} // 如果前面的条件没有填充成功,则直接按正常填充
|
|
7124
|
+
|
|
7125
|
+
|
|
7126
|
+
if (!filled) {
|
|
7127
|
+
this.fillColor(this.points, this.style.fillStyle, bounds, type); // 如果指定的是img,则采用填充图片的方式
|
|
7128
|
+
|
|
7129
|
+
if (this.style.fillImage) {
|
|
7130
|
+
this.fillImage(this.style.fillImage, this.points, bounds);
|
|
7131
|
+
}
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
}, {
|
|
7137
|
+
key: "fillColor",
|
|
7138
|
+
value: function fillColor(points, color, bounds) {
|
|
7139
|
+
var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
7140
|
+
|
|
7141
|
+
// 如果是渐变色,则需要计算偏移量的颜色
|
|
7142
|
+
if (this.isGradient(color)) {
|
|
7143
|
+
var imgData = color.toImageData(this, bounds);
|
|
7144
|
+
return this.fillImage(imgData, points, bounds);
|
|
7145
|
+
} // 标注为fill
|
|
7146
|
+
|
|
7147
|
+
|
|
7148
|
+
this.context.uniform1i(this.program.uniforms.a_type.location, type);
|
|
7149
|
+
var colorBuffer = this.setFragColor(color);
|
|
7150
|
+
var buffer = this.writePoints(points);
|
|
7151
|
+
this.context.drawArrays(this.context.TRIANGLE_FAN, 0, points.length);
|
|
7152
|
+
|
|
7153
|
+
if (buffer) {
|
|
7154
|
+
this.deleteBuffer(buffer);
|
|
7155
|
+
this.disableVertexAttribArray(buffer.attr);
|
|
7156
|
+
}
|
|
7157
|
+
|
|
7158
|
+
colorBuffer && this.deleteBuffer(colorBuffer);
|
|
7159
|
+
colorBuffer && this.disableVertexAttribArray(colorBuffer.attr); // 为线段顶点绘制
|
|
7160
|
+
|
|
7161
|
+
/*for(const p of points) {
|
|
7162
|
+
this.stroke([p], 'red', 10);
|
|
7163
|
+
}*/
|
|
7164
|
+
} // 区域填充图片
|
|
7165
|
+
// points绘制的图形顶点
|
|
7166
|
+
// 图片整体绘制区域
|
|
7167
|
+
|
|
7168
|
+
}, {
|
|
7169
|
+
key: "fillImage",
|
|
7170
|
+
value: function fillImage(img, points, bounds) {
|
|
7171
|
+
if (!img) return; // 设置纹理
|
|
7172
|
+
|
|
7173
|
+
var texture = img instanceof ImageData ? this.createDataTexture(img) : this.createImgTexture(img);
|
|
7174
|
+
this.context.uniform1i(this.program.uniforms.u_sample.location, 0); // 纹理单元传递给着色器
|
|
7175
|
+
// 指定纹理区域尺寸
|
|
7176
|
+
|
|
7177
|
+
this.context.uniform4f(this.program.uniforms.v_texture_bounds.location, bounds.left + this.parentAbsoluteBounds.left, bounds.top + this.parentAbsoluteBounds.top, bounds.width, bounds.height); // 纹理单元传递给着色器
|
|
7178
|
+
// 标注为纹理对象
|
|
7179
|
+
|
|
7180
|
+
this.context.uniform1i(this.program.uniforms.a_type.location, 2);
|
|
7181
|
+
var filled = false; // 是否成功填充
|
|
7182
|
+
// 3个以上的点,且非规则图形才需要切割
|
|
7183
|
+
|
|
7184
|
+
if (points.length > 3 && !this.isRegular) {
|
|
7185
|
+
var polygons = this.getPolygon(points);
|
|
7186
|
+
|
|
7187
|
+
if (polygons.length) {
|
|
7188
|
+
var _iterator6 = _createForOfIteratorHelper(polygons),
|
|
7189
|
+
_step6;
|
|
7190
|
+
|
|
7191
|
+
try {
|
|
7192
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
7193
|
+
var polygon = _step6.value;
|
|
7194
|
+
// 需要分割三角形,不然填充会有问题
|
|
7195
|
+
var triangles = this.earCutPointsToTriangles(polygon); // 切割得到三角形顶点二维数组
|
|
7196
|
+
|
|
7197
|
+
if (triangles && triangles.length) {
|
|
7198
|
+
var _iterator7 = _createForOfIteratorHelper(triangles),
|
|
7199
|
+
_step7;
|
|
7200
|
+
|
|
7201
|
+
try {
|
|
7202
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
7203
|
+
var triangle = _step7.value;
|
|
7204
|
+
this.fillTexture(triangle); // 单独为每个分割的图形填充
|
|
7205
|
+
}
|
|
7206
|
+
} catch (err) {
|
|
7207
|
+
_iterator7.e(err);
|
|
7208
|
+
} finally {
|
|
7209
|
+
_iterator7.f();
|
|
7210
|
+
}
|
|
7211
|
+
|
|
7212
|
+
filled = true; // 表示已填充过了
|
|
7213
|
+
}
|
|
7214
|
+
}
|
|
7215
|
+
} catch (err) {
|
|
7216
|
+
_iterator6.e(err);
|
|
7217
|
+
} finally {
|
|
7218
|
+
_iterator6.f();
|
|
7219
|
+
}
|
|
7220
|
+
}
|
|
7221
|
+
} // 如果前面的条件没有填充成功,则直接按正常填充
|
|
7222
|
+
|
|
7223
|
+
|
|
7224
|
+
if (!filled) {
|
|
7225
|
+
this.fillTexture(points);
|
|
7226
|
+
}
|
|
7227
|
+
|
|
7228
|
+
this.deleteTexture(texture);
|
|
7229
|
+
} // 填充图形
|
|
7230
|
+
|
|
7231
|
+
}, {
|
|
7232
|
+
key: "drawImage",
|
|
7233
|
+
value: function drawImage(img) {
|
|
7234
|
+
var left = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
7235
|
+
var top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
7236
|
+
var width = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : img.width;
|
|
7237
|
+
var height = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : img.height;
|
|
7238
|
+
width = width || img.width;
|
|
7239
|
+
height = height || img.height; //this.useProgram();
|
|
7240
|
+
|
|
7241
|
+
this.fillImage(img, this.points, {
|
|
7242
|
+
left: left,
|
|
7243
|
+
top: top,
|
|
7244
|
+
width: width,
|
|
7245
|
+
height: height
|
|
7246
|
+
});
|
|
7247
|
+
}
|
|
7248
|
+
}, {
|
|
7249
|
+
key: "fillTexture",
|
|
7250
|
+
value: function fillTexture(points) {
|
|
7251
|
+
// 纹理坐标
|
|
7252
|
+
var coordBuffer = this.writePoints(points, this.program.attrs.a_text_coord);
|
|
7253
|
+
|
|
7254
|
+
if (points && points.length) {
|
|
7255
|
+
var buffer = this.writePoints(points);
|
|
7256
|
+
this.context.drawArrays(this.context.TRIANGLE_FAN, 0, points.length);
|
|
7257
|
+
this.deleteBuffer(buffer);
|
|
7258
|
+
this.disableVertexAttribArray(buffer.attr);
|
|
7259
|
+
}
|
|
7260
|
+
|
|
7261
|
+
this.disableVertexAttribArray(coordBuffer.attr);
|
|
7262
|
+
this.deleteBuffer(coordBuffer);
|
|
7263
|
+
}
|
|
7264
|
+
}]);
|
|
7265
|
+
|
|
7266
|
+
return WebglPath;
|
|
7267
|
+
}(_base["default"]);
|
|
7268
|
+
|
|
7269
|
+
var _default = WebglPath;
|
|
7270
|
+
exports["default"] = _default;
|
|
7271
|
+
|
|
7272
|
+
},{"./base.js":13}],22:[function(require,module,exports){
|
|
7273
|
+
"use strict";
|
|
7274
|
+
|
|
7275
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
7276
|
+
|
|
7277
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7278
|
+
value: true
|
|
7279
|
+
});
|
|
7280
|
+
exports.jmArc = exports["default"] = void 0;
|
|
7281
|
+
|
|
7282
|
+
var _jmPath2 = require("../core/jmPath.js");
|
|
7283
|
+
|
|
7284
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7285
|
+
|
|
7286
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
7287
|
+
|
|
7288
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
7289
|
+
|
|
7290
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
7291
|
+
|
|
7292
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7293
|
+
|
|
7294
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7295
|
+
|
|
7296
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7297
|
+
|
|
7298
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
7299
|
+
|
|
7300
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
7301
|
+
|
|
7302
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
7303
|
+
|
|
7304
|
+
/**
|
|
7305
|
+
* 圆弧图型 继承自jmPath
|
|
7306
|
+
*
|
|
7307
|
+
* @class jmArc
|
|
7308
|
+
* @extends jmPath
|
|
7309
|
+
* @param {object} params center=当前圆弧中心,radius=圆弧半径,start=圆弧起始角度,end=圆弧结束角度,anticlockwise= false 顺时针,true 逆时针
|
|
7310
|
+
*/
|
|
7311
|
+
var jmArc = /*#__PURE__*/function (_jmPath) {
|
|
7312
|
+
_inherits(jmArc, _jmPath);
|
|
7313
|
+
|
|
7314
|
+
var _super = _createSuper(jmArc);
|
|
7315
|
+
|
|
7316
|
+
function jmArc(params) {
|
|
7317
|
+
var _this;
|
|
7318
|
+
|
|
7319
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmArc';
|
|
7320
|
+
|
|
7321
|
+
_classCallCheck(this, jmArc);
|
|
7322
|
+
|
|
7323
|
+
if (!params) params = {};
|
|
7324
|
+
params.isRegular = params.isRegular === false ? false : true; // 规则的
|
|
7325
|
+
|
|
7326
|
+
params.needCut = params.needCut === true ? true : false; // 规则的
|
|
7327
|
+
|
|
7328
|
+
_this = _super.call(this, params, t);
|
|
7329
|
+
_this.center = params.center || {
|
|
7330
|
+
x: 0,
|
|
7331
|
+
y: 0
|
|
7332
|
+
};
|
|
7333
|
+
_this.radius = params.radius || 0;
|
|
7334
|
+
_this.startAngle = params.start || params.startAngle || 0;
|
|
7335
|
+
_this.endAngle = params.end || params.endAngle || Math.PI * 2;
|
|
7336
|
+
_this.anticlockwise = params.anticlockwise || 0;
|
|
7337
|
+
_this.isFan = !!params.isFan;
|
|
7338
|
+
return _this;
|
|
7339
|
+
}
|
|
7340
|
+
/**
|
|
7341
|
+
* 中心点
|
|
7342
|
+
* point格式:{x:0,y:0,m:true}
|
|
7343
|
+
* @property center
|
|
7344
|
+
* @type {point}
|
|
7345
|
+
*/
|
|
7346
|
+
|
|
7347
|
+
|
|
7348
|
+
_createClass(jmArc, [{
|
|
7349
|
+
key: "center",
|
|
7350
|
+
get: function get() {
|
|
7351
|
+
return this.property('center');
|
|
7352
|
+
},
|
|
7353
|
+
set: function set(v) {
|
|
7354
|
+
this.needUpdate = true;
|
|
7355
|
+
return this.property('center', v);
|
|
7356
|
+
}
|
|
7357
|
+
/**
|
|
7358
|
+
* 半径
|
|
7359
|
+
* @property radius
|
|
7360
|
+
* @type {number}
|
|
7361
|
+
*/
|
|
7362
|
+
|
|
7363
|
+
}, {
|
|
7364
|
+
key: "radius",
|
|
7365
|
+
get: function get() {
|
|
7366
|
+
return this.property('radius');
|
|
7367
|
+
},
|
|
7368
|
+
set: function set(v) {
|
|
7369
|
+
this.needUpdate = true;
|
|
7370
|
+
return this.property('radius', v);
|
|
7371
|
+
}
|
|
7372
|
+
/**
|
|
7373
|
+
* 扇形起始角度
|
|
7374
|
+
* @property startAngle
|
|
7375
|
+
* @type {number}
|
|
7376
|
+
*/
|
|
7377
|
+
|
|
7378
|
+
}, {
|
|
7379
|
+
key: "startAngle",
|
|
7380
|
+
get: function get() {
|
|
7381
|
+
return this.property('startAngle');
|
|
7382
|
+
},
|
|
7383
|
+
set: function set(v) {
|
|
7384
|
+
this.needUpdate = true;
|
|
7385
|
+
return this.property('startAngle', v);
|
|
7386
|
+
}
|
|
7387
|
+
/**
|
|
7388
|
+
* 扇形结束角度
|
|
7389
|
+
* @property endAngle
|
|
7390
|
+
* @type {number}
|
|
7391
|
+
*/
|
|
7392
|
+
|
|
7393
|
+
}, {
|
|
7394
|
+
key: "endAngle",
|
|
7395
|
+
get: function get() {
|
|
7396
|
+
return this.property('endAngle');
|
|
7397
|
+
},
|
|
7398
|
+
set: function set(v) {
|
|
7399
|
+
this.needUpdate = true;
|
|
7400
|
+
return this.property('endAngle', v);
|
|
7401
|
+
}
|
|
7402
|
+
/**
|
|
7403
|
+
* 可选。规定应该逆时针还是顺时针绘图
|
|
7404
|
+
* false 顺时针,true 逆时针
|
|
7405
|
+
* @property anticlockwise
|
|
7406
|
+
* @type {boolean}
|
|
7407
|
+
*/
|
|
7408
|
+
|
|
7409
|
+
}, {
|
|
7410
|
+
key: "anticlockwise",
|
|
7411
|
+
get: function get() {
|
|
7412
|
+
return this.property('anticlockwise');
|
|
7413
|
+
},
|
|
7414
|
+
set: function set(v) {
|
|
7415
|
+
this.needUpdate = true;
|
|
7416
|
+
return this.property('anticlockwise', v);
|
|
7417
|
+
}
|
|
7418
|
+
/**
|
|
7419
|
+
* 初始化图形点
|
|
7420
|
+
*
|
|
4761
7421
|
* @method initPoint
|
|
4762
7422
|
* @private
|
|
4763
7423
|
* @for jmArc
|
|
@@ -4816,7 +7476,7 @@ var jmArc = /*#__PURE__*/function (_jmPath) {
|
|
|
4816
7476
|
|
|
4817
7477
|
exports.jmArc = exports["default"] = jmArc;
|
|
4818
7478
|
|
|
4819
|
-
},{"../core/jmPath.js":8}],
|
|
7479
|
+
},{"../core/jmPath.js":8}],23:[function(require,module,exports){
|
|
4820
7480
|
"use strict";
|
|
4821
7481
|
|
|
4822
7482
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -4897,11 +7557,11 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
4897
7557
|
_createClass(jmArrow, [{
|
|
4898
7558
|
key: "start",
|
|
4899
7559
|
get: function get() {
|
|
4900
|
-
return this.
|
|
7560
|
+
return this.property('start');
|
|
4901
7561
|
},
|
|
4902
7562
|
set: function set(v) {
|
|
4903
7563
|
this.needUpdate = true;
|
|
4904
|
-
return this.
|
|
7564
|
+
return this.property('start', v);
|
|
4905
7565
|
}
|
|
4906
7566
|
/**
|
|
4907
7567
|
* 控制结束点
|
|
@@ -4914,11 +7574,11 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
4914
7574
|
}, {
|
|
4915
7575
|
key: "end",
|
|
4916
7576
|
get: function get() {
|
|
4917
|
-
return this.
|
|
7577
|
+
return this.property('end');
|
|
4918
7578
|
},
|
|
4919
7579
|
set: function set(v) {
|
|
4920
7580
|
this.needUpdate = true;
|
|
4921
|
-
return this.
|
|
7581
|
+
return this.property('end', v);
|
|
4922
7582
|
}
|
|
4923
7583
|
/**
|
|
4924
7584
|
* 箭头角度
|
|
@@ -4931,11 +7591,11 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
4931
7591
|
}, {
|
|
4932
7592
|
key: "angle",
|
|
4933
7593
|
get: function get() {
|
|
4934
|
-
return this.
|
|
7594
|
+
return this.property('angle');
|
|
4935
7595
|
},
|
|
4936
7596
|
set: function set(v) {
|
|
4937
7597
|
this.needUpdate = true;
|
|
4938
|
-
return this.
|
|
7598
|
+
return this.property('angle', v);
|
|
4939
7599
|
}
|
|
4940
7600
|
/**
|
|
4941
7601
|
* 箭头X偏移量
|
|
@@ -4948,11 +7608,11 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
4948
7608
|
}, {
|
|
4949
7609
|
key: "offsetX",
|
|
4950
7610
|
get: function get() {
|
|
4951
|
-
return this.
|
|
7611
|
+
return this.property('offsetX');
|
|
4952
7612
|
},
|
|
4953
7613
|
set: function set(v) {
|
|
4954
7614
|
this.needUpdate = true;
|
|
4955
|
-
return this.
|
|
7615
|
+
return this.property('offsetX', v);
|
|
4956
7616
|
}
|
|
4957
7617
|
/**
|
|
4958
7618
|
* 箭头Y偏移量
|
|
@@ -4965,11 +7625,11 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
4965
7625
|
}, {
|
|
4966
7626
|
key: "offsetY",
|
|
4967
7627
|
get: function get() {
|
|
4968
|
-
return this.
|
|
7628
|
+
return this.property('offsetY');
|
|
4969
7629
|
},
|
|
4970
7630
|
set: function set(v) {
|
|
4971
7631
|
this.needUpdate = true;
|
|
4972
|
-
return this.
|
|
7632
|
+
return this.property('offsetY', v);
|
|
4973
7633
|
}
|
|
4974
7634
|
/**
|
|
4975
7635
|
* 初始化图形点
|
|
@@ -5040,7 +7700,7 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
5040
7700
|
|
|
5041
7701
|
exports.jmArrow = exports["default"] = jmArrow;
|
|
5042
7702
|
|
|
5043
|
-
},{"../core/jmPath.js":8,"../core/jmUtils.js":11}],
|
|
7703
|
+
},{"../core/jmPath.js":8,"../core/jmUtils.js":11}],24:[function(require,module,exports){
|
|
5044
7704
|
"use strict";
|
|
5045
7705
|
|
|
5046
7706
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5134,7 +7794,7 @@ var jmArrowLine = /*#__PURE__*/function (_jmLine) {
|
|
|
5134
7794
|
|
|
5135
7795
|
exports.jmArrowLine = exports["default"] = jmArrowLine;
|
|
5136
7796
|
|
|
5137
|
-
},{"./jmArrow.js":
|
|
7797
|
+
},{"./jmArrow.js":23,"./jmLine.js":30}],25:[function(require,module,exports){
|
|
5138
7798
|
"use strict";
|
|
5139
7799
|
|
|
5140
7800
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5207,11 +7867,11 @@ var jmBezier = /*#__PURE__*/function (_jmPath) {
|
|
|
5207
7867
|
_createClass(jmBezier, [{
|
|
5208
7868
|
key: "cpoints",
|
|
5209
7869
|
get: function get() {
|
|
5210
|
-
return this.
|
|
7870
|
+
return this.property('cpoints');
|
|
5211
7871
|
},
|
|
5212
7872
|
set: function set(v) {
|
|
5213
7873
|
this.needUpdate = true;
|
|
5214
|
-
return this.
|
|
7874
|
+
return this.property('cpoints', v);
|
|
5215
7875
|
}
|
|
5216
7876
|
/**
|
|
5217
7877
|
* 初始化图形点
|
|
@@ -5306,7 +7966,7 @@ var jmBezier = /*#__PURE__*/function (_jmPath) {
|
|
|
5306
7966
|
|
|
5307
7967
|
exports.jmBezier = exports["default"] = jmBezier;
|
|
5308
7968
|
|
|
5309
|
-
},{"../core/jmPath.js":8}],
|
|
7969
|
+
},{"../core/jmPath.js":8}],26:[function(require,module,exports){
|
|
5310
7970
|
"use strict";
|
|
5311
7971
|
|
|
5312
7972
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5324,6 +7984,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
5324
7984
|
|
|
5325
7985
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
5326
7986
|
|
|
7987
|
+
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
7988
|
+
|
|
7989
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
7990
|
+
|
|
5327
7991
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
5328
7992
|
|
|
5329
7993
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -5355,6 +8019,8 @@ var jmCircle = /*#__PURE__*/function (_jmArc) {
|
|
|
5355
8019
|
|
|
5356
8020
|
_classCallCheck(this, jmCircle);
|
|
5357
8021
|
|
|
8022
|
+
params.isRegular = true; // 规则的
|
|
8023
|
+
|
|
5358
8024
|
return _super.call(this, params, t);
|
|
5359
8025
|
}
|
|
5360
8026
|
/**
|
|
@@ -5369,6 +8035,10 @@ var jmCircle = /*#__PURE__*/function (_jmArc) {
|
|
|
5369
8035
|
_createClass(jmCircle, [{
|
|
5370
8036
|
key: "initPoints",
|
|
5371
8037
|
value: function initPoints() {
|
|
8038
|
+
if (this.graph.mode === 'webgl') {
|
|
8039
|
+
return _get(_getPrototypeOf(jmCircle.prototype), "initPoints", this).call(this);
|
|
8040
|
+
}
|
|
8041
|
+
|
|
5372
8042
|
var location = this.getLocation();
|
|
5373
8043
|
|
|
5374
8044
|
if (!location.radius) {
|
|
@@ -5402,6 +8072,10 @@ var jmCircle = /*#__PURE__*/function (_jmArc) {
|
|
|
5402
8072
|
}, {
|
|
5403
8073
|
key: "draw",
|
|
5404
8074
|
value: function draw() {
|
|
8075
|
+
if (this.graph.mode === 'webgl') {
|
|
8076
|
+
return _get(_getPrototypeOf(jmCircle.prototype), "draw", this).call(this);
|
|
8077
|
+
}
|
|
8078
|
+
|
|
5405
8079
|
var bounds = this.parent && this.parent.absoluteBounds ? this.parent.absoluteBounds : this.absoluteBounds;
|
|
5406
8080
|
var location = this.getLocation();
|
|
5407
8081
|
|
|
@@ -5422,7 +8096,7 @@ var jmCircle = /*#__PURE__*/function (_jmArc) {
|
|
|
5422
8096
|
|
|
5423
8097
|
exports.jmCircle = exports["default"] = jmCircle;
|
|
5424
8098
|
|
|
5425
|
-
},{"./jmArc.js":
|
|
8099
|
+
},{"./jmArc.js":22}],27:[function(require,module,exports){
|
|
5426
8100
|
"use strict";
|
|
5427
8101
|
|
|
5428
8102
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5473,6 +8147,9 @@ var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
|
5473
8147
|
|
|
5474
8148
|
_classCallCheck(this, jmHArc);
|
|
5475
8149
|
|
|
8150
|
+
params.isRegular = true; // 规则的
|
|
8151
|
+
|
|
8152
|
+
params.needCut = true;
|
|
5476
8153
|
_this = _super.call(this, params, t);
|
|
5477
8154
|
_this.minRadius = params.minRadius || _this.style.minRadius || 0;
|
|
5478
8155
|
_this.maxRadius = params.maxRadius || _this.style.maxRadius || 0;
|
|
@@ -5490,11 +8167,11 @@ var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
|
5490
8167
|
_createClass(jmHArc, [{
|
|
5491
8168
|
key: "minRadius",
|
|
5492
8169
|
get: function get() {
|
|
5493
|
-
return this.
|
|
8170
|
+
return this.property('minRadius');
|
|
5494
8171
|
},
|
|
5495
8172
|
set: function set(v) {
|
|
5496
8173
|
this.needUpdate = true;
|
|
5497
|
-
return this.
|
|
8174
|
+
return this.property('minRadius', v);
|
|
5498
8175
|
}
|
|
5499
8176
|
/**
|
|
5500
8177
|
* 设定或获取外空心圆半径
|
|
@@ -5507,11 +8184,11 @@ var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
|
5507
8184
|
}, {
|
|
5508
8185
|
key: "maxRadius",
|
|
5509
8186
|
get: function get() {
|
|
5510
|
-
return this.
|
|
8187
|
+
return this.property('maxRadius');
|
|
5511
8188
|
},
|
|
5512
8189
|
set: function set(v) {
|
|
5513
8190
|
this.needUpdate = true;
|
|
5514
|
-
return this.
|
|
8191
|
+
return this.property('maxRadius', v);
|
|
5515
8192
|
}
|
|
5516
8193
|
/**
|
|
5517
8194
|
* 初始化图形点
|
|
@@ -5579,7 +8256,7 @@ var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
|
5579
8256
|
|
|
5580
8257
|
exports.jmHArc = exports["default"] = jmHArc;
|
|
5581
8258
|
|
|
5582
|
-
},{"./jmArc.js":
|
|
8259
|
+
},{"./jmArc.js":22}],28:[function(require,module,exports){
|
|
5583
8260
|
"use strict";
|
|
5584
8261
|
|
|
5585
8262
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5631,6 +8308,8 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5631
8308
|
_classCallCheck(this, jmImage);
|
|
5632
8309
|
|
|
5633
8310
|
params = params || {};
|
|
8311
|
+
params.isRegular = true; // 规则的
|
|
8312
|
+
|
|
5634
8313
|
_this = _super.call(this, params, t || 'jmImage');
|
|
5635
8314
|
_this.style.fill = _this.fill || 'transparent'; //默认指定一个fill,为了可以鼠标选中
|
|
5636
8315
|
|
|
@@ -5651,10 +8330,10 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5651
8330
|
_createClass(jmImage, [{
|
|
5652
8331
|
key: "sourcePosition",
|
|
5653
8332
|
get: function get() {
|
|
5654
|
-
return this.
|
|
8333
|
+
return this.property('sourcePosition');
|
|
5655
8334
|
},
|
|
5656
8335
|
set: function set(v) {
|
|
5657
|
-
return this.
|
|
8336
|
+
return this.property('sourcePosition', v);
|
|
5658
8337
|
}
|
|
5659
8338
|
/**
|
|
5660
8339
|
* 被剪切宽度
|
|
@@ -5666,11 +8345,11 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5666
8345
|
}, {
|
|
5667
8346
|
key: "sourceWidth",
|
|
5668
8347
|
get: function get() {
|
|
5669
|
-
return this.
|
|
8348
|
+
return this.property('sourceWidth');
|
|
5670
8349
|
},
|
|
5671
8350
|
set: function set(v) {
|
|
5672
8351
|
this.needUpdate = true;
|
|
5673
|
-
return this.
|
|
8352
|
+
return this.property('sourceWidth', v);
|
|
5674
8353
|
}
|
|
5675
8354
|
/**
|
|
5676
8355
|
* 被剪切高度
|
|
@@ -5682,11 +8361,11 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5682
8361
|
}, {
|
|
5683
8362
|
key: "sourceHeight",
|
|
5684
8363
|
get: function get() {
|
|
5685
|
-
return this.
|
|
8364
|
+
return this.property('sourceHeight');
|
|
5686
8365
|
},
|
|
5687
8366
|
set: function set(v) {
|
|
5688
8367
|
this.needUpdate = true;
|
|
5689
|
-
return this.
|
|
8368
|
+
return this.property('sourceHeight', v);
|
|
5690
8369
|
}
|
|
5691
8370
|
/**
|
|
5692
8371
|
* 设定要绘制的图像或其它多媒体对象,可以是图片地址,或图片image对象
|
|
@@ -5698,11 +8377,11 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5698
8377
|
}, {
|
|
5699
8378
|
key: "image",
|
|
5700
8379
|
get: function get() {
|
|
5701
|
-
return this.
|
|
8380
|
+
return this.property('image');
|
|
5702
8381
|
},
|
|
5703
8382
|
set: function set(v) {
|
|
5704
8383
|
this.needUpdate = true;
|
|
5705
|
-
return this.
|
|
8384
|
+
return this.property('image', v);
|
|
5706
8385
|
}
|
|
5707
8386
|
/**
|
|
5708
8387
|
* 重写控件绘制
|
|
@@ -5714,25 +8393,9 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5714
8393
|
}, {
|
|
5715
8394
|
key: "draw",
|
|
5716
8395
|
value: function draw() {
|
|
5717
|
-
var _this2 = this;
|
|
5718
|
-
|
|
5719
8396
|
try {
|
|
5720
8397
|
var img = this.getImage();
|
|
5721
|
-
|
|
5722
|
-
if (this.graph.isWXMiniApp && this.graph.canvas && typeof img === 'string') {
|
|
5723
|
-
// 图片对象
|
|
5724
|
-
var image = this.graph.canvas.createImage(); // 图片加载完成回调
|
|
5725
|
-
|
|
5726
|
-
image.onload = function () {
|
|
5727
|
-
// 将图片绘制到 canvas 上
|
|
5728
|
-
_this2.drawImg(image);
|
|
5729
|
-
}; // 设置图片src
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
image.src = img;
|
|
5733
|
-
} else {
|
|
5734
|
-
this.drawImg(img);
|
|
5735
|
-
}
|
|
8398
|
+
this.drawImg(img);
|
|
5736
8399
|
} catch (e) {
|
|
5737
8400
|
console.error && console.error(e);
|
|
5738
8401
|
}
|
|
@@ -5741,7 +8404,7 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5741
8404
|
}, {
|
|
5742
8405
|
key: "drawImg",
|
|
5743
8406
|
value: function drawImg(img) {
|
|
5744
|
-
if (!img) {
|
|
8407
|
+
if (!img || !img.complete) {
|
|
5745
8408
|
console.warn('image is empty');
|
|
5746
8409
|
return;
|
|
5747
8410
|
}
|
|
@@ -5749,11 +8412,35 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5749
8412
|
var bounds = this.parent && this.parent.absoluteBounds ? this.parent.absoluteBounds : this.absoluteBounds;
|
|
5750
8413
|
if (!bounds) bounds = this.parent && this.parent.getAbsoluteBounds ? this.parent.getAbsoluteBounds() : this.getAbsoluteBounds();
|
|
5751
8414
|
var p = this.getLocation();
|
|
5752
|
-
p.left += bounds.left;
|
|
5753
|
-
p.top += bounds.top;
|
|
5754
8415
|
var sp = this.sourcePosition;
|
|
5755
8416
|
var sw = this.sourceWidth;
|
|
5756
8417
|
var sh = this.sourceHeight;
|
|
8418
|
+
var ctx = this.webglControl || this.context;
|
|
8419
|
+
|
|
8420
|
+
if (this.webglControl) {
|
|
8421
|
+
ctx.setParentBounds && ctx.setParentBounds(bounds);
|
|
8422
|
+
var localBounds = this.getBounds(); // 给图片给定顶点
|
|
8423
|
+
|
|
8424
|
+
ctx.draw([{
|
|
8425
|
+
x: localBounds.left,
|
|
8426
|
+
y: localBounds.top
|
|
8427
|
+
}, {
|
|
8428
|
+
x: localBounds.left + localBounds.width,
|
|
8429
|
+
y: localBounds.top
|
|
8430
|
+
}, {
|
|
8431
|
+
x: localBounds.left + localBounds.width,
|
|
8432
|
+
y: localBounds.top + localBounds.height
|
|
8433
|
+
}, {
|
|
8434
|
+
x: localBounds.left,
|
|
8435
|
+
y: localBounds.top + localBounds.height
|
|
8436
|
+
}], bounds);
|
|
8437
|
+
ctx.drawImage(img, localBounds.left, localBounds.top, localBounds.width, localBounds.height);
|
|
8438
|
+
return;
|
|
8439
|
+
} // 计算绝对定位
|
|
8440
|
+
|
|
8441
|
+
|
|
8442
|
+
p.left += bounds.left;
|
|
8443
|
+
p.top += bounds.top;
|
|
5757
8444
|
|
|
5758
8445
|
if (sp || typeof sw != 'undefined' || typeof sh != 'undefined') {
|
|
5759
8446
|
if (typeof sw == 'undefined') sw = p.width || img.width || 0;
|
|
@@ -5762,15 +8449,15 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5762
8449
|
x: 0,
|
|
5763
8450
|
y: 0
|
|
5764
8451
|
};
|
|
5765
|
-
if (p.width && p.height)
|
|
5766
|
-
|
|
8452
|
+
if (p.width && p.height) ctx.drawImage(img, sp.x, sp.y, sw, sh, p.left, p.top, p.width, p.height);else if (p.width) {
|
|
8453
|
+
ctx.drawImage(img, sp.x, sp.y, sw, sh, p.left, p.top, p.width, sh);
|
|
5767
8454
|
} else if (p.height) {
|
|
5768
|
-
|
|
5769
|
-
} else
|
|
8455
|
+
ctx.drawImage(img, sp.x, sp.y, sw, sh, p.left, p.top, sw, p.height);
|
|
8456
|
+
} else ctx.drawImage(img, sp.x, sp.y, sw, sh, p.left, p.top, sw, sh);
|
|
5770
8457
|
} else if (p) {
|
|
5771
|
-
if (p.width && p.height)
|
|
8458
|
+
if (p.width && p.height) ctx.drawImage(img, p.left, p.top, p.width, p.height);else if (p.width) ctx.drawImage(img, p.left, p.top, p.width, img.height);else if (p.height) ctx.drawImage(img, p.left, p.top, img.width, p.height);else ctx.drawImage(img, p.left, p.top);
|
|
5772
8459
|
} else {
|
|
5773
|
-
|
|
8460
|
+
ctx.drawImage(img);
|
|
5774
8461
|
}
|
|
5775
8462
|
}
|
|
5776
8463
|
/**
|
|
@@ -5806,6 +8493,8 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5806
8493
|
}, {
|
|
5807
8494
|
key: "getImage",
|
|
5808
8495
|
value: function getImage() {
|
|
8496
|
+
var _this2 = this;
|
|
8497
|
+
|
|
5809
8498
|
var src = this.image || this.style.src || this.style.image;
|
|
5810
8499
|
|
|
5811
8500
|
if (this.__img && this.__img.src && this.__img.src.indexOf(src) != -1) {
|
|
@@ -5814,11 +8503,27 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5814
8503
|
this.__img = src;
|
|
5815
8504
|
} else if (typeof document !== 'undefined' && document.createElement) {
|
|
5816
8505
|
this.__img = document.createElement('img');
|
|
8506
|
+
|
|
8507
|
+
this.__img.onload = function () {
|
|
8508
|
+
_this2.needUpdate = true;
|
|
8509
|
+
};
|
|
8510
|
+
|
|
5817
8511
|
if (src && typeof src == 'string') this.__img.src = src;
|
|
8512
|
+
} else if (this.graph.isWXMiniApp && this.graph.canvas && typeof src === 'string') {
|
|
8513
|
+
// 图片对象
|
|
8514
|
+
this.__img = this.graph.canvas.createImage();
|
|
8515
|
+
|
|
8516
|
+
this.__img.onload = function () {
|
|
8517
|
+
_this2.needUpdate = true;
|
|
8518
|
+
}; // 设置图片src
|
|
8519
|
+
|
|
8520
|
+
|
|
8521
|
+
this.__img.src = src;
|
|
5818
8522
|
} else {
|
|
5819
8523
|
this.__img = src;
|
|
5820
8524
|
}
|
|
5821
8525
|
|
|
8526
|
+
this.image = this.__img.src;
|
|
5822
8527
|
return this.__img;
|
|
5823
8528
|
}
|
|
5824
8529
|
}]);
|
|
@@ -5828,7 +8533,7 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
5828
8533
|
|
|
5829
8534
|
exports.jmImage = exports["default"] = jmImage;
|
|
5830
8535
|
|
|
5831
|
-
},{"../core/jmControl.js":2}],
|
|
8536
|
+
},{"../core/jmControl.js":2}],29:[function(require,module,exports){
|
|
5832
8537
|
"use strict";
|
|
5833
8538
|
|
|
5834
8539
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -5882,6 +8587,8 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
5882
8587
|
_classCallCheck(this, jmLabel);
|
|
5883
8588
|
|
|
5884
8589
|
params = params || {};
|
|
8590
|
+
params.isRegular = true; // 规则的
|
|
8591
|
+
|
|
5885
8592
|
_this = _super.call(this, params, t || 'jmLabel');
|
|
5886
8593
|
_this.style.font = _this.style.font || "15px Arial";
|
|
5887
8594
|
_this.style.fontFamily = _this.style.fontFamily || 'Arial';
|
|
@@ -5905,11 +8612,11 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
5905
8612
|
_createClass(jmLabel, [{
|
|
5906
8613
|
key: "text",
|
|
5907
8614
|
get: function get() {
|
|
5908
|
-
return this.
|
|
8615
|
+
return this.property('text');
|
|
5909
8616
|
},
|
|
5910
8617
|
set: function set(v) {
|
|
5911
8618
|
this.needUpdate = true;
|
|
5912
|
-
return this.
|
|
8619
|
+
return this.property('text', v);
|
|
5913
8620
|
}
|
|
5914
8621
|
/**
|
|
5915
8622
|
* 中心点
|
|
@@ -5921,11 +8628,11 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
5921
8628
|
}, {
|
|
5922
8629
|
key: "center",
|
|
5923
8630
|
get: function get() {
|
|
5924
|
-
return this.
|
|
8631
|
+
return this.property('center');
|
|
5925
8632
|
},
|
|
5926
8633
|
set: function set(v) {
|
|
5927
8634
|
this.needUpdate = true;
|
|
5928
|
-
return this.
|
|
8635
|
+
return this.property('center', v);
|
|
5929
8636
|
}
|
|
5930
8637
|
/**
|
|
5931
8638
|
* 当前位置左上角
|
|
@@ -5936,11 +8643,11 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
5936
8643
|
}, {
|
|
5937
8644
|
key: "position",
|
|
5938
8645
|
get: function get() {
|
|
5939
|
-
return this.
|
|
8646
|
+
return this.property('position');
|
|
5940
8647
|
},
|
|
5941
8648
|
set: function set(v) {
|
|
5942
8649
|
this.needUpdate = true;
|
|
5943
|
-
return this.
|
|
8650
|
+
return this.property('position', v);
|
|
5944
8651
|
}
|
|
5945
8652
|
/**
|
|
5946
8653
|
* 在基础的getLocation上,再加上一个特殊的center处理
|
|
@@ -6007,7 +8714,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
6007
8714
|
key: "testSize",
|
|
6008
8715
|
value: function testSize() {
|
|
6009
8716
|
if (this.__size) return this.__size;
|
|
6010
|
-
this.context.save(); // 修改字体,用来计算
|
|
8717
|
+
this.context.save && this.context.save(); // 修改字体,用来计算
|
|
6011
8718
|
|
|
6012
8719
|
this.setStyle({
|
|
6013
8720
|
font: this.style.font || this.style.fontSize + 'px ' + this.style.fontFamily
|
|
@@ -6016,7 +8723,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
6016
8723
|
this.__size = this.context.measureText ? this.context.measureText(this.text) : {
|
|
6017
8724
|
width: 15
|
|
6018
8725
|
};
|
|
6019
|
-
this.context.restore();
|
|
8726
|
+
this.context.restore && this.context.restore();
|
|
6020
8727
|
this.__size.height = this.style.fontSize ? this.style.fontSize : 15;
|
|
6021
8728
|
if (!this.width) this.width = this.__size.width;
|
|
6022
8729
|
if (!this.height) this.height = this.__size.height;
|
|
@@ -6091,7 +8798,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
6091
8798
|
if (this.style.border) {
|
|
6092
8799
|
//如果指定了边框样式
|
|
6093
8800
|
if (this.style.border.style) {
|
|
6094
|
-
this.context.save();
|
|
8801
|
+
this.context.save && this.context.save();
|
|
6095
8802
|
this.setStyle(this.style.border.style);
|
|
6096
8803
|
}
|
|
6097
8804
|
|
|
@@ -6118,7 +8825,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
6118
8825
|
|
|
6119
8826
|
|
|
6120
8827
|
if (this.style.border.style) {
|
|
6121
|
-
this.context.restore();
|
|
8828
|
+
this.context.restore && this.context.restore();
|
|
6122
8829
|
}
|
|
6123
8830
|
}
|
|
6124
8831
|
}
|
|
@@ -6129,7 +8836,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
6129
8836
|
|
|
6130
8837
|
exports.jmLabel = exports["default"] = jmLabel;
|
|
6131
8838
|
|
|
6132
|
-
},{"../core/jmControl.js":2}],
|
|
8839
|
+
},{"../core/jmControl.js":2}],30:[function(require,module,exports){
|
|
6133
8840
|
"use strict";
|
|
6134
8841
|
|
|
6135
8842
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -6180,6 +8887,8 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6180
8887
|
|
|
6181
8888
|
_classCallCheck(this, jmLine);
|
|
6182
8889
|
|
|
8890
|
+
params.isRegular = true; // 规则的
|
|
8891
|
+
|
|
6183
8892
|
_this = _super.call(this, params, t);
|
|
6184
8893
|
_this.start = params.start || {
|
|
6185
8894
|
x: 0,
|
|
@@ -6191,6 +8900,7 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6191
8900
|
};
|
|
6192
8901
|
_this.style.lineType = _this.style.lineType || 'solid';
|
|
6193
8902
|
_this.style.dashLength = _this.style.dashLength || 4;
|
|
8903
|
+
_this.style.close = false;
|
|
6194
8904
|
return _this;
|
|
6195
8905
|
}
|
|
6196
8906
|
/**
|
|
@@ -6205,11 +8915,11 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6205
8915
|
_createClass(jmLine, [{
|
|
6206
8916
|
key: "start",
|
|
6207
8917
|
get: function get() {
|
|
6208
|
-
return this.
|
|
8918
|
+
return this.property('start');
|
|
6209
8919
|
},
|
|
6210
8920
|
set: function set(v) {
|
|
6211
8921
|
this.needUpdate = true;
|
|
6212
|
-
return this.
|
|
8922
|
+
return this.property('start', v);
|
|
6213
8923
|
}
|
|
6214
8924
|
/**
|
|
6215
8925
|
* 控制结束点
|
|
@@ -6222,11 +8932,11 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6222
8932
|
}, {
|
|
6223
8933
|
key: "end",
|
|
6224
8934
|
get: function get() {
|
|
6225
|
-
return this.
|
|
8935
|
+
return this.property('end');
|
|
6226
8936
|
},
|
|
6227
8937
|
set: function set(v) {
|
|
6228
8938
|
this.needUpdate = true;
|
|
6229
|
-
return this.
|
|
8939
|
+
return this.property('end', v);
|
|
6230
8940
|
}
|
|
6231
8941
|
/**
|
|
6232
8942
|
* 初始化图形点,如呆为虚线则根据跳跃间隔描点
|
|
@@ -6253,21 +8963,20 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6253
8963
|
var dottedsp = dashLen / 2;
|
|
6254
8964
|
|
|
6255
8965
|
for (var l = dashLen; l <= lineLen;) {
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
8966
|
+
var p = {
|
|
8967
|
+
x: start.x + dx * l,
|
|
8968
|
+
y: start.y + dy * l
|
|
8969
|
+
};
|
|
8970
|
+
|
|
8971
|
+
if (dottedstart === false) {
|
|
6261
8972
|
l += dottedsp;
|
|
6262
8973
|
} else {
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
y: start.y + dy * l,
|
|
6266
|
-
m: true
|
|
6267
|
-
});
|
|
8974
|
+
p.m = true; // 移动到当时坐标
|
|
8975
|
+
|
|
6268
8976
|
l += dashLen;
|
|
6269
8977
|
}
|
|
6270
8978
|
|
|
8979
|
+
this.points.push(p);
|
|
6271
8980
|
dottedstart = !dottedstart;
|
|
6272
8981
|
}
|
|
6273
8982
|
}
|
|
@@ -6282,7 +8991,7 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
6282
8991
|
|
|
6283
8992
|
exports.jmLine = exports["default"] = jmLine;
|
|
6284
8993
|
|
|
6285
|
-
},{"../core/jmPath.js":8}],
|
|
8994
|
+
},{"../core/jmPath.js":8}],31:[function(require,module,exports){
|
|
6286
8995
|
"use strict";
|
|
6287
8996
|
|
|
6288
8997
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -6333,6 +9042,8 @@ var jmPrismatic = /*#__PURE__*/function (_jmPath) {
|
|
|
6333
9042
|
|
|
6334
9043
|
_classCallCheck(this, jmPrismatic);
|
|
6335
9044
|
|
|
9045
|
+
params.isRegular = true; // 规则的
|
|
9046
|
+
|
|
6336
9047
|
_this = _super.call(this, params, t);
|
|
6337
9048
|
_this.style.close = typeof _this.style.close == 'undefined' ? true : _this.style.close;
|
|
6338
9049
|
_this.center = params.center || {
|
|
@@ -6355,11 +9066,11 @@ var jmPrismatic = /*#__PURE__*/function (_jmPath) {
|
|
|
6355
9066
|
_createClass(jmPrismatic, [{
|
|
6356
9067
|
key: "center",
|
|
6357
9068
|
get: function get() {
|
|
6358
|
-
return this.
|
|
9069
|
+
return this.property('center');
|
|
6359
9070
|
},
|
|
6360
9071
|
set: function set(v) {
|
|
6361
9072
|
this.needUpdate = true;
|
|
6362
|
-
return this.
|
|
9073
|
+
return this.property('center', v);
|
|
6363
9074
|
}
|
|
6364
9075
|
/**
|
|
6365
9076
|
* 初始化图形点
|
|
@@ -6400,7 +9111,7 @@ var jmPrismatic = /*#__PURE__*/function (_jmPath) {
|
|
|
6400
9111
|
|
|
6401
9112
|
exports.jmPrismatic = exports["default"] = jmPrismatic;
|
|
6402
9113
|
|
|
6403
|
-
},{"../core/jmPath.js":8}],
|
|
9114
|
+
},{"../core/jmPath.js":8}],32:[function(require,module,exports){
|
|
6404
9115
|
"use strict";
|
|
6405
9116
|
|
|
6406
9117
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -6456,6 +9167,8 @@ var jmRect = /*#__PURE__*/function (_jmPath) {
|
|
|
6456
9167
|
_classCallCheck(this, jmRect);
|
|
6457
9168
|
|
|
6458
9169
|
params = params || {};
|
|
9170
|
+
params.isRegular = true; // 规则的
|
|
9171
|
+
|
|
6459
9172
|
_this = _super.call(this, params, t);
|
|
6460
9173
|
_this.style.close = true;
|
|
6461
9174
|
_this.radius = params.radius || _this.style.radius || 0;
|
|
@@ -6471,11 +9184,11 @@ var jmRect = /*#__PURE__*/function (_jmPath) {
|
|
|
6471
9184
|
_createClass(jmRect, [{
|
|
6472
9185
|
key: "radius",
|
|
6473
9186
|
get: function get() {
|
|
6474
|
-
return this.
|
|
9187
|
+
return this.property('radius');
|
|
6475
9188
|
},
|
|
6476
9189
|
set: function set(v) {
|
|
6477
9190
|
this.needUpdate = true;
|
|
6478
|
-
return this.
|
|
9191
|
+
return this.property('radius', v);
|
|
6479
9192
|
}
|
|
6480
9193
|
/**
|
|
6481
9194
|
* 当前位置左上角
|
|
@@ -6486,11 +9199,11 @@ var jmRect = /*#__PURE__*/function (_jmPath) {
|
|
|
6486
9199
|
}, {
|
|
6487
9200
|
key: "position",
|
|
6488
9201
|
get: function get() {
|
|
6489
|
-
return this.
|
|
9202
|
+
return this.property('position');
|
|
6490
9203
|
},
|
|
6491
9204
|
set: function set(v) {
|
|
6492
9205
|
this.needUpdate = true;
|
|
6493
|
-
return this.
|
|
9206
|
+
return this.property('position', v);
|
|
6494
9207
|
}
|
|
6495
9208
|
/**
|
|
6496
9209
|
* 获取当前控件的边界
|
|
@@ -6662,7 +9375,7 @@ var jmRect = /*#__PURE__*/function (_jmPath) {
|
|
|
6662
9375
|
|
|
6663
9376
|
exports.jmRect = exports["default"] = jmRect;
|
|
6664
9377
|
|
|
6665
|
-
},{"../core/jmPath.js":8,"./jmArc.js":
|
|
9378
|
+
},{"../core/jmPath.js":8,"./jmArc.js":22,"./jmLine.js":30}],33:[function(require,module,exports){
|
|
6666
9379
|
"use strict";
|
|
6667
9380
|
|
|
6668
9381
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -6715,6 +9428,8 @@ var jmResize = /*#__PURE__*/function (_jmRect) {
|
|
|
6715
9428
|
_classCallCheck(this, jmResize);
|
|
6716
9429
|
|
|
6717
9430
|
params = params || {};
|
|
9431
|
+
params.isRegular = true; // 规则的
|
|
9432
|
+
|
|
6718
9433
|
_this = _super.call(this, params, t); //是否可拉伸
|
|
6719
9434
|
|
|
6720
9435
|
_this.resizable = params.resizable === false ? false : true;
|
|
@@ -6736,10 +9451,10 @@ var jmResize = /*#__PURE__*/function (_jmRect) {
|
|
|
6736
9451
|
_createClass(jmResize, [{
|
|
6737
9452
|
key: "rectSize",
|
|
6738
9453
|
get: function get() {
|
|
6739
|
-
return this.
|
|
9454
|
+
return this.property('rectSize');
|
|
6740
9455
|
},
|
|
6741
9456
|
set: function set(v) {
|
|
6742
|
-
return this.
|
|
9457
|
+
return this.property('rectSize', v);
|
|
6743
9458
|
}
|
|
6744
9459
|
/**
|
|
6745
9460
|
* 是否可以拉大缩小
|
|
@@ -6750,10 +9465,10 @@ var jmResize = /*#__PURE__*/function (_jmRect) {
|
|
|
6750
9465
|
}, {
|
|
6751
9466
|
key: "resizable",
|
|
6752
9467
|
get: function get() {
|
|
6753
|
-
return this.
|
|
9468
|
+
return this.property('resizable');
|
|
6754
9469
|
},
|
|
6755
9470
|
set: function set(v) {
|
|
6756
|
-
return this.
|
|
9471
|
+
return this.property('resizable', v);
|
|
6757
9472
|
}
|
|
6758
9473
|
/**
|
|
6759
9474
|
* 初始化控件的8个拉伸方框
|
|
@@ -7015,5 +9730,5 @@ var jmResize = /*#__PURE__*/function (_jmRect) {
|
|
|
7015
9730
|
|
|
7016
9731
|
exports.jmResize = exports["default"] = jmResize;
|
|
7017
9732
|
|
|
7018
|
-
},{"./jmRect.js":
|
|
9733
|
+
},{"./jmRect.js":32}]},{},[1]);
|
|
7019
9734
|
var _r=_m(1);_g.jmGraph=_r;return _r;})})(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:(typeof self!=='undefined'?self:this)));
|