@meta2d/core 1.0.51 → 1.0.53

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/src/pen/render.js CHANGED
@@ -418,7 +418,40 @@ function ctxDrawLinearGradientPath(ctx, pen) {
418
418
  if (i < anchors.length - 2) {
419
419
  _last = getSmoothAdjacent(smoothLenth, anchors[i + 1], anchors[i]);
420
420
  }
421
+ var flag = false;
422
+ if (i === 0) {
423
+ if (pen.fromLineCap && pen.fromLineCap !== 'butt') {
424
+ ctx.save();
425
+ flag = true;
426
+ ctx.lineCap = pen.fromLineCap;
427
+ }
428
+ }
429
+ if (i !== 0 && i === anchors.length - 2) {
430
+ if (pen.toLineCap && pen.toLineCap !== 'butt') {
431
+ ctx.save();
432
+ flag = true;
433
+ ctx.lineCap = pen.toLineCap;
434
+ }
435
+ }
421
436
  drawLinearGradientLine(ctx, pen, [_next, _last]);
437
+ if (flag) {
438
+ ctx.restore();
439
+ }
440
+ if (anchors.length === 2 && i === 0) {
441
+ ctx.save();
442
+ flag = true;
443
+ ctx.lineCap = pen.toLineCap;
444
+ var _y = 0.1;
445
+ var _x = 0.1;
446
+ if (_next.x - _last.x === 0) {
447
+ _x = 0;
448
+ }
449
+ else {
450
+ _y = (_next.y - _last.y) / (_next.x - _last.x) * 0.1;
451
+ }
452
+ drawLinearGradientLine(ctx, pen, [{ x: _last.x - _x, y: _last.y - _y }, _last]);
453
+ ctx.restore();
454
+ }
422
455
  }
423
456
  }
424
457
  }
@@ -1078,6 +1111,10 @@ export function renderPen(ctx, pen, download) {
1078
1111
  _stroke = pen.disabledColor || store.options.disabledColor || pSBC(0.4, pen.calculative.color || getGlobalColor(store));
1079
1112
  fill = pen.disabledBackground || store.options.disabledBackground || pSBC(0.4, pen.calculative.background || store.data.penBackground);
1080
1113
  }
1114
+ else if (pen.mouseDownValid && pen.calculative.mouseDown) {
1115
+ _stroke = pen.mouseDownColor || pSBC(-0.4, pen.calculative.color || getGlobalColor(store));
1116
+ fill = pen.mouseDownBackground || pSBC(-0.4, pen.calculative.background || store.data.penBackground);
1117
+ }
1081
1118
  else if (pen.calculative.hover) {
1082
1119
  _stroke = pen.hoverColor || store.options.hoverColor;
1083
1120
  fill = pen.hoverBackground || store.options.hoverBackground;
@@ -1437,6 +1474,23 @@ export function ctxDrawPath(canUsePath, ctx, pen, store, fill) {
1437
1474
  var path = canUsePath
1438
1475
  ? store.path2dMap.get(pen)
1439
1476
  : globalStore.path2dDraws[pen.name];
1477
+ var path_from = null;
1478
+ var path_to = null;
1479
+ if (pen.type === PenType.Line) {
1480
+ //线段的起始和结束线帽 分别配置
1481
+ if (pen.fromLineCap && pen.fromLineCap !== 'butt') {
1482
+ ctx.lineCap = 'butt';
1483
+ path_from = new Path2D();
1484
+ path_from.moveTo(pen.calculative.worldAnchors[0].x, pen.calculative.worldAnchors[0].y);
1485
+ path_from.lineTo(pen.calculative.worldAnchors[0].x, pen.calculative.worldAnchors[0].y);
1486
+ }
1487
+ if (pen.toLineCap && pen.toLineCap !== 'butt') {
1488
+ ctx.lineCap = 'butt';
1489
+ path_to = new Path2D();
1490
+ path_to.moveTo(pen.calculative.worldAnchors[pen.calculative.worldAnchors.length - 1].x, pen.calculative.worldAnchors[pen.calculative.worldAnchors.length - 1].y);
1491
+ path_to.lineTo(pen.calculative.worldAnchors[pen.calculative.worldAnchors.length - 1].x, pen.calculative.worldAnchors[pen.calculative.worldAnchors.length - 1].y);
1492
+ }
1493
+ }
1440
1494
  if (path) {
1441
1495
  if (pen.type === PenType.Line && pen.borderWidth) {
1442
1496
  ctx.save();
@@ -1444,6 +1498,12 @@ export function ctxDrawPath(canUsePath, ctx, pen, store, fill) {
1444
1498
  var lineWidth = pen.calculative.lineWidth + pen.calculative.borderWidth;
1445
1499
  ctx.lineWidth = lineWidth;
1446
1500
  ctx.strokeStyle = pen.borderColor;
1501
+ if (path_from) {
1502
+ ctx.save();
1503
+ ctx.lineCap = pen.fromLineCap;
1504
+ ctx.stroke(path_from);
1505
+ ctx.restore();
1506
+ }
1447
1507
  if (path instanceof Path2D) {
1448
1508
  fill && ctx.fill(path);
1449
1509
  lineWidth && ctx.stroke(path);
@@ -1453,6 +1513,12 @@ export function ctxDrawPath(canUsePath, ctx, pen, store, fill) {
1453
1513
  fill && ctx.fill();
1454
1514
  lineWidth && ctx.stroke();
1455
1515
  }
1516
+ if (path_to) {
1517
+ ctx.save();
1518
+ ctx.lineCap = pen.toLineCap;
1519
+ ctx.stroke(path_to);
1520
+ ctx.restore();
1521
+ }
1456
1522
  ctx.restore();
1457
1523
  }
1458
1524
  if (path instanceof Path2D) {
@@ -1518,7 +1584,19 @@ export function ctxDrawPath(canUsePath, ctx, pen, store, fill) {
1518
1584
  if (pen.calculative.lineWidth) {
1519
1585
  if (path instanceof Path2D) {
1520
1586
  if (store.options.svgPathStroke || pen.name !== 'svgPath') {
1587
+ if (path_from) {
1588
+ ctx.save();
1589
+ ctx.lineCap = pen.fromLineCap;
1590
+ ctx.stroke(path_from);
1591
+ ctx.restore();
1592
+ }
1521
1593
  ctx.stroke(path);
1594
+ if (path_to) {
1595
+ ctx.save();
1596
+ ctx.lineCap = pen.toLineCap;
1597
+ ctx.stroke(path_to);
1598
+ ctx.restore();
1599
+ }
1522
1600
  }
1523
1601
  }
1524
1602
  else {
@@ -1544,6 +1622,13 @@ export function ctxDrawPath(canUsePath, ctx, pen, store, fill) {
1544
1622
  }
1545
1623
  else {
1546
1624
  if (path instanceof Path2D) {
1625
+ if (path_from && !pen.lineAnimateType) {
1626
+ ctx.save();
1627
+ ctx.lineCap = pen.fromLineCap;
1628
+ ctx.stroke(path_from);
1629
+ ctx.restore();
1630
+ }
1631
+ ctx.lineCap = pen.lineCap;
1547
1632
  ctx.stroke(path);
1548
1633
  }
1549
1634
  else {
@@ -1896,6 +1981,33 @@ export function calcWorldAnchors(pen) {
1896
1981
  }
1897
1982
  pen.calculative.gradientAnimatePath = undefined;
1898
1983
  }
1984
+ export function calcChildrenInitRect(pen) {
1985
+ var _a;
1986
+ // 重新计算子节点初始化坐标
1987
+ if ((_a = pen.children) === null || _a === void 0 ? void 0 : _a.length) {
1988
+ var parentRect_1 = pen.calculative.worldRect;
1989
+ pen.children.forEach(function (id) {
1990
+ var child = pen.calculative.canvas.store.pens[id];
1991
+ if (child.calculative.initRect && child.calculative.initRelativeRect) {
1992
+ child.calculative.initRect.x =
1993
+ parentRect_1.x +
1994
+ parentRect_1.width * child.calculative.initRelativeRect.x;
1995
+ child.calculative.initRect.y =
1996
+ parentRect_1.y +
1997
+ parentRect_1.height * child.calculative.initRelativeRect.y;
1998
+ child.calculative.initRect.ex =
1999
+ child.calculative.initRect.x +
2000
+ parentRect_1.width * child.calculative.initRelativeRect.width;
2001
+ child.calculative.initRect.ey =
2002
+ child.calculative.initRect.y +
2003
+ parentRect_1.height +
2004
+ child.calculative.initRelativeRect.height;
2005
+ calcCenter(child.calculative.initRect);
2006
+ }
2007
+ calcChildrenInitRect(child);
2008
+ });
2009
+ }
2010
+ }
1899
2011
  export function calcWorldPointOfPen(pen, pt) {
1900
2012
  var p = __assign({}, pt);
1901
2013
  var _a = pen.calculative.worldRect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
@@ -1962,6 +2074,7 @@ export function scalePen(pen, scale, center) {
1962
2074
  if (pen.calculative.initRect) {
1963
2075
  scaleRect(pen.calculative.initRect, scale, center, pen.pivot);
1964
2076
  }
2077
+ scaleChildrenInitRect(pen, scale, center);
1965
2078
  if (pen.calculative.x) {
1966
2079
  scalePoint(pen.calculative, scale, center);
1967
2080
  }
@@ -1969,6 +2082,19 @@ export function scalePen(pen, scale, center) {
1969
2082
  calcWorldAnchors(pen);
1970
2083
  }
1971
2084
  }
2085
+ export function scaleChildrenInitRect(pen, scale, center) {
2086
+ var _a;
2087
+ if ((_a = pen.children) === null || _a === void 0 ? void 0 : _a.length) {
2088
+ pen.children.forEach(function (id) {
2089
+ var child = pen.calculative.canvas.store.pens[id];
2090
+ if (child &&
2091
+ child.calculative.initRect) {
2092
+ scaleRect(child.calculative.initRect, scale, center);
2093
+ }
2094
+ scaleChildrenInitRect(child, scale, center);
2095
+ });
2096
+ }
2097
+ }
1972
2098
  export function pushPenAnchor(pen, pt) {
1973
2099
  if (!pen.anchors) {
1974
2100
  pen.anchors = [];
@@ -2260,6 +2386,14 @@ export function setNodeAnimate(pen, now) {
2260
2386
  pen.calculative.x = pen.calculative.worldRect.x;
2261
2387
  pen.calculative.y = pen.calculative.worldRect.y;
2262
2388
  pen.calculative.initRect = deepClone(pen.calculative.worldRect);
2389
+ if (pen.parentId) {
2390
+ pen.calculative.initRelativeRect = {
2391
+ x: pen.x,
2392
+ y: pen.y,
2393
+ width: pen.width,
2394
+ height: pen.height,
2395
+ };
2396
+ }
2263
2397
  pen.calculative.initRect.rotate = pen.calculative.rotate || 0;
2264
2398
  initPrevFrame(pen);
2265
2399
  }
@@ -2313,8 +2447,8 @@ export function setNodeAnimate(pen, now) {
2313
2447
  // 以初始位置为参考点。因为网页在后台时,不执行动画帧,网页恢复显示时,位置不确定
2314
2448
  pen.calculative.x = pen.calculative.initRect.x;
2315
2449
  pen.calculative.y = pen.calculative.initRect.y;
2316
- if ((_c = pen.children) === null || _c === void 0 ? void 0 : _c.length) {
2317
- pen.calculative.canvas.rotatePen(pen, (pen.calculative.initRect.rotate || 0) - pen.calculative.rotate, pen.calculative.initRect);
2450
+ if (((_c = pen.children) === null || _c === void 0 ? void 0 : _c.length) && !pen.parentId) {
2451
+ pen.calculative.canvas.rotatePen(pen, (pen.calculative.initRect.rotate || 0) - (pen.calculative.rotate || 0), pen.calculative.initRect);
2318
2452
  }
2319
2453
  else {
2320
2454
  pen.calculative.rotate = pen.calculative.initRect.rotate || 0;
@@ -2801,7 +2935,7 @@ export function setGlobalAlpha(ctx, pen) {
2801
2935
  * @param pen 画笔
2802
2936
  */
2803
2937
  function ctxDrawCanvas(ctx, pen) {
2804
- var canvasDraw = globalStore.canvasDraws[pen.name];
2938
+ var canvasDraw = drawFuncGenerator(ctx, pen) || globalStore.canvasDraws[pen.name];
2805
2939
  if (canvasDraw) {
2806
2940
  // TODO: 后续考虑优化 save / restore
2807
2941
  ctx.save();
@@ -2810,6 +2944,224 @@ function ctxDrawCanvas(ctx, pen) {
2810
2944
  ctx.restore();
2811
2945
  }
2812
2946
  }
2947
+ function drawFuncGenerator(ctx, pen) {
2948
+ // 进行数据的预处理
2949
+ var drawCommand = pen.drawCommand;
2950
+ if (!drawCommand || pen.name === 'line')
2951
+ return;
2952
+ // 单位转换 将其他单位转换为px
2953
+ // 执行自定义绘画函数
2954
+ return function (ctx, pen) {
2955
+ // TODO 绘制命令的转换 (能否兼容多种指令??)
2956
+ drawCommand.forEach(function (command) {
2957
+ try {
2958
+ command.steps.reduce(function (calculate, step) {
2959
+ var cs = commandTransfer(step, pen, calculate.x, calculate.y);
2960
+ // 应当保证顺序的正确
2961
+ try {
2962
+ if (cs.c) {
2963
+ var l = [];
2964
+ for (var csKey in cs.v) {
2965
+ l.push(cs.v[csKey]);
2966
+ }
2967
+ // ctx.beginPath();
2968
+ ctx[cs.c].apply(ctx, __spreadArray([], __read(l), false));
2969
+ ctx.moveTo(cs.startX || cs.v.x, cs.startY || cs.v.y);
2970
+ // command.prop.NoFill === '0'?ctx.fill():'';
2971
+ return { x: cs.startX || cs.v.x, y: cs.startY || cs.v.y };
2972
+ }
2973
+ return { x: calculate.x, y: calculate.y };
2974
+ }
2975
+ catch (e) {
2976
+ // pass
2977
+ }
2978
+ }, {});
2979
+ }
2980
+ catch (e) {
2981
+ }
2982
+ });
2983
+ ctx.stroke();
2984
+ };
2985
+ }
2986
+ function commandTransfer(command, pen, startX, startY) {
2987
+ // TODO 是否支持扩展更多的命令?用于兼容未来的其他解析格式?
2988
+ //1. 进行简单的命令解析
2989
+ // VISIO
2990
+ var map = {
2991
+ 'visio': dealWithVisio,
2992
+ 'dxf': dealWithDXF
2993
+ };
2994
+ // CAD
2995
+ return map[pen.parseType](command, pen, startX, startY);
2996
+ }
2997
+ function dealWithDXF(command, pen, startX, startY) {
2998
+ var _a = pen.calculative.worldRect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
2999
+ switch (command.c) {
3000
+ case "moveTo":
3001
+ return {
3002
+ c: 'moveTo',
3003
+ v: {
3004
+ x: command.v.x * pen.calculative.canvas.store.data.scale,
3005
+ y: window.innerHeight - (command.v.y * pen.calculative.canvas.store.data.scale)
3006
+ }
3007
+ };
3008
+ case "lineTo":
3009
+ return {
3010
+ c: 'lineTo',
3011
+ v: {
3012
+ x: command.v.x * pen.calculative.canvas.store.data.scale,
3013
+ y: window.innerHeight - (command.v.y * pen.calculative.canvas.store.data.scale)
3014
+ }
3015
+ };
3016
+ case "arc":
3017
+ return {
3018
+ c: 'arc',
3019
+ v: {
3020
+ x: command.v.x * pen.calculative.canvas.store.data.scale,
3021
+ y: window.innerHeight - (command.v.y * pen.calculative.canvas.store.data.scale),
3022
+ r: command.v.r * pen.calculative.canvas.store.data.scale,
3023
+ startAngle: command.v.startAngle,
3024
+ endAngle: command.v.endAngle
3025
+ }
3026
+ };
3027
+ }
3028
+ return command;
3029
+ }
3030
+ function dealWithVisio(command, pen, startX, startY) {
3031
+ var _a = pen.calculative.worldRect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
3032
+ var _b = pen.origin, originWidth = _b.width, originHeight = _b.height;
3033
+ switch (command.c) {
3034
+ case "MoveTo":
3035
+ return {
3036
+ c: "moveTo",
3037
+ v: {
3038
+ x: +command.v.X * (100) * (width / originWidth) + x,
3039
+ y: +command.v.Y * (100) * (height / originHeight) + y
3040
+ }
3041
+ };
3042
+ case "RelMoveTo":
3043
+ return {
3044
+ c: "moveTo",
3045
+ v: {
3046
+ x: +command.v.X * originWidth * (width / originWidth) + x,
3047
+ y: +command.v.Y * originHeight * (height / originHeight) + y
3048
+ }
3049
+ };
3050
+ case "LineTo":
3051
+ return {
3052
+ c: "lineTo",
3053
+ v: {
3054
+ x: +command.v.X * (100) * (width / originWidth) + x,
3055
+ y: +command.v.Y * (100) * (height / originHeight) + y
3056
+ }
3057
+ };
3058
+ case "RelLineTo":
3059
+ return {
3060
+ c: "lineTo",
3061
+ v: {
3062
+ x: +command.v.X * originWidth * (width / originWidth) + x,
3063
+ y: +command.v.Y * originHeight * (height / originHeight) + y
3064
+ }
3065
+ };
3066
+ case "Ellipse":
3067
+ var centerX1 = command.v.X;
3068
+ var centerY1 = command.v.Y;
3069
+ var longAxis = Math.abs(command.v.A - command.v.C);
3070
+ var shortAxis = Math.abs(command.v.B - command.v.D);
3071
+ return {
3072
+ c: "ellipse",
3073
+ v: {
3074
+ x: centerX1 * (100) * (width / originWidth) + x,
3075
+ y: centerY1 * (100) * (height / originHeight) + y,
3076
+ radiuX: longAxis * (100) * (width / originWidth),
3077
+ radiuY: shortAxis * (100) * (height / originHeight),
3078
+ rotation: 0,
3079
+ startAngle: 0,
3080
+ endAngle: Math.PI * 2,
3081
+ anticlockwise: true
3082
+ }
3083
+ };
3084
+ case "EllipticalArcTo":
3085
+ var endX = command.v.X * 100 * (width / originWidth) + x; // 弧上结束顶点的 x 坐标
3086
+ var endY = command.v.Y * 100 * (height / originHeight) + y; // 弧上结束顶点的 y 坐标
3087
+ var ctrlX = command.v.A * 100 * (width / originWidth) + x; // 控制点的 x 坐标
3088
+ var ctrlY = command.v.B * 100 * (height / originHeight) + y; // 控制点的 y 坐标
3089
+ var angleDeg = command.v.C; // 主轴相对于 x 轴的角度 (度)
3090
+ var axisRatio = command.v.D * (width / height) * (originHeight / originWidth); // 长轴和短轴的比率
3091
+ //
3092
+ var params = calculateEllipseParameters(startX, startY, endX, endY, ctrlX, ctrlY, axisRatio);
3093
+ // 开始绘制路径
3094
+ !command.orign && (command.orign = {});
3095
+ !command.orign.startA && (command.orign.startA = calculateAngleInRadians(params.x0, params.y0, startX, startY));
3096
+ !command.orign.endA && (command.orign.endA = calculateAngleInRadians(params.x0, params.y0, endX, endY));
3097
+ return {
3098
+ c: "ellipse",
3099
+ v: {
3100
+ centerX: params.x0,
3101
+ centerY: params.y0,
3102
+ radiuX: params.a,
3103
+ radiuY: params.b,
3104
+ // rotation:radiansToDegrees(angleDeg),
3105
+ rotation: 0,
3106
+ startAngle: command.orign.startA,
3107
+ endAngle: command.orign.endA,
3108
+ // startAngle: 0,
3109
+ // endAngle: Math.PI * 2,
3110
+ // anticlockwise: startA > 0 && startA>endA
3111
+ anticlockwise: +angleDeg < 0
3112
+ // anticlockwise: Math.abs(endA - startA) < Math.PI
3113
+ },
3114
+ startX: endX,
3115
+ startY: endY,
3116
+ };
3117
+ case "ArcTo":
3118
+ var endX2 = command.v.X * 100 * width / originWidth + x;
3119
+ var endY2 = command.v.Y * 100 * height / originHeight + y;
3120
+ var h = command.v.A * 100 * (width / height) * (originHeight / originWidth);
3121
+ // 计算弦的中点
3122
+ var xm = (startX + endX2) / 2;
3123
+ var ym = (startY + endY2) / 2;
3124
+ // 计算弦的长度
3125
+ var d = Math.sqrt(Math.pow((endX2 - startX), 2) + Math.pow((endY2 - startY), 2));
3126
+ // 计算圆弧的半径
3127
+ var R = (Math.pow(d, 2)) / (8 * h) + h / 2;
3128
+ // 计算单位垂直向量
3129
+ var ux = -(endY2 - startY) / d;
3130
+ var uy = (endX2 - startX) / d;
3131
+ // 计算两个可能的圆心
3132
+ var xc1 = xm + ux * R;
3133
+ var yc1 = ym + uy * R;
3134
+ var xc2 = xm - ux * R;
3135
+ var yc2 = ym - uy * R;
3136
+ // 选择一个圆心
3137
+ var xc = xc1;
3138
+ var yc = yc1;
3139
+ // 计算起点和终点到圆心的角度
3140
+ var startAngle = Math.atan2(startY - yc, startX - xc);
3141
+ var endAngle = Math.atan2(endY2 - yc, endX2 - xc);
3142
+ return {
3143
+ c: 'arc',
3144
+ v: {
3145
+ x: xc,
3146
+ y: yc,
3147
+ radius: R,
3148
+ startAngle: startAngle,
3149
+ endAngle: endAngle,
3150
+ aclockwise: true,
3151
+ }
3152
+ };
3153
+ // case "RelCubBezTo":
3154
+ // return {
3155
+ // c:"bezierCurveTo",
3156
+ // v:{
3157
+ //
3158
+ // }
3159
+ // };
3160
+ default:
3161
+ // console.log(command.c);
3162
+ return {};
3163
+ }
3164
+ }
2813
3165
  export function setChildValue(pen, data) {
2814
3166
  for (var k in data) {
2815
3167
  if (inheritanceProps.includes(k)) {
@@ -2823,8 +3175,9 @@ export function setChildValue(pen, data) {
2823
3175
  }
2824
3176
  }
2825
3177
  }
2826
- if (pen.calculative.canvas.parent.isCombine(pen) &&
2827
- pen.showChild === undefined) {
3178
+ if (pen.calculative.canvas.parent.isCombine(pen)
3179
+ //&& pen.showChild === undefined
3180
+ ) {
2828
3181
  var children = pen.children;
2829
3182
  children === null || children === void 0 ? void 0 : children.forEach(function (childId) {
2830
3183
  var child = pen.calculative.canvas.store.pens[childId];
@@ -2832,4 +3185,31 @@ export function setChildValue(pen, data) {
2832
3185
  });
2833
3186
  }
2834
3187
  }
3188
+ function calculateEllipseParameters(x1, y1, x2, y2, x3, y3, D) {
3189
+ // Calculate x₀ using equation ⑥
3190
+ var numeratorX0 = (x1 - x2) * (x1 + x2) * (y2 - y3) - (x2 - x3) * (x2 + x3) * (y1 - y2) + D * D * (y1 - y2) * (y2 - y3) * (y1 - y3);
3191
+ var denominatorX0 = 2 * ((x1 - x2) * (y2 - y3) - (x2 - x3) * (y1 - y2));
3192
+ var x0 = numeratorX0 / denominatorX0;
3193
+ // Calculate y₀ using equation ⑦
3194
+ var numeratorY0 = (x1 - x2) * (x2 - x3) * (x1 - x3) + D * D * ((x2 - x3) * (y1 - y2) * (y1 + y2) - (x1 - x2) * (y2 - y3) * (y2 + y3));
3195
+ var denominatorY0 = 2 * D * D * ((x2 - x3) * (y1 - y2) - (x1 - x2) * (y2 - y3));
3196
+ var y0 = numeratorY0 / denominatorY0;
3197
+ // Calculate 'a' using equation ⑧, substituting x₀ and y₀
3198
+ var a = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(D * (y1 - y0), 2));
3199
+ // Calculate 'b' using equation ⑨
3200
+ var b = a / D;
3201
+ return { x0: x0, y0: y0, a: a, b: b };
3202
+ }
3203
+ function calculateAngleInRadians(x1, y1, x2, y2) {
3204
+ // 计算两个点的差值
3205
+ var dx = x2 - x1;
3206
+ var dy = y2 - y1;
3207
+ // 使用 atan2 计算角度,结果为弧度
3208
+ var angleRadians = Math.atan2(dy, dx);
3209
+ // 如果角度为负值,加上2π
3210
+ if (angleRadians < 0) {
3211
+ angleRadians += 2 * Math.PI;
3212
+ }
3213
+ return angleRadians;
3214
+ }
2835
3215
  //# sourceMappingURL=render.js.map