jmgraph 3.2.13 → 3.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +16 -4
- package/dist/jmgraph.min.js +1 -1
- package/example/controls/bezier.html +77 -1
- package/package.json +1 -1
- package/src/core/jmControl.js +4 -4
- package/src/core/jmEvents.js +12 -0
|
@@ -74,7 +74,9 @@
|
|
|
74
74
|
p3arc.canMove(true);
|
|
75
75
|
var p4arc = graph1.createShape('arc', { style: pstyle, center: p4, radius: psize, start: 0, end: Math.PI * 2, width: psize, height: psize });
|
|
76
76
|
graph1.children.add(p4arc);
|
|
77
|
-
p4arc.canMove(true);
|
|
77
|
+
p4arc.canMove(true);
|
|
78
|
+
|
|
79
|
+
drawManualArc(graph1);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
|
|
@@ -213,6 +215,80 @@
|
|
|
213
215
|
|
|
214
216
|
init2(g2);
|
|
215
217
|
|
|
218
|
+
// 手绘式圆
|
|
219
|
+
function drawManualArc(g) {
|
|
220
|
+
const baseRadius = 60; // 基础半径
|
|
221
|
+
const points = 12; // 分割成多少点,减少点数以避免毛刺
|
|
222
|
+
const variance = 20; // 半径的随机偏移量
|
|
223
|
+
const center = {
|
|
224
|
+
x: 600, y: 100
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// 生成半径偏移的函数,使用简单的正弦函数模拟平滑变化
|
|
228
|
+
function getRadius(angleIndex, totalPoints) {
|
|
229
|
+
const angle = (angleIndex / totalPoints) * Math.PI * 2;
|
|
230
|
+
// 使用正弦函数创建周期性变化
|
|
231
|
+
const noise = Math.sin(angle * 1) * (variance / 2); // 3决定波动次数,可调节
|
|
232
|
+
// 添加随机偏移
|
|
233
|
+
const randomOffset = (Math.random() - 0.5) * (variance / 2);
|
|
234
|
+
return baseRadius + noise + randomOffset;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var p = g.createShape('path', { style: {
|
|
238
|
+
stroke: 'rgb(120,20,80)',
|
|
239
|
+
lineWidth: 3,
|
|
240
|
+
close: true,
|
|
241
|
+
}, points: [] });
|
|
242
|
+
|
|
243
|
+
//一个固定的bezier曲线
|
|
244
|
+
var bezier = g.createShape('bezier', { style: style, points: [] });
|
|
245
|
+
let start = {
|
|
246
|
+
x: 0,
|
|
247
|
+
y: 0
|
|
248
|
+
};
|
|
249
|
+
for (let i = 0; i <= points; i++) {
|
|
250
|
+
const angleIndex = i % points;
|
|
251
|
+
const angle = (angleIndex / points) * Math.PI * 2;
|
|
252
|
+
const r = getRadius(angleIndex, points);
|
|
253
|
+
const x = center.x + r * Math.cos(angle);
|
|
254
|
+
const y = center.y + r * Math.sin(angle);
|
|
255
|
+
|
|
256
|
+
if (i === 0) {
|
|
257
|
+
start = {
|
|
258
|
+
x, y
|
|
259
|
+
};
|
|
260
|
+
} else {
|
|
261
|
+
// 使用二次贝塞尔曲线连接点
|
|
262
|
+
const prevIndex = (i - 1) % points;
|
|
263
|
+
const prevAngle = (prevIndex / points) * Math.PI * 2;
|
|
264
|
+
const prevR = getRadius(prevIndex, points);
|
|
265
|
+
const prevX = center.x + prevR * Math.cos(prevAngle);
|
|
266
|
+
const prevY = center.y + prevR * Math.sin(prevAngle);
|
|
267
|
+
|
|
268
|
+
// 控制点为当前点和前一个点的中点,加上偏移量
|
|
269
|
+
const cpX = (prevX + x) / 2;
|
|
270
|
+
const cpY = (prevY + y) / 2;
|
|
271
|
+
bezier.cpoints = [
|
|
272
|
+
start,{
|
|
273
|
+
x: prevX,
|
|
274
|
+
y: prevY
|
|
275
|
+
}, {
|
|
276
|
+
x: cpX,
|
|
277
|
+
y: cpY
|
|
278
|
+
}]
|
|
279
|
+
//ctx.quadraticCurveTo(prevX, prevY, cpX, cpY);
|
|
280
|
+
p.points.push(...bezier.initPoints());
|
|
281
|
+
start = {
|
|
282
|
+
x: cpX,
|
|
283
|
+
y: cpY
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//p.points.push(start);
|
|
288
|
+
console.log(p.points)
|
|
289
|
+
g.children.add(p);
|
|
290
|
+
}
|
|
291
|
+
|
|
216
292
|
//实时更新画布
|
|
217
293
|
function update() {
|
|
218
294
|
if(g1.needUpdate) g1.redraw();
|
package/package.json
CHANGED
package/src/core/jmControl.js
CHANGED
|
@@ -1423,19 +1423,19 @@ export default class jmControl extends jmProperty {
|
|
|
1423
1423
|
let thisbounds = _this.bounds || _this.getAbsoluteBounds();
|
|
1424
1424
|
//检查边界出界
|
|
1425
1425
|
let outside = jmUtils.checkOutSide(_this.option.lockSide, thisbounds, { x: offsetx, y: offsety });
|
|
1426
|
-
if(outside.left < 0) {
|
|
1426
|
+
if(outside.left < 0 && offsetx < 0) {
|
|
1427
1427
|
//offsetx -= outside.left;
|
|
1428
1428
|
offsetx = 0;
|
|
1429
1429
|
}
|
|
1430
|
-
else if(outside.right > 0) {
|
|
1430
|
+
else if(outside.right > 0 && offsetx > 0) {
|
|
1431
1431
|
//offsetx -= outside.right;
|
|
1432
1432
|
offsetx = 0;
|
|
1433
1433
|
}
|
|
1434
|
-
if(outside.top < 0) {
|
|
1434
|
+
if(outside.top < 0 && offsety < 0) {
|
|
1435
1435
|
//offsety -= outside.top;
|
|
1436
1436
|
offsety = 0;
|
|
1437
1437
|
}
|
|
1438
|
-
else if(outside.bottom > 0) {
|
|
1438
|
+
else if(outside.bottom > 0 && offsety > 0) {
|
|
1439
1439
|
//offsety -= outside.bottom;
|
|
1440
1440
|
offsety = 0;
|
|
1441
1441
|
}
|
package/src/core/jmEvents.js
CHANGED
|
@@ -60,6 +60,18 @@ export default class jmEvents {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
tap(evt) {
|
|
64
|
+
evt = evt || window.event;
|
|
65
|
+
evt.eventName = 'tap';
|
|
66
|
+
|
|
67
|
+
this.container.raiseEvent('tap',evt);
|
|
68
|
+
let t = evt.target || evt.srcElement;
|
|
69
|
+
if(t == this.target) {
|
|
70
|
+
//if(evt.preventDefault) evt.preventDefault();
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
63
75
|
// 销毁
|
|
64
76
|
destroy() {
|
|
65
77
|
this.mouseHandler.destroy();
|