jmgraph 3.2.18 → 3.2.20
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 +174 -2
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +1672 -147
- package/dist/jmgraph.min.js +1 -1
- package/index.js +13 -2
- package/package.json +1 -1
- package/src/core/jmGraph.js +460 -5
- package/src/core/jmLayer.js +142 -0
- package/src/core/jmPath.js +55 -0
- package/src/lib/webgl/base.js +6 -0
- package/src/lib/webgl/path.js +8 -11
- package/src/shapes/jmEllipse.js +91 -0
- package/src/shapes/jmLabel.js +127 -15
- package/src/shapes/jmPolygon.js +129 -0
- package/src/shapes/jmStar.js +160 -0
- package/example/ball.html +0 -217
- package/example/base.html +0 -112
- package/example/canvas.html +0 -54
- package/example/cell.html +0 -284
- package/example/controls/arc.html +0 -129
- package/example/controls/arrowline.html +0 -78
- package/example/controls/bezier.html +0 -299
- package/example/controls/img.html +0 -97
- package/example/controls/label.html +0 -87
- package/example/controls/line.html +0 -173
- package/example/controls/prismatic.html +0 -63
- package/example/controls/rect.html +0 -64
- package/example/controls/resize.html +0 -112
- package/example/controls/test.html +0 -360
- package/example/es.html +0 -70
- package/example/es5module.html +0 -63
- package/example/heartarc.html +0 -116
- package/example/index.html +0 -47
- package/example/js/require.js +0 -5
- package/example/love/img/bling/bling.tps +0 -265
- package/example/love/img/bling.json +0 -87
- package/example/love/img/bling.tps +0 -295
- package/example/love/img/doc/bling.gif +0 -0
- package/example/love/img/love.json +0 -95
- package/example/love/img/love.tps +0 -315
- package/example/love/img/qq/qq.tps +0 -399
- package/example/love/img/qq.json +0 -242
- package/example/love/index.html +0 -40
- package/example/love/js/game.js +0 -558
- package/example/music.html +0 -211
- package/example/node/test.js +0 -138
- package/example/pdf.html +0 -187
- package/example/progress.html +0 -173
- package/example/pso.html +0 -148
- package/example/sort.html +0 -805
- package/example/tweenjs.html +0 -84
- package/example/webgl.html +0 -278
- package/example/xfj/img/dr_die.gif +0 -0
- package/example/xfj/index.html +0 -332
- package/example/xfj/shake.js +0 -49
- package/example/xfj/testori.html +0 -76
package/dist/jmgraph.js
CHANGED
|
@@ -78,6 +78,24 @@ Object.defineProperty(exports, "jmResize", {
|
|
|
78
78
|
return _jmResize.jmResize;
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
+
Object.defineProperty(exports, "jmEllipse", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function get() {
|
|
84
|
+
return _jmEllipse.jmEllipse;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, "jmPolygon", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function get() {
|
|
90
|
+
return _jmPolygon.jmPolygon;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "jmStar", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function get() {
|
|
96
|
+
return _jmStar.jmStar;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
81
99
|
Object.defineProperty(exports, "jmUtils", {
|
|
82
100
|
enumerable: true,
|
|
83
101
|
get: function get() {
|
|
@@ -114,6 +132,12 @@ Object.defineProperty(exports, "jmPath", {
|
|
|
114
132
|
return _jmGraph.jmPath;
|
|
115
133
|
}
|
|
116
134
|
});
|
|
135
|
+
Object.defineProperty(exports, "jmLayer", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function get() {
|
|
138
|
+
return _jmGraph.jmLayer;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
117
141
|
exports.create = exports.jmGraph = exports["default"] = void 0;
|
|
118
142
|
|
|
119
143
|
var _jmArc = require("./src/shapes/jmArc.js");
|
|
@@ -140,6 +164,12 @@ var _jmLabel = require("./src/shapes/jmLabel.js");
|
|
|
140
164
|
|
|
141
165
|
var _jmResize = require("./src/shapes/jmResize.js");
|
|
142
166
|
|
|
167
|
+
var _jmEllipse = require("./src/shapes/jmEllipse.js");
|
|
168
|
+
|
|
169
|
+
var _jmPolygon = require("./src/shapes/jmPolygon.js");
|
|
170
|
+
|
|
171
|
+
var _jmStar = require("./src/shapes/jmStar.js");
|
|
172
|
+
|
|
143
173
|
var _jmGraph = require("./src/core/jmGraph.js");
|
|
144
174
|
|
|
145
175
|
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); }
|
|
@@ -177,7 +207,10 @@ var shapes = {
|
|
|
177
207
|
"image": _jmImage.jmImage,
|
|
178
208
|
"img": _jmImage.jmImage,
|
|
179
209
|
"label": _jmLabel.jmLabel,
|
|
180
|
-
"resize": _jmResize.jmResize
|
|
210
|
+
"resize": _jmResize.jmResize,
|
|
211
|
+
"ellipse": _jmEllipse.jmEllipse,
|
|
212
|
+
"polygon": _jmPolygon.jmPolygon,
|
|
213
|
+
"star": _jmStar.jmStar
|
|
181
214
|
};
|
|
182
215
|
|
|
183
216
|
var jmGraph = /*#__PURE__*/function (_jmGraphCore) {
|
|
@@ -233,7 +266,7 @@ var createJmGraph = function createJmGraph() {
|
|
|
233
266
|
|
|
234
267
|
exports.create = createJmGraph;
|
|
235
268
|
|
|
236
|
-
},{"./src/core/jmGraph.js":5,"./src/shapes/jmArc.js":
|
|
269
|
+
},{"./src/core/jmGraph.js":5,"./src/shapes/jmArc.js":23,"./src/shapes/jmArrow.js":24,"./src/shapes/jmArrowLine.js":25,"./src/shapes/jmBezier.js":26,"./src/shapes/jmCircle.js":27,"./src/shapes/jmEllipse.js":28,"./src/shapes/jmHArc.js":29,"./src/shapes/jmImage.js":30,"./src/shapes/jmLabel.js":31,"./src/shapes/jmLine.js":32,"./src/shapes/jmPolygon.js":33,"./src/shapes/jmPrismatic.js":34,"./src/shapes/jmRect.js":35,"./src/shapes/jmResize.js":36,"./src/shapes/jmStar.js":37}],2:[function(require,module,exports){
|
|
237
270
|
"use strict";
|
|
238
271
|
|
|
239
272
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -1895,7 +1928,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1895
1928
|
exports.jmControl = exports["default"] = jmControl;
|
|
1896
1929
|
;
|
|
1897
1930
|
|
|
1898
|
-
},{"../lib/webgl/path.js":
|
|
1931
|
+
},{"../lib/webgl/path.js":22,"./jmGradient.js":4,"./jmList.js":7,"./jmProperty.js":10,"./jmShadow.js":11,"./jmUtils.js":12}],3:[function(require,module,exports){
|
|
1899
1932
|
"use strict";
|
|
1900
1933
|
|
|
1901
1934
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -2169,7 +2202,7 @@ var jmKeyEvent = /*#__PURE__*/function () {
|
|
|
2169
2202
|
return jmKeyEvent;
|
|
2170
2203
|
}();
|
|
2171
2204
|
|
|
2172
|
-
},{"./jmUtils.js":
|
|
2205
|
+
},{"./jmUtils.js":12}],4:[function(require,module,exports){
|
|
2173
2206
|
"use strict";
|
|
2174
2207
|
|
|
2175
2208
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -2452,7 +2485,7 @@ var jmGradient = /*#__PURE__*/function () {
|
|
|
2452
2485
|
|
|
2453
2486
|
exports.jmGradient = exports["default"] = jmGradient;
|
|
2454
2487
|
|
|
2455
|
-
},{"./jmList.js":
|
|
2488
|
+
},{"./jmList.js":7,"./jmUtils.js":12}],5:[function(require,module,exports){
|
|
2456
2489
|
"use strict";
|
|
2457
2490
|
|
|
2458
2491
|
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); }
|
|
@@ -2508,6 +2541,12 @@ Object.defineProperty(exports, "jmPath", {
|
|
|
2508
2541
|
return _jmPath.jmPath;
|
|
2509
2542
|
}
|
|
2510
2543
|
});
|
|
2544
|
+
Object.defineProperty(exports, "jmLayer", {
|
|
2545
|
+
enumerable: true,
|
|
2546
|
+
get: function get() {
|
|
2547
|
+
return _jmLayer.jmLayer;
|
|
2548
|
+
}
|
|
2549
|
+
});
|
|
2511
2550
|
exports.jmGraph = exports["default"] = void 0;
|
|
2512
2551
|
|
|
2513
2552
|
var _jmUtils = require("./jmUtils.js");
|
|
@@ -2526,6 +2565,8 @@ var _jmControl2 = require("./jmControl.js");
|
|
|
2526
2565
|
|
|
2527
2566
|
var _jmPath = require("./jmPath.js");
|
|
2528
2567
|
|
|
2568
|
+
var _jmLayer = require("./jmLayer.js");
|
|
2569
|
+
|
|
2529
2570
|
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); }
|
|
2530
2571
|
|
|
2531
2572
|
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; }
|
|
@@ -2597,7 +2638,13 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2597
2638
|
|
|
2598
2639
|
_this.util = _this.utils = _jmUtils.jmUtils; // 模式 webgl | 2d
|
|
2599
2640
|
|
|
2600
|
-
_this.mode = option.mode || '2d';
|
|
2641
|
+
_this.mode = option.mode || '2d'; // 缩放和平移相关
|
|
2642
|
+
|
|
2643
|
+
_this.scaleFactor = 1;
|
|
2644
|
+
_this.translation = {
|
|
2645
|
+
x: 0,
|
|
2646
|
+
y: 0
|
|
2647
|
+
}; //如果是小程序
|
|
2601
2648
|
|
|
2602
2649
|
if (typeof wx != 'undefined' && wx.canIUse && wx.canIUse('canvas')) {
|
|
2603
2650
|
if (typeof canvas === 'string') canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
@@ -2623,8 +2670,16 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2623
2670
|
}
|
|
2624
2671
|
}
|
|
2625
2672
|
|
|
2626
|
-
_this.canvas = canvas;
|
|
2627
|
-
|
|
2673
|
+
_this.canvas = canvas; // Create context with preserveDrawingBuffer for webgl to prevent flickering
|
|
2674
|
+
|
|
2675
|
+
if (_this.mode === 'webgl') {
|
|
2676
|
+
_this.context = canvas.getContext(_this.mode, {
|
|
2677
|
+
preserveDrawingBuffer: true
|
|
2678
|
+
});
|
|
2679
|
+
} else {
|
|
2680
|
+
_this.context = canvas.getContext(_this.mode);
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2628
2683
|
_this.textureCanvas = option.textureCanvas || null; // webgl模式
|
|
2629
2684
|
|
|
2630
2685
|
if (_this.mode === 'webgl') {
|
|
@@ -2675,14 +2730,24 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2675
2730
|
*/
|
|
2676
2731
|
|
|
2677
2732
|
this.on('beginDraw', function () {
|
|
2678
|
-
this.context.translate && this.context.translate(0.5, 0.5);
|
|
2733
|
+
this.context.translate && this.context.translate(0.5, 0.5); // 应用缩放和平移变换
|
|
2734
|
+
|
|
2735
|
+
if (this.context.translate && this.context.scale) {
|
|
2736
|
+
this.context.translate(this.translation.x, this.translation.y);
|
|
2737
|
+
this.context.scale(this.scaleFactor, this.scaleFactor);
|
|
2738
|
+
}
|
|
2679
2739
|
});
|
|
2680
2740
|
/**
|
|
2681
2741
|
* 结束控件绘制 为了解决一像素线条问题
|
|
2682
2742
|
*/
|
|
2683
2743
|
|
|
2684
2744
|
this.on('endDraw', function () {
|
|
2685
|
-
this.context.translate && this.context.translate(-0.5, -0.5);
|
|
2745
|
+
this.context.translate && this.context.translate(-0.5, -0.5); // 恢复缩放和平移变换
|
|
2746
|
+
|
|
2747
|
+
if (this.context.translate && this.context.scale) {
|
|
2748
|
+
this.context.scale(1 / this.scaleFactor, 1 / this.scaleFactor);
|
|
2749
|
+
this.context.translate(-this.translation.x, -this.translation.y);
|
|
2750
|
+
}
|
|
2686
2751
|
}); // devicePixelRatio初始化
|
|
2687
2752
|
|
|
2688
2753
|
var dpr = typeof window != 'undefined' && window.devicePixelRatio > 1 ? window.devicePixelRatio : 1;
|
|
@@ -2837,7 +2902,9 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2837
2902
|
if (shape) {
|
|
2838
2903
|
if (!args) args = {};
|
|
2839
2904
|
args.graph = this;
|
|
2840
|
-
var obj = new shape(args);
|
|
2905
|
+
var obj = new shape(args); // 添加到活动图层
|
|
2906
|
+
|
|
2907
|
+
this.addShapeToLayer(obj);
|
|
2841
2908
|
return obj;
|
|
2842
2909
|
}
|
|
2843
2910
|
}
|
|
@@ -3120,6 +3187,334 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
3120
3187
|
|
|
3121
3188
|
this.canvas.style && (this.canvas.style.transform = "scale(".concat(this.scaleSize.x, ", ").concat(this.scaleSize.y, ")"));
|
|
3122
3189
|
}
|
|
3190
|
+
/**
|
|
3191
|
+
* 设置缩放因子
|
|
3192
|
+
* 支持以指定点为中心进行缩放,保持该点在屏幕上的位置不变
|
|
3193
|
+
*
|
|
3194
|
+
* @method setZoom
|
|
3195
|
+
* @param {number} zoom 缩放因子(建议范围:0.1 - 10)
|
|
3196
|
+
* @param {number} [x] 缩放中心X坐标(画布坐标)
|
|
3197
|
+
* @param {number} [y] 缩放中心Y坐标(画布坐标)
|
|
3198
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3199
|
+
*/
|
|
3200
|
+
|
|
3201
|
+
}, {
|
|
3202
|
+
key: "setZoom",
|
|
3203
|
+
value: function setZoom(zoom, x, y) {
|
|
3204
|
+
// 参数验证
|
|
3205
|
+
if (typeof zoom !== 'number' || isNaN(zoom)) {
|
|
3206
|
+
console.warn('jmGraph: setZoom - 无效的缩放因子');
|
|
3207
|
+
return this;
|
|
3208
|
+
} // 限制缩放范围,防止过度缩放导致性能问题或显示异常
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
var minZoom = 0.1; // 最小缩放到10%
|
|
3212
|
+
|
|
3213
|
+
var maxZoom = 10; // 最大放大到10倍
|
|
3214
|
+
|
|
3215
|
+
zoom = Math.max(minZoom, Math.min(maxZoom, zoom));
|
|
3216
|
+
|
|
3217
|
+
if (x !== undefined && y !== undefined) {
|
|
3218
|
+
// 计算缩放前后的坐标偏移
|
|
3219
|
+
// 保持缩放中心点在屏幕上的位置不变
|
|
3220
|
+
var oldZoom = this.scaleFactor;
|
|
3221
|
+
var newZoom = zoom; // 调整平移量以保持缩放中心位置不变
|
|
3222
|
+
|
|
3223
|
+
this.translation.x = x - (x - this.translation.x) * (newZoom / oldZoom);
|
|
3224
|
+
this.translation.y = y - (y - this.translation.y) * (newZoom / oldZoom);
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
this.scaleFactor = zoom;
|
|
3228
|
+
this.needUpdate = true;
|
|
3229
|
+
this.redraw();
|
|
3230
|
+
return this; // 支持链式调用
|
|
3231
|
+
}
|
|
3232
|
+
/**
|
|
3233
|
+
* 平移画布
|
|
3234
|
+
* 移动画布视图,改变可视区域
|
|
3235
|
+
*
|
|
3236
|
+
* @method pan
|
|
3237
|
+
* @param {number} dx X轴平移量(像素)
|
|
3238
|
+
* @param {number} dy Y轴平移量(像素)
|
|
3239
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3240
|
+
*/
|
|
3241
|
+
|
|
3242
|
+
}, {
|
|
3243
|
+
key: "pan",
|
|
3244
|
+
value: function pan(dx, dy) {
|
|
3245
|
+
// 参数验证
|
|
3246
|
+
if (typeof dx !== 'number' || typeof dy !== 'number' || isNaN(dx) || isNaN(dy)) {
|
|
3247
|
+
console.warn('jmGraph: pan - 无效的平移参数');
|
|
3248
|
+
return this;
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
this.translation.x += dx;
|
|
3252
|
+
this.translation.y += dy;
|
|
3253
|
+
this.needUpdate = true;
|
|
3254
|
+
this.redraw();
|
|
3255
|
+
return this; // 支持链式调用
|
|
3256
|
+
}
|
|
3257
|
+
/**
|
|
3258
|
+
* 重置缩放和平移
|
|
3259
|
+
* 恢复画布到初始状态(缩放为1,平移为0)
|
|
3260
|
+
*
|
|
3261
|
+
* @method resetTransform
|
|
3262
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3263
|
+
*/
|
|
3264
|
+
|
|
3265
|
+
}, {
|
|
3266
|
+
key: "resetTransform",
|
|
3267
|
+
value: function resetTransform() {
|
|
3268
|
+
this.scaleFactor = 1;
|
|
3269
|
+
this.translation = {
|
|
3270
|
+
x: 0,
|
|
3271
|
+
y: 0
|
|
3272
|
+
};
|
|
3273
|
+
this.needUpdate = true;
|
|
3274
|
+
this.redraw();
|
|
3275
|
+
return this; // 支持链式调用
|
|
3276
|
+
}
|
|
3277
|
+
/**
|
|
3278
|
+
* 初始化图层系统
|
|
3279
|
+
* 创建图层管理的基础结构,包括默认图层
|
|
3280
|
+
*
|
|
3281
|
+
* @method initLayers
|
|
3282
|
+
* @private
|
|
3283
|
+
*/
|
|
3284
|
+
|
|
3285
|
+
}, {
|
|
3286
|
+
key: "initLayers",
|
|
3287
|
+
value: function initLayers() {
|
|
3288
|
+
if (!this.layers) {
|
|
3289
|
+
this.layers = new _jmList.jmList(); // 创建默认图层
|
|
3290
|
+
|
|
3291
|
+
var defaultLayer = this.createLayer('Default Layer');
|
|
3292
|
+
this.activeLayer = defaultLayer;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* 创建新图层
|
|
3297
|
+
* 图层用于组织和管理图形对象,支持可见性和锁定控制
|
|
3298
|
+
*
|
|
3299
|
+
* @method createLayer
|
|
3300
|
+
* @param {string} name 图层名称(必须唯一)
|
|
3301
|
+
* @param {object} [options] 图层选项
|
|
3302
|
+
* @param {boolean} [options.visible=true] 图层是否可见
|
|
3303
|
+
* @param {boolean} [options.locked=false] 图层是否锁定(锁定后不可交互)
|
|
3304
|
+
* @return {jmLayer} 新创建的图层
|
|
3305
|
+
*/
|
|
3306
|
+
|
|
3307
|
+
}, {
|
|
3308
|
+
key: "createLayer",
|
|
3309
|
+
value: function createLayer(name) {
|
|
3310
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3311
|
+
|
|
3312
|
+
// 参数验证
|
|
3313
|
+
if (!name || typeof name !== 'string') {
|
|
3314
|
+
console.warn('jmGraph: createLayer - 图层名称必须是非空字符串');
|
|
3315
|
+
name = "Layer_".concat(Date.now());
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
this.initLayers(); // 检查图层名称是否已存在
|
|
3319
|
+
|
|
3320
|
+
var existingLayer = this.getLayer(name);
|
|
3321
|
+
|
|
3322
|
+
if (existingLayer) {
|
|
3323
|
+
console.warn("jmGraph: \u56FE\u5C42 \"".concat(name, "\" \u5DF2\u5B58\u5728\uFF0C\u5C06\u8FD4\u56DE\u73B0\u6709\u56FE\u5C42"));
|
|
3324
|
+
return existingLayer;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
var layer = new _jmLayer.jmLayer(_objectSpread({
|
|
3328
|
+
name: name,
|
|
3329
|
+
graph: this
|
|
3330
|
+
}, options));
|
|
3331
|
+
this.layers.add(layer);
|
|
3332
|
+
this.children.add(layer);
|
|
3333
|
+
this.needUpdate = true;
|
|
3334
|
+
return layer;
|
|
3335
|
+
}
|
|
3336
|
+
/**
|
|
3337
|
+
* 获取所有图层
|
|
3338
|
+
*
|
|
3339
|
+
* @method getLayers
|
|
3340
|
+
* @return {jmList} 图层列表
|
|
3341
|
+
*/
|
|
3342
|
+
|
|
3343
|
+
}, {
|
|
3344
|
+
key: "getLayers",
|
|
3345
|
+
value: function getLayers() {
|
|
3346
|
+
this.initLayers();
|
|
3347
|
+
return this.layers;
|
|
3348
|
+
}
|
|
3349
|
+
/**
|
|
3350
|
+
* 根据名称获取图层
|
|
3351
|
+
*
|
|
3352
|
+
* @method getLayer
|
|
3353
|
+
* @param {string} name 图层名称
|
|
3354
|
+
* @return {jmLayer|null} 图层对象,如果不存在则返回null
|
|
3355
|
+
*/
|
|
3356
|
+
|
|
3357
|
+
}, {
|
|
3358
|
+
key: "getLayer",
|
|
3359
|
+
value: function getLayer(name) {
|
|
3360
|
+
this.initLayers();
|
|
3361
|
+
if (!name) return null;
|
|
3362
|
+
var result = null;
|
|
3363
|
+
this.layers.each(function (i, layer) {
|
|
3364
|
+
if (layer.name === name) {
|
|
3365
|
+
result = layer;
|
|
3366
|
+
return false; // 找到后停止遍历
|
|
3367
|
+
}
|
|
3368
|
+
});
|
|
3369
|
+
return result;
|
|
3370
|
+
}
|
|
3371
|
+
/**
|
|
3372
|
+
* 设置活动图层
|
|
3373
|
+
* 新创建的图形将自动添加到活动图层
|
|
3374
|
+
*
|
|
3375
|
+
* @method setActiveLayer
|
|
3376
|
+
* @param {string|jmLayer} layer 图层名称或图层对象
|
|
3377
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3378
|
+
*/
|
|
3379
|
+
|
|
3380
|
+
}, {
|
|
3381
|
+
key: "setActiveLayer",
|
|
3382
|
+
value: function setActiveLayer(layer) {
|
|
3383
|
+
this.initLayers(); // 支持传入图层名称或图层对象
|
|
3384
|
+
|
|
3385
|
+
if (typeof layer === 'string') {
|
|
3386
|
+
layer = this.getLayer(layer);
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
if (!layer || !(layer instanceof _jmLayer.jmLayer)) {
|
|
3390
|
+
console.warn('jmGraph: setActiveLayer - 无效的图层');
|
|
3391
|
+
return this;
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3394
|
+
this.activeLayer = layer;
|
|
3395
|
+
return this;
|
|
3396
|
+
}
|
|
3397
|
+
/**
|
|
3398
|
+
* 获取当前活动图层
|
|
3399
|
+
* 活动图层是新创建图形的默认容器
|
|
3400
|
+
*
|
|
3401
|
+
* @method getActiveLayer
|
|
3402
|
+
* @return {jmLayer} 当前活动图层
|
|
3403
|
+
*/
|
|
3404
|
+
|
|
3405
|
+
}, {
|
|
3406
|
+
key: "getActiveLayer",
|
|
3407
|
+
value: function getActiveLayer() {
|
|
3408
|
+
this.initLayers();
|
|
3409
|
+
return this.activeLayer;
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* 移除图层
|
|
3413
|
+
* 删除指定图层及其包含的所有图形
|
|
3414
|
+
* 注意:默认图层不可删除
|
|
3415
|
+
*
|
|
3416
|
+
* @method removeLayer
|
|
3417
|
+
* @param {string|jmLayer} layer 图层名称或图层对象
|
|
3418
|
+
* @return {boolean} 是否成功删除
|
|
3419
|
+
*/
|
|
3420
|
+
|
|
3421
|
+
}, {
|
|
3422
|
+
key: "removeLayer",
|
|
3423
|
+
value: function removeLayer(layer) {
|
|
3424
|
+
this.initLayers(); // 支持传入图层名称或图层对象
|
|
3425
|
+
|
|
3426
|
+
if (typeof layer === 'string') {
|
|
3427
|
+
layer = this.getLayer(layer);
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3430
|
+
if (!layer) {
|
|
3431
|
+
console.warn('jmGraph: removeLayer - 图层不存在');
|
|
3432
|
+
return false;
|
|
3433
|
+
} // 禁止删除默认图层
|
|
3434
|
+
|
|
3435
|
+
|
|
3436
|
+
if (layer.name === 'Default Layer') {
|
|
3437
|
+
console.warn('jmGraph: 不能删除默认图层');
|
|
3438
|
+
return false;
|
|
3439
|
+
} // 如果删除的是当前活动图层,切换到默认图层
|
|
3440
|
+
|
|
3441
|
+
|
|
3442
|
+
if (this.activeLayer === layer) {
|
|
3443
|
+
this.activeLayer = this.getLayer('Default Layer');
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
this.layers.remove(layer);
|
|
3447
|
+
this.children.remove(layer);
|
|
3448
|
+
this.needUpdate = true;
|
|
3449
|
+
return true;
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* 将形状添加到指定图层
|
|
3453
|
+
* 如果未指定图层,则添加到当前活动图层
|
|
3454
|
+
*
|
|
3455
|
+
* @method addShapeToLayer
|
|
3456
|
+
* @param {jmControl} shape 要添加的形状对象
|
|
3457
|
+
* @param {string|jmLayer} [layer] 图层名称或图层对象,默认为当前活动图层
|
|
3458
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3459
|
+
*/
|
|
3460
|
+
|
|
3461
|
+
}, {
|
|
3462
|
+
key: "addShapeToLayer",
|
|
3463
|
+
value: function addShapeToLayer(shape, layer) {
|
|
3464
|
+
this.initLayers(); // 参数验证
|
|
3465
|
+
|
|
3466
|
+
if (!shape) {
|
|
3467
|
+
console.warn('jmGraph: addShapeToLayer - 无效的形状对象');
|
|
3468
|
+
return this;
|
|
3469
|
+
} // 确定目标图层
|
|
3470
|
+
|
|
3471
|
+
|
|
3472
|
+
if (!layer) {
|
|
3473
|
+
layer = this.activeLayer;
|
|
3474
|
+
} else if (typeof layer === 'string') {
|
|
3475
|
+
layer = this.getLayer(layer);
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
if (!layer) {
|
|
3479
|
+
console.warn('jmGraph: addShapeToLayer - 图层不存在');
|
|
3480
|
+
return this;
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
layer.children.add(shape);
|
|
3484
|
+
this.needUpdate = true;
|
|
3485
|
+
return this;
|
|
3486
|
+
}
|
|
3487
|
+
/**
|
|
3488
|
+
* 从图层中移除形状
|
|
3489
|
+
*
|
|
3490
|
+
* @method removeShapeFromLayer
|
|
3491
|
+
* @param {jmControl} shape 要移除的形状对象
|
|
3492
|
+
* @return {jmGraph} 返回当前实例,支持链式调用
|
|
3493
|
+
*/
|
|
3494
|
+
|
|
3495
|
+
}, {
|
|
3496
|
+
key: "removeShapeFromLayer",
|
|
3497
|
+
value: function removeShapeFromLayer(shape) {
|
|
3498
|
+
var _this2 = this;
|
|
3499
|
+
|
|
3500
|
+
if (!shape) {
|
|
3501
|
+
console.warn('jmGraph: removeShapeFromLayer - 无效的形状对象');
|
|
3502
|
+
return this;
|
|
3503
|
+
} // 从所有图层中查找并移除
|
|
3504
|
+
|
|
3505
|
+
|
|
3506
|
+
if (this.layers) {
|
|
3507
|
+
this.layers.each(function (i, layer) {
|
|
3508
|
+
if (layer.children.contains(shape)) {
|
|
3509
|
+
layer.children.remove(shape);
|
|
3510
|
+
_this2.needUpdate = true;
|
|
3511
|
+
return false; // 找到后停止遍历
|
|
3512
|
+
}
|
|
3513
|
+
});
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
return this;
|
|
3517
|
+
}
|
|
3123
3518
|
/**
|
|
3124
3519
|
* 保存为base64图形数据
|
|
3125
3520
|
*
|
|
@@ -3133,6 +3528,145 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
3133
3528
|
var data = this.canvas.toDataURL ? this.canvas.toDataURL() : '';
|
|
3134
3529
|
return data;
|
|
3135
3530
|
}
|
|
3531
|
+
/**
|
|
3532
|
+
* 导出为PNG图片
|
|
3533
|
+
* 使用Canvas的toDataURL方法导出当前画布内容
|
|
3534
|
+
*
|
|
3535
|
+
* @method exportToPNG
|
|
3536
|
+
* @param {string} [fileName='jmgraph-export'] 文件名(不含扩展名)
|
|
3537
|
+
* @param {string} [format='image/png'] 图片格式,支持image/png和image/jpeg
|
|
3538
|
+
* @param {number} [quality=0.9] 图片质量(0-1之间,仅对JPEG格式有效)
|
|
3539
|
+
*/
|
|
3540
|
+
|
|
3541
|
+
}, {
|
|
3542
|
+
key: "exportToPNG",
|
|
3543
|
+
value: function exportToPNG() {
|
|
3544
|
+
var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'jmgraph-export';
|
|
3545
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'image/png';
|
|
3546
|
+
var quality = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.9;
|
|
3547
|
+
|
|
3548
|
+
try {
|
|
3549
|
+
// 确保画布已渲染
|
|
3550
|
+
this.redraw();
|
|
3551
|
+
var dataURL = this.canvas.toDataURL(format, quality);
|
|
3552
|
+
this.downloadFile(dataURL, fileName, 'png');
|
|
3553
|
+
} catch (error) {
|
|
3554
|
+
console.error('jmGraph: exportToPNG - 导出失败', error);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
/**
|
|
3558
|
+
* 导出为JPEG图片
|
|
3559
|
+
*
|
|
3560
|
+
* @method exportToJPEG
|
|
3561
|
+
* @param {string} [fileName='jmgraph-export'] 文件名(不含扩展名)
|
|
3562
|
+
* @param {number} [quality=0.9] 图片质量(0-1之间)
|
|
3563
|
+
*/
|
|
3564
|
+
|
|
3565
|
+
}, {
|
|
3566
|
+
key: "exportToJPEG",
|
|
3567
|
+
value: function exportToJPEG() {
|
|
3568
|
+
var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'jmgraph-export';
|
|
3569
|
+
var quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.9;
|
|
3570
|
+
this.exportToPNG(fileName, 'image/jpeg', quality);
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* 导出为SVG文件
|
|
3574
|
+
* 将当前画布内容转换为SVG格式
|
|
3575
|
+
* 注意:只有实现了toSVG方法的形状才能被导出
|
|
3576
|
+
*
|
|
3577
|
+
* @method exportToSVG
|
|
3578
|
+
* @param {string} [fileName='jmgraph-export'] 文件名(不含扩展名)
|
|
3579
|
+
*/
|
|
3580
|
+
|
|
3581
|
+
}, {
|
|
3582
|
+
key: "exportToSVG",
|
|
3583
|
+
value: function exportToSVG() {
|
|
3584
|
+
var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'jmgraph-export';
|
|
3585
|
+
|
|
3586
|
+
try {
|
|
3587
|
+
var svg = this.toSVG();
|
|
3588
|
+
var blob = new Blob([svg], {
|
|
3589
|
+
type: 'image/svg+xml;charset=utf-8'
|
|
3590
|
+
});
|
|
3591
|
+
var url = URL.createObjectURL(blob);
|
|
3592
|
+
this.downloadFile(url, fileName, 'svg'); // 释放URL对象,避免内存泄漏
|
|
3593
|
+
|
|
3594
|
+
setTimeout(function () {
|
|
3595
|
+
return URL.revokeObjectURL(url);
|
|
3596
|
+
}, 100);
|
|
3597
|
+
} catch (error) {
|
|
3598
|
+
console.error('jmGraph: exportToSVG - 导出失败', error);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
/**
|
|
3602
|
+
* 转换为SVG字符串
|
|
3603
|
+
* 遍历所有图层和形状,生成SVG标记
|
|
3604
|
+
*
|
|
3605
|
+
* @method toSVG
|
|
3606
|
+
* @return {string} SVG字符串
|
|
3607
|
+
*/
|
|
3608
|
+
|
|
3609
|
+
}, {
|
|
3610
|
+
key: "toSVG",
|
|
3611
|
+
value: function toSVG() {
|
|
3612
|
+
// SVG头部,包含命名空间和画布尺寸
|
|
3613
|
+
var svg = "<svg width=\"".concat(this.width, "\" height=\"").concat(this.height, "\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ").concat(this.width, " ").concat(this.height, "\">"); // 添加背景色(如果有)
|
|
3614
|
+
|
|
3615
|
+
if (this.style && this.style.fill) {
|
|
3616
|
+
svg += "<rect width=\"100%\" height=\"100%\" fill=\"".concat(this.style.fill, "\"/>");
|
|
3617
|
+
} // 遍历所有图层
|
|
3618
|
+
|
|
3619
|
+
|
|
3620
|
+
if (this.layers) {
|
|
3621
|
+
this.layers.each(function (i, layer) {
|
|
3622
|
+
if (layer.visible) {
|
|
3623
|
+
// 添加图层组,方便管理
|
|
3624
|
+
svg += "<g id=\"".concat(layer.name, "\" opacity=\"").concat(layer.opacity || 1, "\">"); // 遍历图层中的所有形状
|
|
3625
|
+
|
|
3626
|
+
layer.children.each(function (j, shape) {
|
|
3627
|
+
if (shape.toSVG) {
|
|
3628
|
+
svg += shape.toSVG();
|
|
3629
|
+
}
|
|
3630
|
+
});
|
|
3631
|
+
svg += '</g>';
|
|
3632
|
+
}
|
|
3633
|
+
});
|
|
3634
|
+
} else {
|
|
3635
|
+
// 遍历直接添加的形状(兼容没有图层系统的情况)
|
|
3636
|
+
this.children.each(function (i, shape) {
|
|
3637
|
+
if (shape.toSVG) {
|
|
3638
|
+
svg += shape.toSVG();
|
|
3639
|
+
}
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
svg += '</svg>';
|
|
3644
|
+
return svg;
|
|
3645
|
+
}
|
|
3646
|
+
/**
|
|
3647
|
+
* 下载文件
|
|
3648
|
+
* 创建临时链接元素触发浏览器下载
|
|
3649
|
+
*
|
|
3650
|
+
* @method downloadFile
|
|
3651
|
+
* @private
|
|
3652
|
+
* @param {string} url 文件URL或Data URL
|
|
3653
|
+
* @param {string} fileName 文件名(不含扩展名)
|
|
3654
|
+
* @param {string} extension 文件扩展名
|
|
3655
|
+
*/
|
|
3656
|
+
|
|
3657
|
+
}, {
|
|
3658
|
+
key: "downloadFile",
|
|
3659
|
+
value: function downloadFile(url, fileName, extension) {
|
|
3660
|
+
// 创建临时链接元素
|
|
3661
|
+
var link = document.createElement('a');
|
|
3662
|
+
link.href = url;
|
|
3663
|
+
link.download = "".concat(fileName, ".").concat(extension); // 添加到DOM并触发点击
|
|
3664
|
+
|
|
3665
|
+
document.body.appendChild(link);
|
|
3666
|
+
link.click(); // 清理DOM
|
|
3667
|
+
|
|
3668
|
+
document.body.removeChild(link);
|
|
3669
|
+
}
|
|
3136
3670
|
/**
|
|
3137
3671
|
* 自动刷新画版
|
|
3138
3672
|
* @param {function} callback 执行回调
|
|
@@ -3188,15 +3722,17 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
3188
3722
|
|
|
3189
3723
|
exports.jmGraph = exports["default"] = jmGraph;
|
|
3190
3724
|
|
|
3191
|
-
},{"./jmControl.js":2,"./jmEvents.js":3,"./jmGradient.js":4,"./
|
|
3725
|
+
},{"./jmControl.js":2,"./jmEvents.js":3,"./jmGradient.js":4,"./jmLayer.js":6,"./jmList.js":7,"./jmPath.js":9,"./jmProperty.js":10,"./jmShadow.js":11,"./jmUtils.js":12}],6:[function(require,module,exports){
|
|
3192
3726
|
"use strict";
|
|
3193
3727
|
|
|
3728
|
+
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); }
|
|
3729
|
+
|
|
3194
3730
|
Object.defineProperty(exports, "__esModule", {
|
|
3195
3731
|
value: true
|
|
3196
3732
|
});
|
|
3197
|
-
exports.
|
|
3733
|
+
exports.jmLayer = exports["default"] = void 0;
|
|
3198
3734
|
|
|
3199
|
-
|
|
3735
|
+
var _jmControl2 = require("./jmControl.js");
|
|
3200
3736
|
|
|
3201
3737
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3202
3738
|
|
|
@@ -3204,18 +3740,224 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
3204
3740
|
|
|
3205
3741
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
3206
3742
|
|
|
3743
|
+
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); }
|
|
3744
|
+
|
|
3745
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
3746
|
+
|
|
3207
3747
|
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); }
|
|
3208
3748
|
|
|
3749
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
3750
|
+
|
|
3209
3751
|
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); }; }
|
|
3210
3752
|
|
|
3211
3753
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
3212
3754
|
|
|
3213
3755
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
3214
3756
|
|
|
3215
|
-
function
|
|
3216
|
-
|
|
3217
|
-
function
|
|
3218
|
-
|
|
3757
|
+
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; } }
|
|
3758
|
+
|
|
3759
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
3760
|
+
|
|
3761
|
+
/**
|
|
3762
|
+
* 图层类
|
|
3763
|
+
* 用于组织和管理图形对象,支持可见性和锁定控制
|
|
3764
|
+
* 图层可以包含多个图形对象,并控制它们的显示和交互
|
|
3765
|
+
*
|
|
3766
|
+
* @class jmLayer
|
|
3767
|
+
* @extends jmControl
|
|
3768
|
+
* @param {object} params 图层参数
|
|
3769
|
+
* @param {string} [params.name] 图层名称,默认为 'Layer_${timestamp}'
|
|
3770
|
+
* @param {boolean} [params.visible=true] 图层是否可见
|
|
3771
|
+
* @param {boolean} [params.locked=false] 图层是否锁定(锁定后不可交互)
|
|
3772
|
+
* @param {jmGraph} [params.graph] 所属的画布对象
|
|
3773
|
+
*/
|
|
3774
|
+
var jmLayer = /*#__PURE__*/function (_jmControl) {
|
|
3775
|
+
_inherits(jmLayer, _jmControl);
|
|
3776
|
+
|
|
3777
|
+
var _super = _createSuper(jmLayer);
|
|
3778
|
+
|
|
3779
|
+
function jmLayer(params) {
|
|
3780
|
+
var _this;
|
|
3781
|
+
|
|
3782
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmLayer';
|
|
3783
|
+
|
|
3784
|
+
_classCallCheck(this, jmLayer);
|
|
3785
|
+
|
|
3786
|
+
params = params || {};
|
|
3787
|
+
params.interactive = false; // 图层本身不响应交互事件
|
|
3788
|
+
|
|
3789
|
+
_this = _super.call(this, params, t);
|
|
3790
|
+
_this.name = params.name || "Layer_".concat(Date.now());
|
|
3791
|
+
_this.visible = params.visible !== false;
|
|
3792
|
+
_this.locked = params.locked || false;
|
|
3793
|
+
return _this;
|
|
3794
|
+
}
|
|
3795
|
+
/**
|
|
3796
|
+
* 图层名称
|
|
3797
|
+
* 图层的唯一标识符,用于查找和管理图层
|
|
3798
|
+
*
|
|
3799
|
+
* @property name
|
|
3800
|
+
* @type {string}
|
|
3801
|
+
*/
|
|
3802
|
+
|
|
3803
|
+
|
|
3804
|
+
_createClass(jmLayer, [{
|
|
3805
|
+
key: "name",
|
|
3806
|
+
get: function get() {
|
|
3807
|
+
return this.property('name');
|
|
3808
|
+
},
|
|
3809
|
+
set: function set(v) {
|
|
3810
|
+
if (!v || typeof v !== 'string') {
|
|
3811
|
+
console.warn('jmLayer: name must be a non-empty string');
|
|
3812
|
+
return;
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
return this.property('name', v);
|
|
3816
|
+
}
|
|
3817
|
+
/**
|
|
3818
|
+
* 图层是否可见
|
|
3819
|
+
* 不可见的图层不会被渲染,但仍然存在于图层列表中
|
|
3820
|
+
*
|
|
3821
|
+
* @property visible
|
|
3822
|
+
* @type {boolean}
|
|
3823
|
+
*/
|
|
3824
|
+
|
|
3825
|
+
}, {
|
|
3826
|
+
key: "visible",
|
|
3827
|
+
get: function get() {
|
|
3828
|
+
return this.property('visible');
|
|
3829
|
+
},
|
|
3830
|
+
set: function set(v) {
|
|
3831
|
+
this.needUpdate = true;
|
|
3832
|
+
return this.property('visible', v);
|
|
3833
|
+
}
|
|
3834
|
+
/**
|
|
3835
|
+
* 图层是否锁定
|
|
3836
|
+
* 锁定的图层中的图形不可被选中或移动,但仍然可见
|
|
3837
|
+
* 适用于背景图层或参考图层
|
|
3838
|
+
*
|
|
3839
|
+
* @property locked
|
|
3840
|
+
* @type {boolean}
|
|
3841
|
+
*/
|
|
3842
|
+
|
|
3843
|
+
}, {
|
|
3844
|
+
key: "locked",
|
|
3845
|
+
get: function get() {
|
|
3846
|
+
return this.property('locked');
|
|
3847
|
+
},
|
|
3848
|
+
set: function set(v) {
|
|
3849
|
+
return this.property('locked', v);
|
|
3850
|
+
}
|
|
3851
|
+
/**
|
|
3852
|
+
* 绘制图层
|
|
3853
|
+
* 只有可见的图层才会被绘制
|
|
3854
|
+
*
|
|
3855
|
+
* @method paint
|
|
3856
|
+
* @param {boolean} v 是否需要重绘
|
|
3857
|
+
*/
|
|
3858
|
+
|
|
3859
|
+
}, {
|
|
3860
|
+
key: "paint",
|
|
3861
|
+
value: function paint(v) {
|
|
3862
|
+
if (this.visible !== false) {
|
|
3863
|
+
_get(_getPrototypeOf(jmLayer.prototype), "paint", this).call(this, v);
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
/**
|
|
3867
|
+
* 检查点是否在图层内
|
|
3868
|
+
* 锁定的图层不会响应鼠标事件
|
|
3869
|
+
*
|
|
3870
|
+
* @method checkPoint
|
|
3871
|
+
* @param {object} p 坐标点 {x, y}
|
|
3872
|
+
* @param {number} [pad] padding,额外的检测范围
|
|
3873
|
+
* @return {boolean} 是否在图层内
|
|
3874
|
+
*/
|
|
3875
|
+
|
|
3876
|
+
}, {
|
|
3877
|
+
key: "checkPoint",
|
|
3878
|
+
value: function checkPoint(p, pad) {
|
|
3879
|
+
// 锁定的图层不响应交互
|
|
3880
|
+
if (this.locked) return false;
|
|
3881
|
+
return _get(_getPrototypeOf(jmLayer.prototype), "checkPoint", this).call(this, p, pad);
|
|
3882
|
+
}
|
|
3883
|
+
/**
|
|
3884
|
+
* 清空图层
|
|
3885
|
+
* 移除图层中的所有图形对象
|
|
3886
|
+
*
|
|
3887
|
+
* @method clear
|
|
3888
|
+
*/
|
|
3889
|
+
|
|
3890
|
+
}, {
|
|
3891
|
+
key: "clear",
|
|
3892
|
+
value: function clear() {
|
|
3893
|
+
this.children.clear();
|
|
3894
|
+
this.needUpdate = true;
|
|
3895
|
+
}
|
|
3896
|
+
/**
|
|
3897
|
+
* 获取图层中的图形数量
|
|
3898
|
+
*
|
|
3899
|
+
* @method getShapeCount
|
|
3900
|
+
* @return {number} 图形数量
|
|
3901
|
+
*/
|
|
3902
|
+
|
|
3903
|
+
}, {
|
|
3904
|
+
key: "getShapeCount",
|
|
3905
|
+
value: function getShapeCount() {
|
|
3906
|
+
return this.children.length;
|
|
3907
|
+
}
|
|
3908
|
+
/**
|
|
3909
|
+
* 获取图层信息
|
|
3910
|
+
* 返回图层的基本信息,用于调试和日志
|
|
3911
|
+
*
|
|
3912
|
+
* @method getInfo
|
|
3913
|
+
* @return {object} 图层信息对象
|
|
3914
|
+
*/
|
|
3915
|
+
|
|
3916
|
+
}, {
|
|
3917
|
+
key: "getInfo",
|
|
3918
|
+
value: function getInfo() {
|
|
3919
|
+
return {
|
|
3920
|
+
name: this.name,
|
|
3921
|
+
visible: this.visible,
|
|
3922
|
+
locked: this.locked,
|
|
3923
|
+
shapeCount: this.getShapeCount()
|
|
3924
|
+
};
|
|
3925
|
+
}
|
|
3926
|
+
}]);
|
|
3927
|
+
|
|
3928
|
+
return jmLayer;
|
|
3929
|
+
}(_jmControl2.jmControl);
|
|
3930
|
+
|
|
3931
|
+
exports.jmLayer = exports["default"] = jmLayer;
|
|
3932
|
+
|
|
3933
|
+
},{"./jmControl.js":2}],7:[function(require,module,exports){
|
|
3934
|
+
"use strict";
|
|
3935
|
+
|
|
3936
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3937
|
+
value: true
|
|
3938
|
+
});
|
|
3939
|
+
exports.jmList = exports["default"] = void 0;
|
|
3940
|
+
|
|
3941
|
+
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); }
|
|
3942
|
+
|
|
3943
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3944
|
+
|
|
3945
|
+
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); } }
|
|
3946
|
+
|
|
3947
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
3948
|
+
|
|
3949
|
+
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); }
|
|
3950
|
+
|
|
3951
|
+
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); }; }
|
|
3952
|
+
|
|
3953
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
3954
|
+
|
|
3955
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
3956
|
+
|
|
3957
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
3958
|
+
|
|
3959
|
+
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); }
|
|
3960
|
+
|
|
3219
3961
|
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; } }
|
|
3220
3962
|
|
|
3221
3963
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
@@ -3352,7 +4094,7 @@ var jmList = /*#__PURE__*/function (_Array) {
|
|
|
3352
4094
|
|
|
3353
4095
|
exports.jmList = exports["default"] = jmList;
|
|
3354
4096
|
|
|
3355
|
-
},{}],
|
|
4097
|
+
},{}],8:[function(require,module,exports){
|
|
3356
4098
|
"use strict";
|
|
3357
4099
|
|
|
3358
4100
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -3467,7 +4209,7 @@ var jmObject = /*#__PURE__*/function () {
|
|
|
3467
4209
|
|
|
3468
4210
|
exports.jmObject = exports["default"] = jmObject;
|
|
3469
4211
|
|
|
3470
|
-
},{"./jmList.js":
|
|
4212
|
+
},{"./jmList.js":7}],9:[function(require,module,exports){
|
|
3471
4213
|
"use strict";
|
|
3472
4214
|
|
|
3473
4215
|
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); }
|
|
@@ -3541,6 +4283,63 @@ var jmPath = /*#__PURE__*/function (_jmControl) {
|
|
|
3541
4283
|
this.needUpdate = true;
|
|
3542
4284
|
return this.property('points', v);
|
|
3543
4285
|
}
|
|
4286
|
+
/**
|
|
4287
|
+
* 转换为SVG路径
|
|
4288
|
+
*
|
|
4289
|
+
* @method toSVG
|
|
4290
|
+
* @return {string} SVG路径字符串
|
|
4291
|
+
*/
|
|
4292
|
+
|
|
4293
|
+
}, {
|
|
4294
|
+
key: "toSVG",
|
|
4295
|
+
value: function toSVG() {
|
|
4296
|
+
if (!this.points || this.points.length === 0) return '';
|
|
4297
|
+
var pathData = '';
|
|
4298
|
+
var points = this.points; // 移动到起点
|
|
4299
|
+
|
|
4300
|
+
pathData += "M ".concat(points[0].x, " ").concat(points[0].y); // 绘制路径
|
|
4301
|
+
|
|
4302
|
+
for (var i = 1; i < points.length; i++) {
|
|
4303
|
+
var p = points[i];
|
|
4304
|
+
|
|
4305
|
+
if (p.m) {
|
|
4306
|
+
// 移动到新位置
|
|
4307
|
+
pathData += " M ".concat(p.x, " ").concat(p.y);
|
|
4308
|
+
} else {
|
|
4309
|
+
// 直线到
|
|
4310
|
+
pathData += " L ".concat(p.x, " ").concat(p.y);
|
|
4311
|
+
}
|
|
4312
|
+
} // 如果是封闭路径
|
|
4313
|
+
|
|
4314
|
+
|
|
4315
|
+
if (this.style && this.style.close) {
|
|
4316
|
+
pathData += ' Z';
|
|
4317
|
+
} // 构建SVG元素
|
|
4318
|
+
|
|
4319
|
+
|
|
4320
|
+
var svg = '<path d="' + pathData + '"'; // 添加样式
|
|
4321
|
+
|
|
4322
|
+
if (this.style) {
|
|
4323
|
+
if (this.style.fill) {
|
|
4324
|
+
svg += ' fill="' + this.style.fill + '"';
|
|
4325
|
+
}
|
|
4326
|
+
|
|
4327
|
+
if (this.style.stroke) {
|
|
4328
|
+
svg += ' stroke="' + this.style.stroke + '"';
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
if (this.style.lineWidth) {
|
|
4332
|
+
svg += ' stroke-width="' + this.style.lineWidth + '"';
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
if (this.style.opacity) {
|
|
4336
|
+
svg += ' opacity="' + this.style.opacity + '"';
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
|
|
4340
|
+
svg += '/>';
|
|
4341
|
+
return svg;
|
|
4342
|
+
}
|
|
3544
4343
|
}]);
|
|
3545
4344
|
|
|
3546
4345
|
return jmPath;
|
|
@@ -3548,7 +4347,7 @@ var jmPath = /*#__PURE__*/function (_jmControl) {
|
|
|
3548
4347
|
|
|
3549
4348
|
exports.jmPath = exports["default"] = jmPath;
|
|
3550
4349
|
|
|
3551
|
-
},{"./jmControl.js":2}],
|
|
4350
|
+
},{"./jmControl.js":2}],10:[function(require,module,exports){
|
|
3552
4351
|
"use strict";
|
|
3553
4352
|
|
|
3554
4353
|
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); }
|
|
@@ -3674,7 +4473,7 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3674
4473
|
|
|
3675
4474
|
exports.jmProperty = exports["default"] = jmProperty;
|
|
3676
4475
|
|
|
3677
|
-
},{"./jmObject.js":
|
|
4476
|
+
},{"./jmObject.js":8,"./jmUtils.js":12}],11:[function(require,module,exports){
|
|
3678
4477
|
"use strict";
|
|
3679
4478
|
|
|
3680
4479
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -3767,7 +4566,7 @@ var jmShadow = /*#__PURE__*/function () {
|
|
|
3767
4566
|
|
|
3768
4567
|
exports.jmShadow = exports["default"] = jmShadow;
|
|
3769
4568
|
|
|
3770
|
-
},{"./jmUtils.js":
|
|
4569
|
+
},{"./jmUtils.js":12}],12:[function(require,module,exports){
|
|
3771
4570
|
"use strict";
|
|
3772
4571
|
|
|
3773
4572
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -4769,7 +5568,7 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4769
5568
|
|
|
4770
5569
|
exports.jmUtils = exports["default"] = jmUtils;
|
|
4771
5570
|
|
|
4772
|
-
},{"./jmList.js":
|
|
5571
|
+
},{"./jmList.js":7}],13:[function(require,module,exports){
|
|
4773
5572
|
'use strict';
|
|
4774
5573
|
|
|
4775
5574
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -5432,7 +6231,7 @@ earcut.flatten = function (data) {
|
|
|
5432
6231
|
return result;
|
|
5433
6232
|
};
|
|
5434
6233
|
|
|
5435
|
-
},{}],
|
|
6234
|
+
},{}],14:[function(require,module,exports){
|
|
5436
6235
|
"use strict";
|
|
5437
6236
|
|
|
5438
6237
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -5836,6 +6635,9 @@ var WeblBase = /*#__PURE__*/function () {
|
|
|
5836
6635
|
}, {
|
|
5837
6636
|
key: "earCutPointsToTriangles",
|
|
5838
6637
|
value: function earCutPointsToTriangles(points) {
|
|
6638
|
+
this.earCutCache = this.earCutCache || (this.earCutCache = {});
|
|
6639
|
+
var key = JSON.stringify(points);
|
|
6640
|
+
if (this.earCutCache[key]) return this.earCutCache[key];
|
|
5839
6641
|
var ps = this.earCutPoints(points); // 切割得到3角色顶点索引,
|
|
5840
6642
|
|
|
5841
6643
|
var triangles = []; // 用顶点索引再组合成坐标数组
|
|
@@ -5847,6 +6649,7 @@ var WeblBase = /*#__PURE__*/function () {
|
|
|
5847
6649
|
triangles.push([p1, p2, p3]); // 每三个顶点构成一个三角
|
|
5848
6650
|
}
|
|
5849
6651
|
|
|
6652
|
+
this.earCutCache[key] = triangles;
|
|
5850
6653
|
return triangles;
|
|
5851
6654
|
} // 点坐标数组转为一维数组
|
|
5852
6655
|
|
|
@@ -6022,7 +6825,7 @@ var WeblBase = /*#__PURE__*/function () {
|
|
|
6022
6825
|
var _default = WeblBase;
|
|
6023
6826
|
exports["default"] = _default;
|
|
6024
6827
|
|
|
6025
|
-
},{"../earcut.js":
|
|
6828
|
+
},{"../earcut.js":13,"./core/buffer.js":15,"./core/program.js":18,"./core/texture.js":20,"./gradient.js":21}],15:[function(require,module,exports){
|
|
6026
6829
|
"use strict";
|
|
6027
6830
|
|
|
6028
6831
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6083,7 +6886,7 @@ function deleteBuffer(gl, buffer) {
|
|
|
6083
6886
|
gl.deleteBuffer(buffer.buffer || buffer);
|
|
6084
6887
|
}
|
|
6085
6888
|
|
|
6086
|
-
},{}],
|
|
6889
|
+
},{}],16:[function(require,module,exports){
|
|
6087
6890
|
"use strict";
|
|
6088
6891
|
|
|
6089
6892
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6121,7 +6924,7 @@ var mapSize = function mapSize(type) {
|
|
|
6121
6924
|
|
|
6122
6925
|
exports.mapSize = mapSize;
|
|
6123
6926
|
|
|
6124
|
-
},{}],
|
|
6927
|
+
},{}],17:[function(require,module,exports){
|
|
6125
6928
|
"use strict";
|
|
6126
6929
|
|
|
6127
6930
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6164,7 +6967,7 @@ var mapType = function mapType(gl, type) {
|
|
|
6164
6967
|
|
|
6165
6968
|
exports.mapType = mapType;
|
|
6166
6969
|
|
|
6167
|
-
},{}],
|
|
6970
|
+
},{}],18:[function(require,module,exports){
|
|
6168
6971
|
"use strict";
|
|
6169
6972
|
|
|
6170
6973
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6300,7 +7103,7 @@ function getUniformLocation(gl, program, name) {
|
|
|
6300
7103
|
return gl.getUniformLocation(program, name);
|
|
6301
7104
|
}
|
|
6302
7105
|
|
|
6303
|
-
},{"./mapSize.js":
|
|
7106
|
+
},{"./mapSize.js":16,"./mapType.js":17,"./shader.js":19}],19:[function(require,module,exports){
|
|
6304
7107
|
"use strict";
|
|
6305
7108
|
|
|
6306
7109
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6321,7 +7124,7 @@ function createShader(gl, type, src) {
|
|
|
6321
7124
|
return shader;
|
|
6322
7125
|
}
|
|
6323
7126
|
|
|
6324
|
-
},{}],
|
|
7127
|
+
},{}],20:[function(require,module,exports){
|
|
6325
7128
|
"use strict";
|
|
6326
7129
|
|
|
6327
7130
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6387,7 +7190,7 @@ function deleteTexture(gl, texture) {
|
|
|
6387
7190
|
return gl.deleteTexture(texture);
|
|
6388
7191
|
}
|
|
6389
7192
|
|
|
6390
|
-
},{}],
|
|
7193
|
+
},{}],21:[function(require,module,exports){
|
|
6391
7194
|
"use strict";
|
|
6392
7195
|
|
|
6393
7196
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -6583,7 +7386,7 @@ var WebglGradient = /*#__PURE__*/function () {
|
|
|
6583
7386
|
var _default = WebglGradient;
|
|
6584
7387
|
exports["default"] = _default;
|
|
6585
7388
|
|
|
6586
|
-
},{}],
|
|
7389
|
+
},{}],22:[function(require,module,exports){
|
|
6587
7390
|
"use strict";
|
|
6588
7391
|
|
|
6589
7392
|
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); }
|
|
@@ -7071,9 +7874,9 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
7071
7874
|
}, {
|
|
7072
7875
|
key: "getTriangles",
|
|
7073
7876
|
value: function getTriangles(points) {
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7877
|
+
this.trianglesCache = this.trianglesCache || (this.trianglesCache = {});
|
|
7878
|
+
var key = JSON.stringify(points);
|
|
7879
|
+
if (this.trianglesCache[key]) return this.trianglesCache[key];
|
|
7077
7880
|
var res = [];
|
|
7078
7881
|
var polygons = this.getPolygon(points);
|
|
7079
7882
|
|
|
@@ -7093,9 +7896,9 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
7093
7896
|
} finally {
|
|
7094
7897
|
_iterator3.f();
|
|
7095
7898
|
}
|
|
7096
|
-
}
|
|
7097
|
-
|
|
7899
|
+
}
|
|
7098
7900
|
|
|
7901
|
+
this.trianglesCache[key] = res;
|
|
7099
7902
|
return res;
|
|
7100
7903
|
} // 画线条
|
|
7101
7904
|
|
|
@@ -7211,25 +8014,33 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
7211
8014
|
key: "fillPolygons",
|
|
7212
8015
|
value: function fillPolygons(points) {
|
|
7213
8016
|
var isTexture = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
8017
|
+
|
|
8018
|
+
if (points.length > 3) {
|
|
8019
|
+
var triangles = this.needCut ? this.earCutPointsToTriangles(points) : this.getTriangles(points);
|
|
8020
|
+
|
|
8021
|
+
if (triangles.length) {
|
|
8022
|
+
var _iterator4 = _createForOfIteratorHelper(triangles),
|
|
8023
|
+
_step4;
|
|
8024
|
+
|
|
8025
|
+
try {
|
|
8026
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
8027
|
+
var triangle = _step4.value;
|
|
8028
|
+
this.fillPolygons(triangle, isTexture); // 这里就变成了规则的图形了
|
|
8029
|
+
}
|
|
8030
|
+
} catch (err) {
|
|
8031
|
+
_iterator4.e(err);
|
|
8032
|
+
} finally {
|
|
8033
|
+
_iterator4.f();
|
|
7224
8034
|
}
|
|
7225
|
-
|
|
7226
|
-
else {
|
|
7227
|
-
|
|
8035
|
+
}
|
|
8036
|
+
} else {
|
|
8037
|
+
var buffer = this.writePoints(points); // 纹理坐标
|
|
7228
8038
|
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
8039
|
+
var coordBuffer = isTexture ? this.writePoints(points, this.program.attrs.a_text_coord) : null;
|
|
8040
|
+
this.context.drawArrays(this.context.TRIANGLE_FAN, 0, points.length);
|
|
8041
|
+
this.deleteBuffer(buffer);
|
|
8042
|
+
coordBuffer && this.deleteBuffer(coordBuffer);
|
|
8043
|
+
}
|
|
7233
8044
|
} // 填充图形
|
|
7234
8045
|
|
|
7235
8046
|
}, {
|
|
@@ -7299,7 +8110,7 @@ var WebglPath = /*#__PURE__*/function (_WebglBase) {
|
|
|
7299
8110
|
var _default = WebglPath;
|
|
7300
8111
|
exports["default"] = _default;
|
|
7301
8112
|
|
|
7302
|
-
},{"./base.js":
|
|
8113
|
+
},{"./base.js":14}],23:[function(require,module,exports){
|
|
7303
8114
|
"use strict";
|
|
7304
8115
|
|
|
7305
8116
|
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); }
|
|
@@ -7506,7 +8317,7 @@ var jmArc = /*#__PURE__*/function (_jmPath) {
|
|
|
7506
8317
|
|
|
7507
8318
|
exports.jmArc = exports["default"] = jmArc;
|
|
7508
8319
|
|
|
7509
|
-
},{"../core/jmPath.js":
|
|
8320
|
+
},{"../core/jmPath.js":9}],24:[function(require,module,exports){
|
|
7510
8321
|
"use strict";
|
|
7511
8322
|
|
|
7512
8323
|
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); }
|
|
@@ -7730,7 +8541,7 @@ var jmArrow = /*#__PURE__*/function (_jmPath) {
|
|
|
7730
8541
|
|
|
7731
8542
|
exports.jmArrow = exports["default"] = jmArrow;
|
|
7732
8543
|
|
|
7733
|
-
},{"../core/jmPath.js":
|
|
8544
|
+
},{"../core/jmPath.js":9,"../core/jmUtils.js":12}],25:[function(require,module,exports){
|
|
7734
8545
|
"use strict";
|
|
7735
8546
|
|
|
7736
8547
|
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); }
|
|
@@ -7824,7 +8635,7 @@ var jmArrowLine = /*#__PURE__*/function (_jmLine) {
|
|
|
7824
8635
|
|
|
7825
8636
|
exports.jmArrowLine = exports["default"] = jmArrowLine;
|
|
7826
8637
|
|
|
7827
|
-
},{"./jmArrow.js":
|
|
8638
|
+
},{"./jmArrow.js":24,"./jmLine.js":32}],26:[function(require,module,exports){
|
|
7828
8639
|
"use strict";
|
|
7829
8640
|
|
|
7830
8641
|
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); }
|
|
@@ -7996,7 +8807,7 @@ var jmBezier = /*#__PURE__*/function (_jmPath) {
|
|
|
7996
8807
|
|
|
7997
8808
|
exports.jmBezier = exports["default"] = jmBezier;
|
|
7998
8809
|
|
|
7999
|
-
},{"../core/jmPath.js":
|
|
8810
|
+
},{"../core/jmPath.js":9}],27:[function(require,module,exports){
|
|
8000
8811
|
"use strict";
|
|
8001
8812
|
|
|
8002
8813
|
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); }
|
|
@@ -8126,7 +8937,7 @@ var jmCircle = /*#__PURE__*/function (_jmArc) {
|
|
|
8126
8937
|
|
|
8127
8938
|
exports.jmCircle = exports["default"] = jmCircle;
|
|
8128
8939
|
|
|
8129
|
-
},{"./jmArc.js":
|
|
8940
|
+
},{"./jmArc.js":23}],28:[function(require,module,exports){
|
|
8130
8941
|
"use strict";
|
|
8131
8942
|
|
|
8132
8943
|
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); }
|
|
@@ -8134,7 +8945,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
8134
8945
|
Object.defineProperty(exports, "__esModule", {
|
|
8135
8946
|
value: true
|
|
8136
8947
|
});
|
|
8137
|
-
exports.
|
|
8948
|
+
exports.jmEllipse = exports["default"] = void 0;
|
|
8138
8949
|
|
|
8139
8950
|
var _jmArc2 = require("./jmArc.js");
|
|
8140
8951
|
|
|
@@ -8144,6 +8955,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
8144
8955
|
|
|
8145
8956
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8146
8957
|
|
|
8958
|
+
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); }
|
|
8959
|
+
|
|
8960
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
8961
|
+
|
|
8147
8962
|
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); }
|
|
8148
8963
|
|
|
8149
8964
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -8158,85 +8973,231 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
8158
8973
|
|
|
8159
8974
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
8160
8975
|
|
|
8161
|
-
/**
|
|
8162
|
-
*
|
|
8163
|
-
*
|
|
8164
|
-
*
|
|
8165
|
-
*
|
|
8166
|
-
* @
|
|
8976
|
+
/**
|
|
8977
|
+
* 画椭圆
|
|
8978
|
+
* 椭圆是通过缩放圆形来实现的,支持完整的椭圆和椭圆弧
|
|
8979
|
+
* 可以指定起始角度和结束角度来绘制椭圆弧
|
|
8980
|
+
*
|
|
8981
|
+
* @class jmEllipse
|
|
8982
|
+
* @extends jmArc
|
|
8983
|
+
* @param {object} params 椭圆的参数
|
|
8984
|
+
* @param {object} [params.center={x:0,y:0}] 椭圆中心点坐标
|
|
8985
|
+
* @param {number} [params.width=100] 椭圆宽度(长轴直径)
|
|
8986
|
+
* @param {number} [params.height=60] 椭圆高度(短轴直径)
|
|
8987
|
+
* @param {number} [params.startAngle=0] 起始角度(弧度)
|
|
8988
|
+
* @param {number} [params.endAngle=Math.PI*2] 结束角度(弧度)
|
|
8989
|
+
* @param {boolean} [params.anticlockwise=false] 是否逆时针绘制
|
|
8167
8990
|
*/
|
|
8168
|
-
var
|
|
8169
|
-
_inherits(
|
|
8170
|
-
|
|
8171
|
-
var _super = _createSuper(jmHArc);
|
|
8991
|
+
var jmEllipse = /*#__PURE__*/function (_jmArc) {
|
|
8992
|
+
_inherits(jmEllipse, _jmArc);
|
|
8172
8993
|
|
|
8173
|
-
|
|
8174
|
-
var _this;
|
|
8994
|
+
var _super = _createSuper(jmEllipse);
|
|
8175
8995
|
|
|
8176
|
-
|
|
8996
|
+
function jmEllipse(params) {
|
|
8997
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmEllipse';
|
|
8177
8998
|
|
|
8178
|
-
_classCallCheck(this,
|
|
8999
|
+
_classCallCheck(this, jmEllipse);
|
|
8179
9000
|
|
|
8180
|
-
params
|
|
9001
|
+
params = params || {};
|
|
9002
|
+
params.isRegular = true; // 标记为规则图形
|
|
8181
9003
|
|
|
8182
|
-
|
|
8183
|
-
_this = _super.call(this, params, t);
|
|
8184
|
-
_this.minRadius = params.minRadius || _this.style.minRadius || 0;
|
|
8185
|
-
_this.maxRadius = params.maxRadius || _this.style.maxRadius || 0;
|
|
8186
|
-
return _this;
|
|
9004
|
+
return _super.call(this, params, t);
|
|
8187
9005
|
}
|
|
8188
|
-
/**
|
|
8189
|
-
*
|
|
8190
|
-
*
|
|
8191
|
-
*
|
|
8192
|
-
* @
|
|
8193
|
-
* @
|
|
9006
|
+
/**
|
|
9007
|
+
* 初始化图形点
|
|
9008
|
+
* 为WebGL模式生成控制点,2D模式使用draw方法直接绘制
|
|
9009
|
+
*
|
|
9010
|
+
* @method initPoints
|
|
9011
|
+
* @private
|
|
9012
|
+
* @for jmEllipse
|
|
8194
9013
|
*/
|
|
8195
9014
|
|
|
8196
9015
|
|
|
8197
|
-
_createClass(
|
|
8198
|
-
key: "minRadius",
|
|
8199
|
-
get: function get() {
|
|
8200
|
-
return this.property('minRadius');
|
|
8201
|
-
},
|
|
8202
|
-
set: function set(v) {
|
|
8203
|
-
this.needUpdate = true;
|
|
8204
|
-
return this.property('minRadius', v);
|
|
8205
|
-
}
|
|
8206
|
-
/**
|
|
8207
|
-
* 设定或获取外空心圆半径
|
|
8208
|
-
*
|
|
8209
|
-
* @property maxRadius
|
|
8210
|
-
* @for jmHArc
|
|
8211
|
-
* @type {number}
|
|
8212
|
-
*/
|
|
8213
|
-
|
|
8214
|
-
}, {
|
|
8215
|
-
key: "maxRadius",
|
|
8216
|
-
get: function get() {
|
|
8217
|
-
return this.property('maxRadius');
|
|
8218
|
-
},
|
|
8219
|
-
set: function set(v) {
|
|
8220
|
-
this.needUpdate = true;
|
|
8221
|
-
return this.property('maxRadius', v);
|
|
8222
|
-
}
|
|
8223
|
-
/**
|
|
8224
|
-
* 初始化图形点
|
|
8225
|
-
*
|
|
8226
|
-
* @method initPoints
|
|
8227
|
-
* @private
|
|
8228
|
-
*/
|
|
8229
|
-
|
|
8230
|
-
}, {
|
|
9016
|
+
_createClass(jmEllipse, [{
|
|
8231
9017
|
key: "initPoints",
|
|
8232
9018
|
value: function initPoints() {
|
|
8233
|
-
|
|
9019
|
+
// WebGL模式使用父类的点生成方法
|
|
9020
|
+
if (this.graph.mode === 'webgl') {
|
|
9021
|
+
return _get(_getPrototypeOf(jmEllipse.prototype), "initPoints", this).call(this);
|
|
9022
|
+
} // 2D模式:生成4个控制点用于边界计算
|
|
9023
|
+
// 这些点不是实际的绘制点,而是用于碰撞检测和边界计算
|
|
8234
9024
|
|
|
8235
|
-
|
|
8236
|
-
var
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
9025
|
+
|
|
9026
|
+
var location = this.getLocation();
|
|
9027
|
+
this.points = [];
|
|
9028
|
+
this.points.push({
|
|
9029
|
+
x: location.center.x - location.width / 2,
|
|
9030
|
+
y: location.center.y
|
|
9031
|
+
}); // 左
|
|
9032
|
+
|
|
9033
|
+
this.points.push({
|
|
9034
|
+
x: location.center.x,
|
|
9035
|
+
y: location.center.y - location.height / 2
|
|
9036
|
+
}); // 上
|
|
9037
|
+
|
|
9038
|
+
this.points.push({
|
|
9039
|
+
x: location.center.x + location.width / 2,
|
|
9040
|
+
y: location.center.y
|
|
9041
|
+
}); // 右
|
|
9042
|
+
|
|
9043
|
+
this.points.push({
|
|
9044
|
+
x: location.center.x,
|
|
9045
|
+
y: location.center.y + location.height / 2
|
|
9046
|
+
}); // 下
|
|
9047
|
+
}
|
|
9048
|
+
/**
|
|
9049
|
+
* 重写基类画图,此处为画一个椭圆
|
|
9050
|
+
* 使用Canvas的变换功能(平移和缩放)来绘制椭圆
|
|
9051
|
+
*
|
|
9052
|
+
* @method draw
|
|
9053
|
+
*/
|
|
9054
|
+
|
|
9055
|
+
}, {
|
|
9056
|
+
key: "draw",
|
|
9057
|
+
value: function draw() {
|
|
9058
|
+
// WebGL模式使用父类的绘制方法
|
|
9059
|
+
if (this.graph.mode === 'webgl') {
|
|
9060
|
+
return _get(_getPrototypeOf(jmEllipse.prototype), "draw", this).call(this);
|
|
9061
|
+
} // 获取边界和位置信息
|
|
9062
|
+
|
|
9063
|
+
|
|
9064
|
+
var bounds = this.parent && this.parent.absoluteBounds ? this.parent.absoluteBounds : this.absoluteBounds;
|
|
9065
|
+
var location = this.getLocation(); // 获取椭圆弧参数
|
|
9066
|
+
|
|
9067
|
+
var start = this.startAngle || 0;
|
|
9068
|
+
var end = this.endAngle || Math.PI * 2;
|
|
9069
|
+
var anticlockwise = this.anticlockwise || false; // 椭圆绘制:通过变换圆形来实现
|
|
9070
|
+
// 1. 保存当前绘图状态
|
|
9071
|
+
|
|
9072
|
+
this.context.save(); // 2. 平移到椭圆中心
|
|
9073
|
+
|
|
9074
|
+
this.context.translate(location.center.x + bounds.left, location.center.y + bounds.top); // 3. 缩放坐标系,使圆形变为椭圆
|
|
9075
|
+
// 将X轴缩放width/2,Y轴缩放height/2,这样单位圆就变成了椭圆
|
|
9076
|
+
|
|
9077
|
+
this.context.scale(location.width / 2, location.height / 2); // 4. 绘制单位圆(会被缩放成椭圆)
|
|
9078
|
+
|
|
9079
|
+
this.context.arc(0, 0, 1, start, end, anticlockwise); // 5. 恢复绘图状态
|
|
9080
|
+
|
|
9081
|
+
this.context.restore();
|
|
9082
|
+
}
|
|
9083
|
+
}]);
|
|
9084
|
+
|
|
9085
|
+
return jmEllipse;
|
|
9086
|
+
}(_jmArc2.jmArc);
|
|
9087
|
+
|
|
9088
|
+
exports.jmEllipse = exports["default"] = jmEllipse;
|
|
9089
|
+
|
|
9090
|
+
},{"./jmArc.js":23}],29:[function(require,module,exports){
|
|
9091
|
+
"use strict";
|
|
9092
|
+
|
|
9093
|
+
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); }
|
|
9094
|
+
|
|
9095
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9096
|
+
value: true
|
|
9097
|
+
});
|
|
9098
|
+
exports.jmHArc = exports["default"] = void 0;
|
|
9099
|
+
|
|
9100
|
+
var _jmArc2 = require("./jmArc.js");
|
|
9101
|
+
|
|
9102
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9103
|
+
|
|
9104
|
+
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); } }
|
|
9105
|
+
|
|
9106
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
9107
|
+
|
|
9108
|
+
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); }
|
|
9109
|
+
|
|
9110
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9111
|
+
|
|
9112
|
+
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); }; }
|
|
9113
|
+
|
|
9114
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
9115
|
+
|
|
9116
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
9117
|
+
|
|
9118
|
+
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; } }
|
|
9119
|
+
|
|
9120
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
9121
|
+
|
|
9122
|
+
/**
|
|
9123
|
+
* 画空心圆弧,继承自jmPath
|
|
9124
|
+
*
|
|
9125
|
+
* @class jmHArc
|
|
9126
|
+
* @extends jmArc
|
|
9127
|
+
* @param {object} params 空心圆参数:minRadius=中心小圆半径,maxRadius=大圆半径,start=起始角度,end=结束角度,anticlockwise=false 顺时针,true 逆时针
|
|
9128
|
+
*/
|
|
9129
|
+
var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
9130
|
+
_inherits(jmHArc, _jmArc);
|
|
9131
|
+
|
|
9132
|
+
var _super = _createSuper(jmHArc);
|
|
9133
|
+
|
|
9134
|
+
function jmHArc(params) {
|
|
9135
|
+
var _this;
|
|
9136
|
+
|
|
9137
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmHArc';
|
|
9138
|
+
|
|
9139
|
+
_classCallCheck(this, jmHArc);
|
|
9140
|
+
|
|
9141
|
+
params.isRegular = true; // 规则的
|
|
9142
|
+
|
|
9143
|
+
params.needCut = true;
|
|
9144
|
+
_this = _super.call(this, params, t);
|
|
9145
|
+
_this.minRadius = params.minRadius || _this.style.minRadius || 0;
|
|
9146
|
+
_this.maxRadius = params.maxRadius || _this.style.maxRadius || 0;
|
|
9147
|
+
return _this;
|
|
9148
|
+
}
|
|
9149
|
+
/**
|
|
9150
|
+
* 设定或获取内空心圆半径
|
|
9151
|
+
*
|
|
9152
|
+
* @property minRadius
|
|
9153
|
+
* @for jmHArc
|
|
9154
|
+
* @type {number}
|
|
9155
|
+
*/
|
|
9156
|
+
|
|
9157
|
+
|
|
9158
|
+
_createClass(jmHArc, [{
|
|
9159
|
+
key: "minRadius",
|
|
9160
|
+
get: function get() {
|
|
9161
|
+
return this.property('minRadius');
|
|
9162
|
+
},
|
|
9163
|
+
set: function set(v) {
|
|
9164
|
+
this.needUpdate = true;
|
|
9165
|
+
return this.property('minRadius', v);
|
|
9166
|
+
}
|
|
9167
|
+
/**
|
|
9168
|
+
* 设定或获取外空心圆半径
|
|
9169
|
+
*
|
|
9170
|
+
* @property maxRadius
|
|
9171
|
+
* @for jmHArc
|
|
9172
|
+
* @type {number}
|
|
9173
|
+
*/
|
|
9174
|
+
|
|
9175
|
+
}, {
|
|
9176
|
+
key: "maxRadius",
|
|
9177
|
+
get: function get() {
|
|
9178
|
+
return this.property('maxRadius');
|
|
9179
|
+
},
|
|
9180
|
+
set: function set(v) {
|
|
9181
|
+
this.needUpdate = true;
|
|
9182
|
+
return this.property('maxRadius', v);
|
|
9183
|
+
}
|
|
9184
|
+
/**
|
|
9185
|
+
* 初始化图形点
|
|
9186
|
+
*
|
|
9187
|
+
* @method initPoints
|
|
9188
|
+
* @private
|
|
9189
|
+
*/
|
|
9190
|
+
|
|
9191
|
+
}, {
|
|
9192
|
+
key: "initPoints",
|
|
9193
|
+
value: function initPoints() {
|
|
9194
|
+
var location = this.getLocation(); //如果设定了半径。则以半径为主
|
|
9195
|
+
|
|
9196
|
+
var minr = this.minRadius;
|
|
9197
|
+
var maxr = this.maxRadius;
|
|
9198
|
+
var start = this.startAngle;
|
|
9199
|
+
var end = this.endAngle;
|
|
9200
|
+
var anticlockwise = this.anticlockwise; //如果是逆时针绘制,则角度为负数,并且结束角为2Math.PI-end
|
|
8240
9201
|
|
|
8241
9202
|
if (anticlockwise) {
|
|
8242
9203
|
var p2 = Math.PI * 2;
|
|
@@ -8286,7 +9247,7 @@ var jmHArc = /*#__PURE__*/function (_jmArc) {
|
|
|
8286
9247
|
|
|
8287
9248
|
exports.jmHArc = exports["default"] = jmHArc;
|
|
8288
9249
|
|
|
8289
|
-
},{"./jmArc.js":
|
|
9250
|
+
},{"./jmArc.js":23}],30:[function(require,module,exports){
|
|
8290
9251
|
"use strict";
|
|
8291
9252
|
|
|
8292
9253
|
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); }
|
|
@@ -8588,7 +9549,7 @@ var jmImage = /*#__PURE__*/function (_jmControl) {
|
|
|
8588
9549
|
|
|
8589
9550
|
exports.jmImage = exports["default"] = jmImage;
|
|
8590
9551
|
|
|
8591
|
-
},{"../core/jmControl.js":2}],
|
|
9552
|
+
},{"../core/jmControl.js":2}],31:[function(require,module,exports){
|
|
8592
9553
|
"use strict";
|
|
8593
9554
|
|
|
8594
9555
|
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); }
|
|
@@ -8606,6 +9567,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8606
9567
|
|
|
8607
9568
|
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; }
|
|
8608
9569
|
|
|
9570
|
+
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; } } }; }
|
|
9571
|
+
|
|
9572
|
+
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); }
|
|
9573
|
+
|
|
9574
|
+
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; }
|
|
9575
|
+
|
|
8609
9576
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8610
9577
|
|
|
8611
9578
|
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); } }
|
|
@@ -8766,32 +9733,145 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
8766
9733
|
}
|
|
8767
9734
|
/**
|
|
8768
9735
|
* 测试获取文本所占大小
|
|
8769
|
-
*
|
|
9736
|
+
* 计算文本渲染所需的宽度和高度,支持自动换行
|
|
9737
|
+
*
|
|
8770
9738
|
* @method testSize
|
|
8771
|
-
* @return {object} 含文本大小的对象
|
|
9739
|
+
* @return {object} 含文本大小的对象 {width, height}
|
|
8772
9740
|
*/
|
|
8773
9741
|
|
|
8774
9742
|
}, {
|
|
8775
9743
|
key: "testSize",
|
|
8776
9744
|
value: function testSize() {
|
|
9745
|
+
// 使用缓存提高性能,避免重复计算
|
|
8777
9746
|
if (this.__size) return this.__size;
|
|
8778
|
-
|
|
8779
|
-
|
|
9747
|
+
|
|
9748
|
+
if (this.webglControl) {
|
|
9749
|
+
this.__size = this.webglControl.testSize(this.text, this.style);
|
|
9750
|
+
} else {
|
|
9751
|
+
this.context.save && this.context.save(); // 设置字体样式用于测量
|
|
8780
9752
|
|
|
8781
9753
|
this.setStyle({
|
|
8782
9754
|
font: this.style.font || this.style.fontSize + 'px ' + this.style.fontFamily
|
|
8783
|
-
});
|
|
9755
|
+
}); // 计算文本尺寸
|
|
9756
|
+
|
|
9757
|
+
if (this.style.maxWidth && this.text) {
|
|
9758
|
+
// 文本换行处理
|
|
9759
|
+
var lines = this.wrapText(this.text, this.style.maxWidth);
|
|
9760
|
+
var maxWidth = 0; // 找出最宽的一行
|
|
9761
|
+
|
|
9762
|
+
var _iterator = _createForOfIteratorHelper(lines),
|
|
9763
|
+
_step;
|
|
9764
|
+
|
|
9765
|
+
try {
|
|
9766
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9767
|
+
var line = _step.value;
|
|
9768
|
+
var width = this.context.measureText(line).width;
|
|
9769
|
+
if (width > maxWidth) maxWidth = width;
|
|
9770
|
+
} // 计算总高度(行数 × 行高)
|
|
9771
|
+
|
|
9772
|
+
} catch (err) {
|
|
9773
|
+
_iterator.e(err);
|
|
9774
|
+
} finally {
|
|
9775
|
+
_iterator.f();
|
|
9776
|
+
}
|
|
9777
|
+
|
|
9778
|
+
var lineHeight = this.style.lineHeight || this.style.fontSize * 1.2;
|
|
9779
|
+
this.__size = {
|
|
9780
|
+
width: maxWidth,
|
|
9781
|
+
height: lineHeight * lines.length
|
|
9782
|
+
};
|
|
9783
|
+
} else {
|
|
9784
|
+
// 单行文本
|
|
9785
|
+
this.__size = this.context.measureText ? this.context.measureText(this.text) : {
|
|
9786
|
+
width: 15
|
|
9787
|
+
};
|
|
9788
|
+
this.__size.height = this.style.fontSize ? this.style.fontSize : 15;
|
|
9789
|
+
}
|
|
8784
9790
|
|
|
8785
|
-
this.__size = this.context.measureText ? this.context.measureText(this.text) : {
|
|
8786
|
-
width: 15
|
|
8787
|
-
};
|
|
8788
9791
|
this.context.restore && this.context.restore();
|
|
8789
|
-
|
|
8790
|
-
|
|
9792
|
+
} // 设置默认宽高
|
|
9793
|
+
|
|
9794
|
+
|
|
8791
9795
|
if (!this.width) this.width = this.__size.width;
|
|
8792
9796
|
if (!this.height) this.height = this.__size.height;
|
|
8793
9797
|
return this.__size;
|
|
8794
9798
|
}
|
|
9799
|
+
/**
|
|
9800
|
+
* 文本换行处理
|
|
9801
|
+
* 根据最大宽度将文本分割成多行
|
|
9802
|
+
* 支持中英文混合文本,优先在空格处换行
|
|
9803
|
+
*
|
|
9804
|
+
* @method wrapText
|
|
9805
|
+
* @param {string} text 文本内容
|
|
9806
|
+
* @param {number} maxWidth 最大宽度(像素)
|
|
9807
|
+
* @return {array} 换行后的文本数组
|
|
9808
|
+
*/
|
|
9809
|
+
|
|
9810
|
+
}, {
|
|
9811
|
+
key: "wrapText",
|
|
9812
|
+
value: function wrapText(text, maxWidth) {
|
|
9813
|
+
// 参数验证
|
|
9814
|
+
if (!text || !maxWidth) return [text || '']; // 检查缓存,避免重复计算
|
|
9815
|
+
|
|
9816
|
+
var cacheKey = "".concat(text, "_").concat(maxWidth);
|
|
9817
|
+
|
|
9818
|
+
if (this.__wrapTextCache && this.__wrapTextCache.key === cacheKey) {
|
|
9819
|
+
return this.__wrapTextCache.lines;
|
|
9820
|
+
}
|
|
9821
|
+
|
|
9822
|
+
var lines = []; // 先按换行符分割
|
|
9823
|
+
|
|
9824
|
+
var paragraphs = text.split('\n');
|
|
9825
|
+
|
|
9826
|
+
var _iterator2 = _createForOfIteratorHelper(paragraphs),
|
|
9827
|
+
_step2;
|
|
9828
|
+
|
|
9829
|
+
try {
|
|
9830
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
9831
|
+
var paragraph = _step2.value;
|
|
9832
|
+
|
|
9833
|
+
// 如果段落为空,添加空行
|
|
9834
|
+
if (!paragraph) {
|
|
9835
|
+
lines.push('');
|
|
9836
|
+
continue;
|
|
9837
|
+
} // 按空格分割单词
|
|
9838
|
+
|
|
9839
|
+
|
|
9840
|
+
var words = paragraph.split(' ');
|
|
9841
|
+
var currentLine = words[0];
|
|
9842
|
+
|
|
9843
|
+
for (var i = 1; i < words.length; i++) {
|
|
9844
|
+
var word = words[i];
|
|
9845
|
+
var testLine = currentLine + ' ' + word;
|
|
9846
|
+
var metrics = this.context.measureText(testLine);
|
|
9847
|
+
var testWidth = metrics.width;
|
|
9848
|
+
|
|
9849
|
+
if (testWidth <= maxWidth) {
|
|
9850
|
+
// 当前行还能容纳这个单词
|
|
9851
|
+
currentLine = testLine;
|
|
9852
|
+
} else {
|
|
9853
|
+
// 当前行已满,保存当前行并开始新行
|
|
9854
|
+
if (currentLine) lines.push(currentLine);
|
|
9855
|
+
currentLine = word;
|
|
9856
|
+
}
|
|
9857
|
+
} // 添加最后一行
|
|
9858
|
+
|
|
9859
|
+
|
|
9860
|
+
if (currentLine) lines.push(currentLine);
|
|
9861
|
+
} // 缓存结果
|
|
9862
|
+
|
|
9863
|
+
} catch (err) {
|
|
9864
|
+
_iterator2.e(err);
|
|
9865
|
+
} finally {
|
|
9866
|
+
_iterator2.f();
|
|
9867
|
+
}
|
|
9868
|
+
|
|
9869
|
+
this.__wrapTextCache = {
|
|
9870
|
+
key: cacheKey,
|
|
9871
|
+
lines: lines
|
|
9872
|
+
};
|
|
9873
|
+
return lines;
|
|
9874
|
+
}
|
|
8795
9875
|
/**
|
|
8796
9876
|
* 根据位置偏移画字符串
|
|
8797
9877
|
*
|
|
@@ -8848,13 +9928,33 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
8848
9928
|
this.webglControl.drawText(txt, x, y, location);
|
|
8849
9929
|
} else if (this.style.fill && this.context.fillText) {
|
|
8850
9930
|
if (this.style.maxWidth) {
|
|
8851
|
-
|
|
9931
|
+
// 绘制换行文本
|
|
9932
|
+
var lines = this.wrapText(txt, this.style.maxWidth);
|
|
9933
|
+
var lineHeight = this.style.fontSize; // 调整起始Y位置以支持垂直对齐
|
|
9934
|
+
|
|
9935
|
+
var startY = y - (lines.length - 1) * lineHeight / 2;
|
|
9936
|
+
|
|
9937
|
+
for (var i = 0; i < lines.length; i++) {
|
|
9938
|
+
var lineY = startY + i * lineHeight;
|
|
9939
|
+
this.context.fillText(lines[i], x, lineY);
|
|
9940
|
+
}
|
|
8852
9941
|
} else {
|
|
8853
9942
|
this.context.fillText(txt, x, y);
|
|
8854
9943
|
}
|
|
8855
9944
|
} else if (this.context.strokeText) {
|
|
8856
9945
|
if (this.style.maxWidth) {
|
|
8857
|
-
|
|
9946
|
+
// 绘制换行文本
|
|
9947
|
+
var _lines = this.wrapText(txt, this.style.maxWidth);
|
|
9948
|
+
|
|
9949
|
+
var _lineHeight = this.style.fontSize; // 调整起始Y位置以支持垂直对齐
|
|
9950
|
+
|
|
9951
|
+
var _startY = y - (_lines.length - 1) * _lineHeight / 2;
|
|
9952
|
+
|
|
9953
|
+
for (var _i = 0; _i < _lines.length; _i++) {
|
|
9954
|
+
var _lineY = _startY + _i * _lineHeight;
|
|
9955
|
+
|
|
9956
|
+
this.context.strokeText(_lines[_i], x, _lineY);
|
|
9957
|
+
}
|
|
8858
9958
|
} else {
|
|
8859
9959
|
this.context.strokeText(txt, x, y);
|
|
8860
9960
|
}
|
|
@@ -8937,7 +10037,7 @@ var jmLabel = /*#__PURE__*/function (_jmControl) {
|
|
|
8937
10037
|
|
|
8938
10038
|
exports.jmLabel = exports["default"] = jmLabel;
|
|
8939
10039
|
|
|
8940
|
-
},{"../core/jmControl.js":2}],
|
|
10040
|
+
},{"../core/jmControl.js":2}],32:[function(require,module,exports){
|
|
8941
10041
|
"use strict";
|
|
8942
10042
|
|
|
8943
10043
|
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); }
|
|
@@ -9092,7 +10192,203 @@ var jmLine = /*#__PURE__*/function (_jmPath) {
|
|
|
9092
10192
|
|
|
9093
10193
|
exports.jmLine = exports["default"] = jmLine;
|
|
9094
10194
|
|
|
9095
|
-
},{"../core/jmPath.js":
|
|
10195
|
+
},{"../core/jmPath.js":9}],33:[function(require,module,exports){
|
|
10196
|
+
"use strict";
|
|
10197
|
+
|
|
10198
|
+
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); }
|
|
10199
|
+
|
|
10200
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10201
|
+
value: true
|
|
10202
|
+
});
|
|
10203
|
+
exports.jmPolygon = exports["default"] = void 0;
|
|
10204
|
+
|
|
10205
|
+
var _jmPath2 = require("../core/jmPath.js");
|
|
10206
|
+
|
|
10207
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10208
|
+
|
|
10209
|
+
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); } }
|
|
10210
|
+
|
|
10211
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
10212
|
+
|
|
10213
|
+
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); }
|
|
10214
|
+
|
|
10215
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10216
|
+
|
|
10217
|
+
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); }; }
|
|
10218
|
+
|
|
10219
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
10220
|
+
|
|
10221
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10222
|
+
|
|
10223
|
+
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; } }
|
|
10224
|
+
|
|
10225
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
10226
|
+
|
|
10227
|
+
/**
|
|
10228
|
+
* 画多边形
|
|
10229
|
+
* 支持规则多边形(正多边形)和自定义多边形
|
|
10230
|
+
* 规则多边形通过边数和半径自动计算顶点,自定义多边形通过顶点数组定义
|
|
10231
|
+
*
|
|
10232
|
+
* @class jmPolygon
|
|
10233
|
+
* @extends jmPath
|
|
10234
|
+
* @param {object} params 多边形的参数
|
|
10235
|
+
* @param {array} [params.points] 自定义顶点数组,如果提供则忽略sides和radius
|
|
10236
|
+
* @param {number} [params.sides=3] 多边形边数(3-100)
|
|
10237
|
+
* @param {number} [params.radius=50] 多边形半径(像素)
|
|
10238
|
+
* @param {object} [params.center={x:0,y:0}] 多边形中心点坐标
|
|
10239
|
+
*/
|
|
10240
|
+
var jmPolygon = /*#__PURE__*/function (_jmPath) {
|
|
10241
|
+
_inherits(jmPolygon, _jmPath);
|
|
10242
|
+
|
|
10243
|
+
var _super = _createSuper(jmPolygon);
|
|
10244
|
+
|
|
10245
|
+
function jmPolygon(params) {
|
|
10246
|
+
var _params$points;
|
|
10247
|
+
|
|
10248
|
+
var _this;
|
|
10249
|
+
|
|
10250
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmPolygon';
|
|
10251
|
+
|
|
10252
|
+
_classCallCheck(this, jmPolygon);
|
|
10253
|
+
|
|
10254
|
+
params = params || {};
|
|
10255
|
+
params.isRegular = true; // 标记为规则图形,便于优化渲染
|
|
10256
|
+
|
|
10257
|
+
_this = _super.call(this, params, t); // 参数验证和初始化
|
|
10258
|
+
|
|
10259
|
+
_this.sides = params.sides || ((_params$points = params.points) === null || _params$points === void 0 ? void 0 : _params$points.length) || 3;
|
|
10260
|
+
_this.radius = params.radius || 50;
|
|
10261
|
+
_this.center = params.center || {
|
|
10262
|
+
x: 0,
|
|
10263
|
+
y: 0
|
|
10264
|
+
};
|
|
10265
|
+
return _this;
|
|
10266
|
+
}
|
|
10267
|
+
/**
|
|
10268
|
+
* 设定或获取多边形边数
|
|
10269
|
+
* 边数决定了多边形的形状,最小为3(三角形)
|
|
10270
|
+
*
|
|
10271
|
+
* @property sides
|
|
10272
|
+
* @for jmPolygon
|
|
10273
|
+
* @type {number}
|
|
10274
|
+
*/
|
|
10275
|
+
|
|
10276
|
+
|
|
10277
|
+
_createClass(jmPolygon, [{
|
|
10278
|
+
key: "sides",
|
|
10279
|
+
get: function get() {
|
|
10280
|
+
return this.property('sides');
|
|
10281
|
+
},
|
|
10282
|
+
set: function set(v) {
|
|
10283
|
+
// 参数验证:边数必须在3-100之间
|
|
10284
|
+
if (typeof v !== 'number' || isNaN(v) || v < 3) {
|
|
10285
|
+
console.warn('jmPolygon: sides must be a number >= 3');
|
|
10286
|
+
v = 3;
|
|
10287
|
+
}
|
|
10288
|
+
|
|
10289
|
+
if (v > 100) {
|
|
10290
|
+
console.warn('jmPolygon: sides should not exceed 100 for performance reasons');
|
|
10291
|
+
v = 100;
|
|
10292
|
+
}
|
|
10293
|
+
|
|
10294
|
+
this.needUpdate = true;
|
|
10295
|
+
return this.property('sides', Math.floor(v)); // 确保是整数
|
|
10296
|
+
}
|
|
10297
|
+
/**
|
|
10298
|
+
* 设定或获取多边形半径
|
|
10299
|
+
* 半径是从中心点到顶点的距离
|
|
10300
|
+
*
|
|
10301
|
+
* @property radius
|
|
10302
|
+
* @for jmPolygon
|
|
10303
|
+
* @type {number}
|
|
10304
|
+
*/
|
|
10305
|
+
|
|
10306
|
+
}, {
|
|
10307
|
+
key: "radius",
|
|
10308
|
+
get: function get() {
|
|
10309
|
+
return this.property('radius');
|
|
10310
|
+
},
|
|
10311
|
+
set: function set(v) {
|
|
10312
|
+
// 参数验证:半径必须为正数
|
|
10313
|
+
if (typeof v !== 'number' || isNaN(v) || v <= 0) {
|
|
10314
|
+
console.warn('jmPolygon: radius must be a positive number');
|
|
10315
|
+
v = 1;
|
|
10316
|
+
}
|
|
10317
|
+
|
|
10318
|
+
this.needUpdate = true;
|
|
10319
|
+
return this.property('radius', v);
|
|
10320
|
+
}
|
|
10321
|
+
/**
|
|
10322
|
+
* 设定或获取多边形中心
|
|
10323
|
+
* 中心点是多边形的几何中心
|
|
10324
|
+
*
|
|
10325
|
+
* @property center
|
|
10326
|
+
* @for jmPolygon
|
|
10327
|
+
* @type {object}
|
|
10328
|
+
*/
|
|
10329
|
+
|
|
10330
|
+
}, {
|
|
10331
|
+
key: "center",
|
|
10332
|
+
get: function get() {
|
|
10333
|
+
return this.property('center');
|
|
10334
|
+
},
|
|
10335
|
+
set: function set(v) {
|
|
10336
|
+
// 参数验证:中心点必须包含x和y属性
|
|
10337
|
+
if (!v || typeof v.x !== 'number' || typeof v.y !== 'number') {
|
|
10338
|
+
console.warn('jmPolygon: center must be an object with x and y properties');
|
|
10339
|
+
v = {
|
|
10340
|
+
x: 0,
|
|
10341
|
+
y: 0
|
|
10342
|
+
};
|
|
10343
|
+
}
|
|
10344
|
+
|
|
10345
|
+
this.needUpdate = true;
|
|
10346
|
+
return this.property('center', v);
|
|
10347
|
+
}
|
|
10348
|
+
/**
|
|
10349
|
+
* 初始化图形点
|
|
10350
|
+
* 如果提供了自定义顶点,则使用自定义顶点
|
|
10351
|
+
* 否则根据边数和半径自动计算规则多边形的顶点
|
|
10352
|
+
*
|
|
10353
|
+
* @method initPoints
|
|
10354
|
+
* @private
|
|
10355
|
+
* @for jmPolygon
|
|
10356
|
+
*/
|
|
10357
|
+
|
|
10358
|
+
}, {
|
|
10359
|
+
key: "initPoints",
|
|
10360
|
+
value: function initPoints() {
|
|
10361
|
+
// 如果提供了自定义顶点,直接使用
|
|
10362
|
+
if (this.points && this.points.length > 0) {
|
|
10363
|
+
return;
|
|
10364
|
+
} // 计算规则多边形的顶点
|
|
10365
|
+
|
|
10366
|
+
|
|
10367
|
+
var points = [];
|
|
10368
|
+
var sides = this.sides;
|
|
10369
|
+
var radius = this.radius;
|
|
10370
|
+
var center = this.center; // 从顶部开始绘制(-90度),顺时针方向
|
|
10371
|
+
|
|
10372
|
+
for (var i = 0; i < sides; i++) {
|
|
10373
|
+
var angle = i / sides * Math.PI * 2 - Math.PI / 2;
|
|
10374
|
+
var x = center.x + Math.cos(angle) * radius;
|
|
10375
|
+
var y = center.y + Math.sin(angle) * radius;
|
|
10376
|
+
points.push({
|
|
10377
|
+
x: x,
|
|
10378
|
+
y: y
|
|
10379
|
+
});
|
|
10380
|
+
}
|
|
10381
|
+
|
|
10382
|
+
this.points = points;
|
|
10383
|
+
}
|
|
10384
|
+
}]);
|
|
10385
|
+
|
|
10386
|
+
return jmPolygon;
|
|
10387
|
+
}(_jmPath2.jmPath);
|
|
10388
|
+
|
|
10389
|
+
exports.jmPolygon = exports["default"] = jmPolygon;
|
|
10390
|
+
|
|
10391
|
+
},{"../core/jmPath.js":9}],34:[function(require,module,exports){
|
|
9096
10392
|
"use strict";
|
|
9097
10393
|
|
|
9098
10394
|
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); }
|
|
@@ -9212,7 +10508,7 @@ var jmPrismatic = /*#__PURE__*/function (_jmPath) {
|
|
|
9212
10508
|
|
|
9213
10509
|
exports.jmPrismatic = exports["default"] = jmPrismatic;
|
|
9214
10510
|
|
|
9215
|
-
},{"../core/jmPath.js":
|
|
10511
|
+
},{"../core/jmPath.js":9}],35:[function(require,module,exports){
|
|
9216
10512
|
"use strict";
|
|
9217
10513
|
|
|
9218
10514
|
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); }
|
|
@@ -9478,7 +10774,7 @@ var jmRect = /*#__PURE__*/function (_jmPath) {
|
|
|
9478
10774
|
|
|
9479
10775
|
exports.jmRect = exports["default"] = jmRect;
|
|
9480
10776
|
|
|
9481
|
-
},{"../core/jmPath.js":
|
|
10777
|
+
},{"../core/jmPath.js":9,"./jmArc.js":23,"./jmLine.js":32}],36:[function(require,module,exports){
|
|
9482
10778
|
"use strict";
|
|
9483
10779
|
|
|
9484
10780
|
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); }
|
|
@@ -9878,5 +11174,234 @@ var jmResize = /*#__PURE__*/function (_jmRect) {
|
|
|
9878
11174
|
|
|
9879
11175
|
exports.jmResize = exports["default"] = jmResize;
|
|
9880
11176
|
|
|
9881
|
-
},{"./jmRect.js":
|
|
11177
|
+
},{"./jmRect.js":35}],37:[function(require,module,exports){
|
|
11178
|
+
"use strict";
|
|
11179
|
+
|
|
11180
|
+
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); }
|
|
11181
|
+
|
|
11182
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11183
|
+
value: true
|
|
11184
|
+
});
|
|
11185
|
+
exports.jmStar = exports["default"] = void 0;
|
|
11186
|
+
|
|
11187
|
+
var _jmPath2 = require("../core/jmPath.js");
|
|
11188
|
+
|
|
11189
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11190
|
+
|
|
11191
|
+
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); } }
|
|
11192
|
+
|
|
11193
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
11194
|
+
|
|
11195
|
+
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); }
|
|
11196
|
+
|
|
11197
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11198
|
+
|
|
11199
|
+
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); }; }
|
|
11200
|
+
|
|
11201
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
11202
|
+
|
|
11203
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11204
|
+
|
|
11205
|
+
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; } }
|
|
11206
|
+
|
|
11207
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
11208
|
+
|
|
11209
|
+
/**
|
|
11210
|
+
* 画星形
|
|
11211
|
+
* 支持自定义顶点数和内外半径,创建各种星形图案
|
|
11212
|
+
* 星形由交替的外半径和内半径顶点组成
|
|
11213
|
+
*
|
|
11214
|
+
* @class jmStar
|
|
11215
|
+
* @extends jmPath
|
|
11216
|
+
* @param {object} params 星形的参数
|
|
11217
|
+
* @param {array} [params.points] 自定义顶点数组,如果提供则忽略其他参数
|
|
11218
|
+
* @param {number} [params.points=5] 星形顶点数(角数,3-50)
|
|
11219
|
+
* @param {number} [params.radius=50] 星形外半径(从中心到尖角的距离)
|
|
11220
|
+
* @param {number} [params.innerRadius=25] 星形内半径(从中心到凹陷处的距离)
|
|
11221
|
+
* @param {object} [params.center={x:0,y:0}] 星形中心点坐标
|
|
11222
|
+
*/
|
|
11223
|
+
var jmStar = /*#__PURE__*/function (_jmPath) {
|
|
11224
|
+
_inherits(jmStar, _jmPath);
|
|
11225
|
+
|
|
11226
|
+
var _super = _createSuper(jmStar);
|
|
11227
|
+
|
|
11228
|
+
function jmStar(params) {
|
|
11229
|
+
var _this;
|
|
11230
|
+
|
|
11231
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'jmStar';
|
|
11232
|
+
|
|
11233
|
+
_classCallCheck(this, jmStar);
|
|
11234
|
+
|
|
11235
|
+
params = params || {};
|
|
11236
|
+
params.isRegular = true; // 标记为规则图形
|
|
11237
|
+
|
|
11238
|
+
_this = _super.call(this, params, t); // 参数验证和初始化
|
|
11239
|
+
|
|
11240
|
+
_this.pointsCount = params.points || 5;
|
|
11241
|
+
_this.radius = params.radius || 50;
|
|
11242
|
+
_this.innerRadius = params.innerRadius || 25;
|
|
11243
|
+
_this.center = params.center || {
|
|
11244
|
+
x: 0,
|
|
11245
|
+
y: 0
|
|
11246
|
+
};
|
|
11247
|
+
return _this;
|
|
11248
|
+
}
|
|
11249
|
+
/**
|
|
11250
|
+
* 设定或获取星形顶点数(角数)
|
|
11251
|
+
* 顶点数决定了星形的角数,例如5表示五角星
|
|
11252
|
+
*
|
|
11253
|
+
* @property pointsCount
|
|
11254
|
+
* @for jmStar
|
|
11255
|
+
* @type {number}
|
|
11256
|
+
*/
|
|
11257
|
+
|
|
11258
|
+
|
|
11259
|
+
_createClass(jmStar, [{
|
|
11260
|
+
key: "pointsCount",
|
|
11261
|
+
get: function get() {
|
|
11262
|
+
return this.property('pointsCount');
|
|
11263
|
+
},
|
|
11264
|
+
set: function set(v) {
|
|
11265
|
+
// 参数验证:顶点数必须在3-50之间
|
|
11266
|
+
if (typeof v !== 'number' || isNaN(v) || v < 3) {
|
|
11267
|
+
console.warn('jmStar: pointsCount must be a number >= 3');
|
|
11268
|
+
v = 3;
|
|
11269
|
+
}
|
|
11270
|
+
|
|
11271
|
+
if (v > 50) {
|
|
11272
|
+
console.warn('jmStar: pointsCount should not exceed 50 for performance reasons');
|
|
11273
|
+
v = 50;
|
|
11274
|
+
}
|
|
11275
|
+
|
|
11276
|
+
this.needUpdate = true;
|
|
11277
|
+
return this.property('pointsCount', Math.floor(v)); // 确保是整数
|
|
11278
|
+
}
|
|
11279
|
+
/**
|
|
11280
|
+
* 设定或获取星形外半径
|
|
11281
|
+
* 外半径是从中心到尖角的距离
|
|
11282
|
+
*
|
|
11283
|
+
* @property radius
|
|
11284
|
+
* @for jmStar
|
|
11285
|
+
* @type {number}
|
|
11286
|
+
*/
|
|
11287
|
+
|
|
11288
|
+
}, {
|
|
11289
|
+
key: "radius",
|
|
11290
|
+
get: function get() {
|
|
11291
|
+
return this.property('radius');
|
|
11292
|
+
},
|
|
11293
|
+
set: function set(v) {
|
|
11294
|
+
// 参数验证:半径必须为正数
|
|
11295
|
+
if (typeof v !== 'number' || isNaN(v) || v <= 0) {
|
|
11296
|
+
console.warn('jmStar: radius must be a positive number');
|
|
11297
|
+
v = 1;
|
|
11298
|
+
}
|
|
11299
|
+
|
|
11300
|
+
this.needUpdate = true;
|
|
11301
|
+
return this.property('radius', v);
|
|
11302
|
+
}
|
|
11303
|
+
/**
|
|
11304
|
+
* 设定或获取星形内半径
|
|
11305
|
+
* 内半径是从中心到凹陷处的距离
|
|
11306
|
+
* 内半径应该小于外半径,否则会产生奇怪的形状
|
|
11307
|
+
*
|
|
11308
|
+
* @property innerRadius
|
|
11309
|
+
* @for jmStar
|
|
11310
|
+
* @type {number}
|
|
11311
|
+
*/
|
|
11312
|
+
|
|
11313
|
+
}, {
|
|
11314
|
+
key: "innerRadius",
|
|
11315
|
+
get: function get() {
|
|
11316
|
+
return this.property('innerRadius');
|
|
11317
|
+
},
|
|
11318
|
+
set: function set(v) {
|
|
11319
|
+
// 参数验证:内半径必须为正数
|
|
11320
|
+
if (typeof v !== 'number' || isNaN(v) || v <= 0) {
|
|
11321
|
+
console.warn('jmStar: innerRadius must be a positive number');
|
|
11322
|
+
v = 1;
|
|
11323
|
+
} // 警告:内半径不应大于外半径
|
|
11324
|
+
|
|
11325
|
+
|
|
11326
|
+
if (v >= this.radius) {
|
|
11327
|
+
console.warn('jmStar: innerRadius should be less than radius for proper star shape');
|
|
11328
|
+
}
|
|
11329
|
+
|
|
11330
|
+
this.needUpdate = true;
|
|
11331
|
+
return this.property('innerRadius', v);
|
|
11332
|
+
}
|
|
11333
|
+
/**
|
|
11334
|
+
* 设定或获取星形中心
|
|
11335
|
+
* 中心点是星形的几何中心
|
|
11336
|
+
*
|
|
11337
|
+
* @property center
|
|
11338
|
+
* @for jmStar
|
|
11339
|
+
* @type {object}
|
|
11340
|
+
*/
|
|
11341
|
+
|
|
11342
|
+
}, {
|
|
11343
|
+
key: "center",
|
|
11344
|
+
get: function get() {
|
|
11345
|
+
return this.property('center');
|
|
11346
|
+
},
|
|
11347
|
+
set: function set(v) {
|
|
11348
|
+
// 参数验证:中心点必须包含x和y属性
|
|
11349
|
+
if (!v || typeof v.x !== 'number' || typeof v.y !== 'number') {
|
|
11350
|
+
console.warn('jmStar: center must be an object with x and y properties');
|
|
11351
|
+
v = {
|
|
11352
|
+
x: 0,
|
|
11353
|
+
y: 0
|
|
11354
|
+
};
|
|
11355
|
+
}
|
|
11356
|
+
|
|
11357
|
+
this.needUpdate = true;
|
|
11358
|
+
return this.property('center', v);
|
|
11359
|
+
}
|
|
11360
|
+
/**
|
|
11361
|
+
* 初始化图形点
|
|
11362
|
+
* 计算星形的顶点坐标,交替使用外半径和内半径
|
|
11363
|
+
*
|
|
11364
|
+
* @method initPoints
|
|
11365
|
+
* @private
|
|
11366
|
+
* @for jmStar
|
|
11367
|
+
*/
|
|
11368
|
+
|
|
11369
|
+
}, {
|
|
11370
|
+
key: "initPoints",
|
|
11371
|
+
value: function initPoints() {
|
|
11372
|
+
// 如果提供了自定义顶点,直接使用
|
|
11373
|
+
if (this.points && this.points.length > 0) {
|
|
11374
|
+
return;
|
|
11375
|
+
} // 计算星形顶点
|
|
11376
|
+
|
|
11377
|
+
|
|
11378
|
+
var points = [];
|
|
11379
|
+
var pointsCount = this.pointsCount;
|
|
11380
|
+
var radius = this.radius;
|
|
11381
|
+
var innerRadius = this.innerRadius;
|
|
11382
|
+
var center = this.center; // 星形有2倍顶点数的点(外半径和内半径交替)
|
|
11383
|
+
// 从顶部开始绘制(-90度),顺时针方向
|
|
11384
|
+
|
|
11385
|
+
for (var i = 0; i < pointsCount * 2; i++) {
|
|
11386
|
+
var angle = i / pointsCount * Math.PI - Math.PI / 2; // 偶数索引使用外半径,奇数索引使用内半径
|
|
11387
|
+
|
|
11388
|
+
var r = i % 2 === 0 ? radius : innerRadius;
|
|
11389
|
+
var x = center.x + Math.cos(angle) * r;
|
|
11390
|
+
var y = center.y + Math.sin(angle) * r;
|
|
11391
|
+
points.push({
|
|
11392
|
+
x: x,
|
|
11393
|
+
y: y
|
|
11394
|
+
});
|
|
11395
|
+
}
|
|
11396
|
+
|
|
11397
|
+
this.points = points;
|
|
11398
|
+
}
|
|
11399
|
+
}]);
|
|
11400
|
+
|
|
11401
|
+
return jmStar;
|
|
11402
|
+
}(_jmPath2.jmPath);
|
|
11403
|
+
|
|
11404
|
+
exports.jmStar = exports["default"] = jmStar;
|
|
11405
|
+
|
|
11406
|
+
},{"../core/jmPath.js":9}]},{},[1]);
|
|
9882
11407
|
var _r=_m(1);_g.jmGraph=_r;return _r;})})(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:(typeof self!=='undefined'?self:this)));
|