@plait/draw 0.75.0-next.7 → 0.75.0-next.8

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.
@@ -1,5 +1,5 @@
1
- import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, distanceBetweenPointAndPoint, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, createDebugGenerator, Point, arrowPoints, createPath, rotate, findElements, createMask, createRect, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, setPathStrokeLinecap, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
- import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, getStrokeLineDash, StrokeStyle, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, ActiveGenerator, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, canResize, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
1
+ import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, catmullRomFitting, PlaitBoard, createG, drawLinearPath, setStrokeLinecap, setPathStrokeLinecap, getNearestPointBetweenPointAndArc, distanceBetweenPointAndPoint, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, createDebugGenerator, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, Point, arrowPoints, createPath, rotate, findElements, createMask, createRect, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getRectangleByElements, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, isPointInEllipse, getNearestPointBetweenPointAndEllipse, getEllipseTangentSlope, getVectorFromPointAndSlope, drawRoundRectangle, isPointInRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, Path, RgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, temporaryDisableSelection, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
2
+ import { DEFAULT_FILL, Alignment, WithTextPluginKey, TextManage, getMemorizedLatest, memorizeLatest, getPointOnPolyline, buildText, Generator, getStrokeLineDash, StrokeStyle, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, getPointByVectorComponent, RESIZE_HANDLE_DIAMETER, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, ActiveGenerator, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, ROTATE_HANDLE_SIZE, isCornerHandle, getIndexByResizeHandle, withResize, drawHandle, getSymmetricHandleIndex, getResizeHandlePointByIndex, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, canResize, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
3
3
  import { pointsOnBezierCurves } from 'points-on-curve';
4
4
  import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
5
5
  import { Editor, Node } from 'slate';
@@ -1034,6 +1034,177 @@ const drawVectorLine = (board, element) => {
1034
1034
  return lineG;
1035
1035
  };
1036
1036
 
1037
+ const getCenterPointsOnPolygon$1 = (points) => {
1038
+ const centerPoints = [];
1039
+ for (let i = 0; i < points.length; i++) {
1040
+ let j = i == points.length - 1 ? 0 : i + 1;
1041
+ centerPoints.push([(points[i][0] + points[j][0]) / 2, (points[i][1] + points[j][1]) / 2]);
1042
+ }
1043
+ return centerPoints;
1044
+ };
1045
+ const getCrossingPointBetweenPointAndPolygon = (corners, point) => {
1046
+ const result = [];
1047
+ for (let index = 1; index <= corners.length; index++) {
1048
+ let start = corners[index - 1];
1049
+ let end = index === corners.length ? corners[0] : corners[index];
1050
+ const crossingPoint = getCrossingPointsBetweenPointAndSegment(point, start, end);
1051
+ result.push(...crossingPoint);
1052
+ }
1053
+ return result;
1054
+ };
1055
+ const getPolygonEdgeByConnectionPoint = (corners, point) => {
1056
+ for (let index = 1; index <= corners.length; index++) {
1057
+ let start = corners[index - 1];
1058
+ let end = index === corners.length ? corners[0] : corners[index];
1059
+ if (isPointOnSegment(point, start, end)) {
1060
+ return [start, end];
1061
+ }
1062
+ }
1063
+ return null;
1064
+ };
1065
+
1066
+ function generateCloudPath(rectangle) {
1067
+ const divisionWidth = rectangle.width / 7;
1068
+ const divisionHeight = rectangle.height / 3.2;
1069
+ const xRadius = divisionWidth / 8.5;
1070
+ const yRadius = divisionHeight / 20;
1071
+ const startPoint = [rectangle.x + divisionWidth, rectangle.y + divisionHeight];
1072
+ const arcs = [
1073
+ {
1074
+ rx: xRadius,
1075
+ ry: yRadius * 1.2,
1076
+ xAxisRotation: 0,
1077
+ largeArcFlag: 1,
1078
+ sweepFlag: 1,
1079
+ endX: rectangle.x + divisionWidth * 2,
1080
+ endY: rectangle.y + divisionHeight / 2
1081
+ },
1082
+ {
1083
+ rx: xRadius,
1084
+ ry: yRadius,
1085
+ xAxisRotation: 0,
1086
+ largeArcFlag: 1,
1087
+ sweepFlag: 1,
1088
+ endX: rectangle.x + divisionWidth * 4.2,
1089
+ endY: rectangle.y + divisionHeight / 2.2
1090
+ },
1091
+ {
1092
+ rx: xRadius,
1093
+ ry: yRadius,
1094
+ xAxisRotation: 0,
1095
+ largeArcFlag: 1,
1096
+ sweepFlag: 1,
1097
+ endX: rectangle.x + divisionWidth * 5.8,
1098
+ endY: rectangle.y + divisionHeight
1099
+ },
1100
+ {
1101
+ rx: xRadius,
1102
+ ry: yRadius * 1.3,
1103
+ xAxisRotation: 0,
1104
+ largeArcFlag: 1,
1105
+ sweepFlag: 1,
1106
+ endX: rectangle.x + divisionWidth * 6,
1107
+ endY: rectangle.y + divisionHeight * 2.2
1108
+ },
1109
+ {
1110
+ rx: xRadius,
1111
+ ry: yRadius * 1.2,
1112
+ xAxisRotation: 0,
1113
+ largeArcFlag: 1,
1114
+ sweepFlag: 1,
1115
+ endX: rectangle.x + divisionWidth * 5,
1116
+ endY: rectangle.y + divisionHeight * 2.8
1117
+ },
1118
+ {
1119
+ rx: xRadius,
1120
+ ry: yRadius / 1.2,
1121
+ xAxisRotation: 0,
1122
+ largeArcFlag: 1,
1123
+ sweepFlag: 1,
1124
+ endX: rectangle.x + divisionWidth * 2.8,
1125
+ endY: rectangle.y + divisionHeight * 2.8
1126
+ },
1127
+ {
1128
+ rx: xRadius,
1129
+ ry: yRadius,
1130
+ xAxisRotation: 0,
1131
+ largeArcFlag: 1,
1132
+ sweepFlag: 1,
1133
+ endX: rectangle.x + divisionWidth,
1134
+ endY: rectangle.y + divisionHeight * 2.2
1135
+ },
1136
+ {
1137
+ rx: xRadius,
1138
+ ry: yRadius * 1.42,
1139
+ xAxisRotation: 0,
1140
+ largeArcFlag: 1,
1141
+ sweepFlag: 1,
1142
+ endX: rectangle.x + divisionWidth,
1143
+ endY: rectangle.y + divisionHeight
1144
+ }
1145
+ ];
1146
+ return { startPoint, arcs };
1147
+ }
1148
+ const CloudEngine = {
1149
+ draw(board, rectangle, options) {
1150
+ const rs = PlaitBoard.getRoughSVG(board);
1151
+ const { startPoint, arcs } = generateCloudPath(rectangle);
1152
+ const pathData = `M ${startPoint[0]} ${startPoint[1]} ` +
1153
+ arcs
1154
+ .map((arc) => `A ${arc.rx} ${arc.ry} ${arc.xAxisRotation} ${arc.largeArcFlag} ${arc.sweepFlag} ${arc.endX} ${arc.endY}`)
1155
+ .join('\n') +
1156
+ ' Z';
1157
+ const svgElement = rs.path(pathData, { ...options, fillStyle: 'solid' });
1158
+ setPathStrokeLinecap(svgElement, 'round');
1159
+ return svgElement;
1160
+ },
1161
+ isInsidePoint(rectangle, point) {
1162
+ const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
1163
+ return RectangleClient.isHit(rectangle, rangeRectangle);
1164
+ },
1165
+ getCornerPoints(rectangle) {
1166
+ return RectangleClient.getCornerPoints(rectangle);
1167
+ },
1168
+ getNearestPoint(rectangle, point) {
1169
+ const { startPoint, arcs } = generateCloudPath(rectangle);
1170
+ let minDistance = Infinity;
1171
+ let nearestPoint = point;
1172
+ // 检查每个弧段
1173
+ let currentStart = startPoint;
1174
+ for (const arc of arcs) {
1175
+ const arcNearestPoint = getNearestPointBetweenPointAndArc(point, currentStart, arc);
1176
+ const distance = distanceBetweenPointAndPoint(point[0], point[1], arcNearestPoint[0], arcNearestPoint[1]);
1177
+ if (distance < minDistance) {
1178
+ minDistance = distance;
1179
+ nearestPoint = arcNearestPoint;
1180
+ }
1181
+ currentStart = [arc.endX, arc.endY];
1182
+ }
1183
+ return nearestPoint;
1184
+ },
1185
+ getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
1186
+ const corners = CloudEngine.getCornerPoints(rectangle);
1187
+ const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
1188
+ return getPolygonEdgeByConnectionPoint(corners, point);
1189
+ },
1190
+ getConnectorPoints(rectangle) {
1191
+ return RectangleClient.getEdgeCenterPoints(rectangle);
1192
+ },
1193
+ getTextRectangle(element) {
1194
+ const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
1195
+ const strokeWidth = getStrokeWidthByElement(element);
1196
+ const height = element.textHeight;
1197
+ const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
1198
+ const width = originWidth / 1.5;
1199
+ return {
1200
+ height,
1201
+ width: width > 0 ? width : 0,
1202
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
1203
+ y: elementRectangle.y + elementRectangle.height / 6 + ((elementRectangle.height * 4) / 6 - height) / 2
1204
+ };
1205
+ }
1206
+ };
1207
+
1037
1208
  const isTextExceedingBounds = (geometry) => {
1038
1209
  const client = RectangleClient.getRectangleByPoints(geometry.points);
1039
1210
  if (geometry.textHeight && geometry.textHeight > client.height) {
@@ -1169,10 +1340,35 @@ const getFirstTextOrLineElement = (elements) => {
1169
1340
  }
1170
1341
  return null;
1171
1342
  };
1343
+ const debugKey$4 = 'debug:plait:hit:shape:edge:sample-points';
1344
+ const debugGenerator$4 = createDebugGenerator(debugKey$4);
1345
+ const shapes = [BasicShapes.cloud];
1172
1346
  const isHitDrawElement = (board, element, point, isStrict = true) => {
1173
1347
  const rectangle = board.getRectangle(element);
1174
1348
  point = rotateAntiPointsByElement(point, element) || point;
1175
- if (PlaitDrawElement.isGeometry(element)) {
1349
+ if (PlaitDrawElement.isGeometry(element) && rectangle) {
1350
+ if (debugGenerator$4.isDebug() && shapes.includes(element.shape)) {
1351
+ debugGenerator$4.clear();
1352
+ const { startPoint, arcs } = generateCloudPath(rectangle);
1353
+ const points = [startPoint, ...arcs.map((arc) => [arc.endX, arc.endY])];
1354
+ debugGenerator$4.drawCircles(board, points, 5, false);
1355
+ let minDistance = Infinity;
1356
+ let nearestPoint = point;
1357
+ let currentStart = startPoint;
1358
+ for (const arc of arcs) {
1359
+ const arcNearestPoint = getNearestPointBetweenPointAndArc(point, currentStart, arc);
1360
+ const distance = distanceBetweenPointAndPoint(point[0], point[1], arcNearestPoint[0], arcNearestPoint[1]);
1361
+ const { center } = getEllipseArcCenter(currentStart, arc);
1362
+ debugGenerator$4.drawCircles(board, [center], 8, false, { fill: 'yellow' });
1363
+ if (distance < minDistance) {
1364
+ minDistance = distance;
1365
+ nearestPoint = arcNearestPoint;
1366
+ }
1367
+ currentStart = [arc.endX, arc.endY];
1368
+ }
1369
+ debugGenerator$4.drawCircles(board, [point], 12, false, { fill: 'black', stroke: 'black' });
1370
+ debugGenerator$4.drawCircles(board, [nearestPoint], 12, false, { fill: 'green', stroke: 'green' });
1371
+ }
1176
1372
  if (isHitEdgeOfShape(board, element, point, HIT_DISTANCE_BUFFER)) {
1177
1373
  return true;
1178
1374
  }
@@ -2182,7 +2378,7 @@ const getNearestPoint = (element, point) => {
2182
2378
  const shape = getElementShape(element);
2183
2379
  return getEngine(shape).getNearestPoint(rectangle, point);
2184
2380
  };
2185
- const getCenterPointsOnPolygon$1 = (points) => {
2381
+ const getCenterPointsOnPolygon = (points) => {
2186
2382
  const centerPoint = [];
2187
2383
  for (let i = 0; i < points.length; i++) {
2188
2384
  let j = i == points.length - 1 ? 0 : i + 1;
@@ -3147,7 +3343,7 @@ function withDrawResize(board) {
3147
3343
  const canResize = () => {
3148
3344
  const elements = getSelectedElements(board);
3149
3345
  return (elements.length >= 1 &&
3150
- elements.every(el => (PlaitDrawElement.isDrawElement(el) || PlaitDrawElement.isCustomGeometryElement(board, el)) &&
3346
+ elements.every((el) => (PlaitDrawElement.isDrawElement(el) || (PlaitDrawElement.isCustomGeometryElement(board, el) && el.points.length > 1)) &&
3151
3347
  !isSingleSelectLine(board) &&
3152
3348
  !isSingleSelectSwimlane(board)));
3153
3349
  };
@@ -3200,7 +3396,7 @@ function withDrawResize(board) {
3200
3396
  PlaitBoard.getElementActiveHost(board).append(snapG);
3201
3397
  if (bulkRotationRef) {
3202
3398
  const boundingBoxCornerPoints = RectangleClient.getPoints(resizeRef.rectangle);
3203
- const resizedBoundingBoxCornerPoints = boundingBoxCornerPoints.map(p => {
3399
+ const resizedBoundingBoxCornerPoints = boundingBoxCornerPoints.map((p) => {
3204
3400
  return movePointByZoomAndOriginPoint(p, originPoint, resizeSnapRef.xZoom, resizeSnapRef.yZoom);
3205
3401
  });
3206
3402
  const newBoundingBox = RectangleClient.getRectangleByPoints(resizedBoundingBoxCornerPoints);
@@ -3215,7 +3411,7 @@ function withDrawResize(board) {
3215
3411
  });
3216
3412
  debugGenerator$2.isDebug() && debugGenerator$2.drawRectangle(board, adjustedNewBoundingBoxPoints);
3217
3413
  }
3218
- resizeRef.element.forEach(target => {
3414
+ resizeRef.element.forEach((target) => {
3219
3415
  const path = PlaitBoard.findPath(board, target);
3220
3416
  let points;
3221
3417
  if (bulkRotationRef) {
@@ -3223,7 +3419,7 @@ function withDrawResize(board) {
3223
3419
  points = reversedPoints.map((p) => {
3224
3420
  return movePointByZoomAndOriginPoint(p, originPoint, resizeSnapRef.xZoom, resizeSnapRef.yZoom);
3225
3421
  });
3226
- const adjustTargetPoints = points.map(p => [
3422
+ const adjustTargetPoints = points.map((p) => [
3227
3423
  p[0] + bulkRotationRef.offsetX,
3228
3424
  p[1] + bulkRotationRef.offsetY
3229
3425
  ]);
@@ -3237,7 +3433,7 @@ function withDrawResize(board) {
3237
3433
  points = getResizePointsByOtherwiseAxis(board, target.points, originPoint, resizeSnapRef.xZoom, resizeSnapRef.yZoom);
3238
3434
  }
3239
3435
  else {
3240
- points = target.points.map(p => {
3436
+ points = target.points.map((p) => {
3241
3437
  return movePointByZoomAndOriginPoint(p, originPoint, resizeSnapRef.xZoom, resizeSnapRef.yZoom);
3242
3438
  });
3243
3439
  }
@@ -3302,7 +3498,7 @@ function withDrawResize(board) {
3302
3498
  const centerPoint = RectangleClient.getCenterPoint(boundingRectangle);
3303
3499
  corners = rotatePoints(corners, centerPoint, angle);
3304
3500
  }
3305
- corners.forEach(corner => {
3501
+ corners.forEach((corner) => {
3306
3502
  const g = drawHandle(board, corner);
3307
3503
  handleG && handleG.append(g);
3308
3504
  });
@@ -3383,7 +3579,7 @@ const getResizePointsByOtherwiseAxis = (board, points, resizeOriginPoint, xZoom,
3383
3579
  let resultPoints = points;
3384
3580
  resultPoints = rotatePoints(resultPoints, RectangleClient.getCenterPoint(currentRectangle), (1 / 2) * Math.PI);
3385
3581
  debugGenerator$2.isDebug() && debugGenerator$2.drawRectangle(board, resultPoints, { stroke: 'blue' });
3386
- resultPoints = resultPoints.map(p => {
3582
+ resultPoints = resultPoints.map((p) => {
3387
3583
  return movePointByZoomAndOriginPoint(p, resizeOriginPoint, xZoom, yZoom);
3388
3584
  });
3389
3585
  debugGenerator$2.isDebug() && debugGenerator$2.drawRectangle(board, resultPoints);
@@ -3683,35 +3879,6 @@ const insertClipboardData = (board, elements, startPoint) => {
3683
3879
  });
3684
3880
  };
3685
3881
 
3686
- const getCenterPointsOnPolygon = (points) => {
3687
- const centerPoints = [];
3688
- for (let i = 0; i < points.length; i++) {
3689
- let j = i == points.length - 1 ? 0 : i + 1;
3690
- centerPoints.push([(points[i][0] + points[j][0]) / 2, (points[i][1] + points[j][1]) / 2]);
3691
- }
3692
- return centerPoints;
3693
- };
3694
- const getCrossingPointBetweenPointAndPolygon = (corners, point) => {
3695
- const result = [];
3696
- for (let index = 1; index <= corners.length; index++) {
3697
- let start = corners[index - 1];
3698
- let end = index === corners.length ? corners[0] : corners[index];
3699
- const crossingPoint = getCrossingPointsBetweenPointAndSegment(point, start, end);
3700
- result.push(...crossingPoint);
3701
- }
3702
- return result;
3703
- };
3704
- const getPolygonEdgeByConnectionPoint = (corners, point) => {
3705
- for (let index = 1; index <= corners.length; index++) {
3706
- let start = corners[index - 1];
3707
- let end = index === corners.length ? corners[0] : corners[index];
3708
- if (isPointOnSegment(point, start, end)) {
3709
- return [start, end];
3710
- }
3711
- }
3712
- return null;
3713
- };
3714
-
3715
3882
  const heightRatio$1 = 3 / 4;
3716
3883
  const CommentEngine = {
3717
3884
  draw(board, rectangle, options) {
@@ -4002,7 +4169,7 @@ const ParallelogramEngine = createPolygonEngine({
4002
4169
  getPolygonPoints: getParallelogramPoints,
4003
4170
  getConnectorPoints: (rectangle) => {
4004
4171
  const cornerPoints = getParallelogramPoints(rectangle);
4005
- return getCenterPointsOnPolygon(cornerPoints);
4172
+ return getCenterPointsOnPolygon$1(cornerPoints);
4006
4173
  },
4007
4174
  getTextRectangle(element) {
4008
4175
  const rectangle = getTextRectangle(element);
@@ -4280,7 +4447,7 @@ const TrapezoidEngine = createPolygonEngine({
4280
4447
  getPolygonPoints: getTrapezoidPoints,
4281
4448
  getConnectorPoints(rectangle) {
4282
4449
  const points = getTrapezoidPoints(rectangle);
4283
- return getCenterPointsOnPolygon(points);
4450
+ return getCenterPointsOnPolygon$1(points);
4284
4451
  },
4285
4452
  getTextRectangle(element) {
4286
4453
  const rectangle = getTextRectangle(element);
@@ -4302,7 +4469,7 @@ const TriangleEngine = createPolygonEngine({
4302
4469
  getPolygonPoints: getTrianglePoints,
4303
4470
  getConnectorPoints(rectangle) {
4304
4471
  const cornerPoints = getTrianglePoints(rectangle);
4305
- const lineCenterPoints = getCenterPointsOnPolygon(cornerPoints);
4472
+ const lineCenterPoints = getCenterPointsOnPolygon$1(cornerPoints);
4306
4473
  return [...lineCenterPoints, ...cornerPoints];
4307
4474
  },
4308
4475
  getTextRectangle(element) {
@@ -4458,7 +4625,7 @@ const ManualInputEngine = createPolygonEngine({
4458
4625
  getPolygonPoints: getManualInputPoints,
4459
4626
  getConnectorPoints: (rectangle) => {
4460
4627
  const cornerPoints = getManualInputPoints(rectangle);
4461
- return getCenterPointsOnPolygon(cornerPoints);
4628
+ return getCenterPointsOnPolygon$1(cornerPoints);
4462
4629
  },
4463
4630
  getTextRectangle: (element) => {
4464
4631
  const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
@@ -4510,7 +4677,7 @@ const ManualLoopEngine = createPolygonEngine({
4510
4677
  getPolygonPoints: getManualLoopPoints,
4511
4678
  getConnectorPoints: (rectangle) => {
4512
4679
  const cornerPoints = getManualLoopPoints(rectangle);
4513
- return getCenterPointsOnPolygon(cornerPoints);
4680
+ return getCenterPointsOnPolygon$1(cornerPoints);
4514
4681
  },
4515
4682
  getTextRectangle(element) {
4516
4683
  const rectangle = getTextRectangle(element);
@@ -4532,7 +4699,7 @@ const MergeEngine = createPolygonEngine({
4532
4699
  getPolygonPoints: getMergePoints,
4533
4700
  getConnectorPoints: (rectangle) => {
4534
4701
  const cornerPoints = getMergePoints(rectangle);
4535
- const lineCenterPoints = getCenterPointsOnPolygon(cornerPoints);
4702
+ const lineCenterPoints = getCenterPointsOnPolygon$1(cornerPoints);
4536
4703
  return [...lineCenterPoints, ...cornerPoints];
4537
4704
  },
4538
4705
  getTextRectangle(element) {
@@ -4738,59 +4905,6 @@ const OffPageEngine = createPolygonEngine({
4738
4905
  }
4739
4906
  });
4740
4907
 
4741
- const CloudEngine = {
4742
- draw(board, rectangle, options) {
4743
- const rs = PlaitBoard.getRoughSVG(board);
4744
- const divisionWidth = rectangle.width / 7;
4745
- const divisionHeight = rectangle.height / 3.2;
4746
- const xRadius = divisionWidth / 8.5;
4747
- const yRadius = divisionHeight / 20;
4748
- const svgElement = rs.path(`M ${rectangle.x + divisionWidth} ${rectangle.y + divisionHeight}
4749
- A ${xRadius} ${yRadius * 1.2} 0 1 1 ${rectangle.x + divisionWidth * 2} ${rectangle.y + divisionHeight / 2}
4750
- A ${xRadius} ${yRadius} 0 1 1 ${rectangle.x + divisionWidth * 4.2} ${rectangle.y + divisionHeight / 2.2}
4751
- A ${xRadius} ${yRadius} 0 1 1 ${rectangle.x + divisionWidth * 5.8} ${rectangle.y + divisionHeight}
4752
- A ${xRadius} ${yRadius * 1.3} 0 1 1 ${rectangle.x + divisionWidth * 6} ${rectangle.y + divisionHeight * 2.2}
4753
- A ${xRadius} ${yRadius * 1.2} 0 1 1 ${rectangle.x + divisionWidth * 5} ${rectangle.y + divisionHeight * 2.8}
4754
- A ${xRadius} ${yRadius / 1.2} 0 1 1 ${rectangle.x + divisionWidth * 2.8} ${rectangle.y + divisionHeight * 2.8}
4755
- A ${xRadius} ${yRadius} 0 1 1 ${rectangle.x + divisionWidth} ${rectangle.y + divisionHeight * 2.2}
4756
- A ${xRadius} ${yRadius * 1.42} 0 1 1 ${rectangle.x + divisionWidth} ${rectangle.y + divisionHeight}
4757
- Z`, { ...options, fillStyle: 'solid' });
4758
- setPathStrokeLinecap(svgElement, 'round');
4759
- return svgElement;
4760
- },
4761
- isInsidePoint(rectangle, point) {
4762
- const rangeRectangle = RectangleClient.getRectangleByPoints([point, point]);
4763
- return RectangleClient.isHit(rectangle, rangeRectangle);
4764
- },
4765
- getCornerPoints(rectangle) {
4766
- return RectangleClient.getCornerPoints(rectangle);
4767
- },
4768
- getNearestPoint(rectangle, point) {
4769
- return getNearestPointBetweenPointAndSegments(point, CloudEngine.getCornerPoints(rectangle));
4770
- },
4771
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
4772
- const corners = CloudEngine.getCornerPoints(rectangle);
4773
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
4774
- return getPolygonEdgeByConnectionPoint(corners, point);
4775
- },
4776
- getConnectorPoints(rectangle) {
4777
- return RectangleClient.getEdgeCenterPoints(rectangle);
4778
- },
4779
- getTextRectangle(element) {
4780
- const elementRectangle = RectangleClient.getRectangleByPoints(element.points);
4781
- const strokeWidth = getStrokeWidthByElement(element);
4782
- const height = element.textHeight;
4783
- const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
4784
- const width = originWidth / 1.5;
4785
- return {
4786
- height,
4787
- width: width > 0 ? width : 0,
4788
- x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
4789
- y: elementRectangle.y + elementRectangle.height / 6 + ((elementRectangle.height * 4) / 6 - height) / 2
4790
- };
4791
- }
4792
- };
4793
-
4794
4908
  const OrEngine = createEllipseEngine({
4795
4909
  draw(board, rectangle, options) {
4796
4910
  const rs = PlaitBoard.getRoughSVG(board);
@@ -8865,5 +8979,5 @@ const withDraw = (board) => {
8865
8979
  * Generated bundle index. Do not edit.
8866
8980
  */
8867
8981
 
8868
- export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon$1 as getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectElementByTable, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
8982
+ export { ArrowLineAutoCompleteGenerator, ArrowLineComponent, ArrowLineHandleKey, ArrowLineMarkerType, ArrowLineShape, BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultActivationProperty, DefaultActorProperty, DefaultArrowProperty, DefaultAssemblyProperty, DefaultBasicShapeProperty, DefaultBasicShapePropertyMap, DefaultClassProperty, DefaultCloudProperty, DefaultCombinedFragmentProperty, DefaultComponentBoxProperty, DefaultConnectorProperty, DefaultContainerProperty, DefaultDataBaseProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultDeletionProperty, DefaultDocumentProperty, DefaultDrawActiveStyle, DefaultDrawStyle, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultInterfaceProperty, DefaultInternalStorageProperty, DefaultManualInputProperty, DefaultMergeProperty, DefaultMultiDocumentProperty, DefaultNoteProperty, DefaultObjectProperty, DefaultPackageProperty, DefaultPentagonArrowProperty, DefaultPortProperty, DefaultProvidedInterfaceProperty, DefaultRequiredInterfaceProperty, DefaultSwimlaneHorizontalProperty, DefaultSwimlaneHorizontalWithHeaderProperty, DefaultSwimlanePropertyMap, DefaultSwimlaneVerticalProperty, DefaultSwimlaneVerticalWithHeaderProperty, DefaultTextProperty, DefaultTwoWayArrowProperty, DefaultUMLPropertyMap, DrawThemeColors, DrawTransforms, FlowchartSymbols, GEOMETRY_NOT_CLOSED, GEOMETRY_WITHOUT_TEXT, GEOMETRY_WITH_MULTIPLE_TEXT, GeometryCommonTextKeys, GeometryComponent, GeometryShapeGenerator, GeometryThreshold, KEY_TO_TEXT_MANAGE, LINE_HIT_GEOMETRY_BUFFER, LINE_SNAPPING_BUFFER, LINE_SNAPPING_CONNECTOR_BUFFER, LineActiveGenerator, MIN_TEXT_WIDTH, MemorizeKey, MultipleTextGeometryTextKeys, PlaitArrowLine, PlaitDrawElement, PlaitGeometry, PlaitTableElement, Q2C, SELECTED_CELLS, SWIMLANE_HEADER_SIZE, ShapeDefaultSpace, SingleTextGenerator, SwimlaneDrawSymbols, SwimlaneSymbols, TableGenerator, TableSymbols, TextGenerator, UMLSymbols, VectorLineComponent, VectorLinePointerType, VectorLineShape, WithArrowLineAutoCompletePluginKey, WithDrawPluginKey, adjustSwimlaneShape, alignElbowSegment, alignPoints, buildClipboardData, buildDefaultTextsByShape, buildSwimlaneTable, clearSelectedCells, collectArrowLineUpdatedRefsByGeometry, createArrowLineElement, createCell, createDefaultCells, createDefaultFlowchart, createDefaultGeometry, createDefaultRowsOrColumns, createDefaultSwimlane, createGeometryElement, createGeometryElementWithText, createGeometryElementWithoutText, createMultipleTextGeometryElement, createTextElement, createUMLClassOrInterfaceGeometryElement, createVectorLineElement, debugGenerator$1 as debugGenerator, deleteTextManage, drawArrowLine, drawArrowLineArrow, drawBoundReaction, drawGeometry, drawShape, drawVectorLine, editCell, editText, getArrowLineHandleRefPair, getArrowLinePointers, getArrowLinePoints, getArrowLineTextRectangle, getArrowLines, getAutoCompletePoints, getBasicPointers, getCellWithPoints, getCellsRectangle, getCellsWithPoints, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultBasicShapeProperty, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultSwimlanePoints, getDefaultTextPoints, getDefaultUMLProperty, getDrawDefaultStrokeColor, getElbowLineRouteOptions, getElbowPoints, getFillByElement, getFirstFilledDrawElement, getFirstTextOrLineElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryAlign, getGeometryPointers, getHitCell, getHitConnection, getHitConnectorPoint, getHitDrawElement, getHitIndexOfAutoCompletePoint, getHitMultipleGeometryText, getHitShape, getIndexAndDeleteCountByKeyPoint, getLineMemorizedLatest, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getMidKeyPoints, getMiddlePoints, getMirrorDataPoints, getMultipleTextGeometryTextKeys, getNearestPoint, getNextRenderPoints, getNextSourceAndTargetPoints, getResizedPreviousAndNextPoint, getSelectedArrowLineElements, getSelectedCells, getSelectedCustomGeometryElements, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedSwimlane, getSelectedTableCellsEditor, getSelectedTableElements, getSelectedVectorLineElements, getSnapResizingRef, getSnapResizingRefOptions, getSnappingRef, getSnappingShape, getSourceAndTargetRectangle, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getSwimlaneCount, getSwimlanePointers, getTextKey, getTextManage, getTextManageByCell, getTextRectangle, getTextShapeProperty, getUMLPointers, getVectorByConnection, getVectorLinePointers, getVectorLinePoints, handleArrowLineCreating, hasIllegalElbowPoint, insertClipboardData, insertElement, isCellIncludeText, isClosedCustomGeometry, isClosedDrawElement, isClosedPoints, isDrawElementIncludeText, isDrawElementsIncludeText, isEmptyTextElement, isFilledDrawElement, isGeometryClosed, isGeometryIncludeText, isHitArrowLine, isHitArrowLineText, isHitDrawElement, isHitEdgeOfShape, isHitElementInside, isHitElementText, isHitPolyLine, isHitVectorLine, isInsideOfShape, isMultipleTextGeometry, isMultipleTextShape, isRectangleHitDrawElement, isRectangleHitElementText, isRectangleHitRotatedElement, isRectangleHitRotatedPoints, isSelfLoop, isSingleSelectElementByTable, isSingleSelectLine, isSingleSelectSwimlane, isSingleSelectTable, isSingleTextGeometry, isSingleTextShape, isSwimlanePointers, isSwimlaneWithHeader, isTextExceedingBounds, isUpdatedHandleIndex, isUseDefaultOrthogonalRoute, memorizeLatestShape, memorizeLatestText, rerenderGeometryActive, setSelectedCells, setTextManage, traverseDrawShapes, updateCellIds, updateCellIdsByRowOrColumn, updateColumns, updateRowOrColumnIds, updateRows, vectorLineCreating, withArrowLineAutoComplete, withDraw };
8869
8983
  //# sourceMappingURL=plait-draw.mjs.map