jmgraph 3.2.17 → 3.2.18
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 +1 -2
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +126 -9
- package/dist/jmgraph.min.js +1 -1
- package/example/pso.html +1 -1
- package/package.json +9 -6
- package/src/lib/webgl/base.js +70 -0
- package/src/lib/webgl/index.js +127 -1
- package/src/lib/webgl/path.js +9 -2
package/dist/jmgraph.js
CHANGED
|
@@ -5452,7 +5452,21 @@ var _texture = require("./core/texture.js");
|
|
|
5452
5452
|
|
|
5453
5453
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
5454
5454
|
|
|
5455
|
-
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(
|
|
5455
|
+
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(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
5456
|
+
|
|
5457
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5458
|
+
|
|
5459
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5460
|
+
|
|
5461
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
5462
|
+
|
|
5463
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5464
|
+
|
|
5465
|
+
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; }
|
|
5466
|
+
|
|
5467
|
+
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; }
|
|
5468
|
+
|
|
5469
|
+
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; }
|
|
5456
5470
|
|
|
5457
5471
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5458
5472
|
|
|
@@ -5466,12 +5480,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
5466
5480
|
|
|
5467
5481
|
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; }
|
|
5468
5482
|
|
|
5469
|
-
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; }
|
|
5470
|
-
|
|
5471
|
-
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; }
|
|
5472
|
-
|
|
5473
|
-
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; }
|
|
5474
|
-
|
|
5475
5483
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5476
5484
|
|
|
5477
5485
|
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); } }
|
|
@@ -5496,12 +5504,109 @@ var WeblBase = /*#__PURE__*/function () {
|
|
|
5496
5504
|
this.style = {
|
|
5497
5505
|
globalAlpha: 1
|
|
5498
5506
|
};
|
|
5507
|
+
this.stateStack = [];
|
|
5508
|
+
this.transformMatrix = [1, 0, 0, 1, 0, 0]; // 2D 变换矩阵
|
|
5499
5509
|
}
|
|
5500
5510
|
|
|
5501
5511
|
_createClass(WeblBase, [{
|
|
5502
5512
|
key: "context",
|
|
5503
5513
|
get: function get() {
|
|
5504
5514
|
if (this.graph) return this.graph.context;
|
|
5515
|
+
} // 保存当前状态
|
|
5516
|
+
|
|
5517
|
+
}, {
|
|
5518
|
+
key: "save",
|
|
5519
|
+
value: function save() {
|
|
5520
|
+
this.stateStack.push({
|
|
5521
|
+
transformMatrix: _toConsumableArray(this.transformMatrix),
|
|
5522
|
+
style: _objectSpread({}, this.style)
|
|
5523
|
+
});
|
|
5524
|
+
} // 恢复上一个状态
|
|
5525
|
+
|
|
5526
|
+
}, {
|
|
5527
|
+
key: "restore",
|
|
5528
|
+
value: function restore() {
|
|
5529
|
+
if (this.stateStack.length > 0) {
|
|
5530
|
+
var state = this.stateStack.pop();
|
|
5531
|
+
this.transformMatrix = state.transformMatrix;
|
|
5532
|
+
this.style = state.style;
|
|
5533
|
+
}
|
|
5534
|
+
} // 平移变换
|
|
5535
|
+
|
|
5536
|
+
}, {
|
|
5537
|
+
key: "translate",
|
|
5538
|
+
value: function translate(x, y) {
|
|
5539
|
+
// 更新变换矩阵
|
|
5540
|
+
this.transformMatrix[4] += x * this.transformMatrix[0] + y * this.transformMatrix[2];
|
|
5541
|
+
this.transformMatrix[5] += x * this.transformMatrix[1] + y * this.transformMatrix[3];
|
|
5542
|
+
} // 缩放变换
|
|
5543
|
+
|
|
5544
|
+
}, {
|
|
5545
|
+
key: "scale",
|
|
5546
|
+
value: function scale(sx, sy) {
|
|
5547
|
+
// 更新变换矩阵
|
|
5548
|
+
this.transformMatrix[0] *= sx;
|
|
5549
|
+
this.transformMatrix[1] *= sx;
|
|
5550
|
+
this.transformMatrix[2] *= sy;
|
|
5551
|
+
this.transformMatrix[3] *= sy;
|
|
5552
|
+
} // 旋转变换
|
|
5553
|
+
|
|
5554
|
+
}, {
|
|
5555
|
+
key: "rotate",
|
|
5556
|
+
value: function rotate(angle) {
|
|
5557
|
+
var cos = Math.cos(angle);
|
|
5558
|
+
var sin = Math.sin(angle);
|
|
5559
|
+
|
|
5560
|
+
var _this$transformMatrix = _slicedToArray(this.transformMatrix, 6),
|
|
5561
|
+
a = _this$transformMatrix[0],
|
|
5562
|
+
b = _this$transformMatrix[1],
|
|
5563
|
+
c = _this$transformMatrix[2],
|
|
5564
|
+
d = _this$transformMatrix[3],
|
|
5565
|
+
tx = _this$transformMatrix[4],
|
|
5566
|
+
ty = _this$transformMatrix[5]; // 更新变换矩阵
|
|
5567
|
+
|
|
5568
|
+
|
|
5569
|
+
this.transformMatrix[0] = a * cos - b * sin;
|
|
5570
|
+
this.transformMatrix[1] = a * sin + b * cos;
|
|
5571
|
+
this.transformMatrix[2] = c * cos - d * sin;
|
|
5572
|
+
this.transformMatrix[3] = c * sin + d * cos;
|
|
5573
|
+
} // 矩阵变换
|
|
5574
|
+
|
|
5575
|
+
}, {
|
|
5576
|
+
key: "transform",
|
|
5577
|
+
value: function transform(a, b, c, d, e, f) {
|
|
5578
|
+
var _this$transformMatrix2 = _slicedToArray(this.transformMatrix, 6),
|
|
5579
|
+
currentA = _this$transformMatrix2[0],
|
|
5580
|
+
currentB = _this$transformMatrix2[1],
|
|
5581
|
+
currentC = _this$transformMatrix2[2],
|
|
5582
|
+
currentD = _this$transformMatrix2[3],
|
|
5583
|
+
currentE = _this$transformMatrix2[4],
|
|
5584
|
+
currentF = _this$transformMatrix2[5]; // 矩阵乘法
|
|
5585
|
+
|
|
5586
|
+
|
|
5587
|
+
this.transformMatrix[0] = a * currentA + b * currentC;
|
|
5588
|
+
this.transformMatrix[1] = a * currentB + b * currentD;
|
|
5589
|
+
this.transformMatrix[2] = c * currentA + d * currentC;
|
|
5590
|
+
this.transformMatrix[3] = c * currentB + d * currentD;
|
|
5591
|
+
this.transformMatrix[4] = e * currentA + f * currentC + currentE;
|
|
5592
|
+
this.transformMatrix[5] = e * currentB + f * currentD + currentF;
|
|
5593
|
+
} // 应用变换到点
|
|
5594
|
+
|
|
5595
|
+
}, {
|
|
5596
|
+
key: "applyTransform",
|
|
5597
|
+
value: function applyTransform(point) {
|
|
5598
|
+
var _this$transformMatrix3 = _slicedToArray(this.transformMatrix, 6),
|
|
5599
|
+
a = _this$transformMatrix3[0],
|
|
5600
|
+
b = _this$transformMatrix3[1],
|
|
5601
|
+
c = _this$transformMatrix3[2],
|
|
5602
|
+
d = _this$transformMatrix3[3],
|
|
5603
|
+
tx = _this$transformMatrix3[4],
|
|
5604
|
+
ty = _this$transformMatrix3[5];
|
|
5605
|
+
|
|
5606
|
+
return {
|
|
5607
|
+
x: a * point.x + c * point.y + tx,
|
|
5608
|
+
y: b * point.x + d * point.y + ty
|
|
5609
|
+
};
|
|
5505
5610
|
} // 纹理绘制canvas
|
|
5506
5611
|
|
|
5507
5612
|
}, {
|
|
@@ -6512,6 +6617,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
6512
6617
|
|
|
6513
6618
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6514
6619
|
|
|
6620
|
+
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); }
|
|
6621
|
+
|
|
6622
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
6623
|
+
|
|
6515
6624
|
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); }
|
|
6516
6625
|
|
|
6517
6626
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -6544,9 +6653,15 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
6544
6653
|
_this.control = option.control;
|
|
6545
6654
|
_this.points = [];
|
|
6546
6655
|
return _this;
|
|
6547
|
-
}
|
|
6656
|
+
} // 应用变换到点
|
|
6657
|
+
|
|
6548
6658
|
|
|
6549
6659
|
_createClass(WebglPath, [{
|
|
6660
|
+
key: "applyTransform",
|
|
6661
|
+
value: function applyTransform(point) {
|
|
6662
|
+
return _get(_getPrototypeOf(WebglPath.prototype), "applyTransform", this).call(this, point);
|
|
6663
|
+
}
|
|
6664
|
+
}, {
|
|
6550
6665
|
key: "setParentBounds",
|
|
6551
6666
|
value: function setParentBounds() {
|
|
6552
6667
|
var parentBounds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.parentAbsoluteBounds;
|
|
@@ -6631,7 +6746,9 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
6631
6746
|
try {
|
|
6632
6747
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
6633
6748
|
var p = _step2.value;
|
|
6634
|
-
|
|
6749
|
+
// 应用变换矩阵
|
|
6750
|
+
var transformedPoint = this.applyTransform(p);
|
|
6751
|
+
fixedPoints.push(transformedPoint.x + this.parentAbsoluteBounds.left, transformedPoint.y + this.parentAbsoluteBounds.top);
|
|
6635
6752
|
}
|
|
6636
6753
|
} catch (err) {
|
|
6637
6754
|
_iterator2.e(err);
|