@plait/draw 0.28.0 → 0.29.0

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.
Files changed (105) hide show
  1. package/constants/geometry.d.ts +71 -1
  2. package/constants/pointer.d.ts +4 -2
  3. package/engines/{comment.d.ts → basic-shapes/comment.d.ts} +1 -1
  4. package/engines/{cross.d.ts → basic-shapes/cross.d.ts} +2 -2
  5. package/engines/{diamond.d.ts → basic-shapes/diamond.d.ts} +1 -1
  6. package/engines/basic-shapes/ellipse.d.ts +13 -0
  7. package/engines/{hexagon.d.ts → basic-shapes/hexagon.d.ts} +2 -2
  8. package/engines/{left-arrow.d.ts → basic-shapes/left-arrow.d.ts} +2 -2
  9. package/engines/{octagon.d.ts → basic-shapes/octagon.d.ts} +2 -2
  10. package/engines/basic-shapes/parallelogram.d.ts +4 -0
  11. package/engines/{pentagon-arrow.d.ts → basic-shapes/pentagon-arrow.d.ts} +2 -2
  12. package/engines/{pentagon.d.ts → basic-shapes/pentagon.d.ts} +2 -2
  13. package/engines/basic-shapes/polygon.d.ts +8 -0
  14. package/engines/{process-arrow.d.ts → basic-shapes/process-arrow.d.ts} +2 -2
  15. package/engines/{rectangle.d.ts → basic-shapes/rectangle.d.ts} +1 -1
  16. package/engines/{right-arrow.d.ts → basic-shapes/right-arrow.d.ts} +2 -2
  17. package/engines/{round-comment.d.ts → basic-shapes/round-comment.d.ts} +1 -1
  18. package/engines/{round-rectangle.d.ts → basic-shapes/round-rectangle.d.ts} +1 -1
  19. package/engines/{star.d.ts → basic-shapes/star.d.ts} +2 -2
  20. package/engines/{trapezoid.d.ts → basic-shapes/trapezoid.d.ts} +2 -2
  21. package/engines/{triangle.d.ts → basic-shapes/triangle.d.ts} +2 -2
  22. package/engines/{two-way-arrow.d.ts → basic-shapes/two-way-arrow.d.ts} +2 -2
  23. package/engines/flowchart/delay.d.ts +2 -0
  24. package/engines/flowchart/manual-input.d.ts +4 -0
  25. package/engines/flowchart/manual-loop.d.ts +4 -0
  26. package/engines/flowchart/merge.d.ts +4 -0
  27. package/engines/flowchart/preparation.d.ts +4 -0
  28. package/engines/flowchart/stored-data.d.ts +2 -0
  29. package/engines/flowchart/terminal.d.ts +5 -0
  30. package/engines/index.d.ts +3 -3
  31. package/esm2022/constants/geometry.mjs +40 -2
  32. package/esm2022/constants/pointer.mjs +9 -3
  33. package/esm2022/engines/basic-shapes/comment.mjs +57 -0
  34. package/esm2022/engines/basic-shapes/cross.mjs +33 -0
  35. package/esm2022/engines/basic-shapes/diamond.mjs +16 -0
  36. package/esm2022/engines/basic-shapes/ellipse.mjs +100 -0
  37. package/esm2022/engines/basic-shapes/hexagon.mjs +27 -0
  38. package/esm2022/engines/basic-shapes/left-arrow.mjs +30 -0
  39. package/esm2022/engines/basic-shapes/octagon.mjs +29 -0
  40. package/esm2022/engines/basic-shapes/parallelogram.mjs +25 -0
  41. package/esm2022/engines/basic-shapes/pentagon-arrow.mjs +24 -0
  42. package/esm2022/engines/basic-shapes/pentagon.mjs +30 -0
  43. package/esm2022/engines/basic-shapes/polygon.mjs +40 -0
  44. package/esm2022/engines/basic-shapes/process-arrow.mjs +26 -0
  45. package/esm2022/engines/basic-shapes/rectangle.mjs +26 -0
  46. package/esm2022/engines/basic-shapes/right-arrow.mjs +28 -0
  47. package/esm2022/engines/basic-shapes/round-comment.mjs +81 -0
  48. package/esm2022/engines/basic-shapes/round-rectangle.mjs +59 -0
  49. package/esm2022/engines/basic-shapes/star.mjs +39 -0
  50. package/esm2022/engines/basic-shapes/trapezoid.mjs +25 -0
  51. package/esm2022/engines/basic-shapes/triangle.mjs +33 -0
  52. package/esm2022/engines/basic-shapes/two-way-arrow.mjs +25 -0
  53. package/esm2022/engines/flowchart/delay.mjs +45 -0
  54. package/esm2022/engines/flowchart/manual-input.mjs +32 -0
  55. package/esm2022/engines/flowchart/manual-loop.mjs +25 -0
  56. package/esm2022/engines/flowchart/merge.mjs +34 -0
  57. package/esm2022/engines/flowchart/preparation.mjs +27 -0
  58. package/esm2022/engines/flowchart/stored-data.mjs +74 -0
  59. package/esm2022/engines/flowchart/terminal.mjs +59 -0
  60. package/esm2022/engines/index.mjs +59 -41
  61. package/esm2022/generators/geometry-shape.generator.mjs +3 -3
  62. package/esm2022/generators/line.generator.mjs +1 -1
  63. package/esm2022/geometry.component.mjs +9 -5
  64. package/esm2022/image.component.mjs +4 -4
  65. package/esm2022/interfaces/geometry.mjs +38 -24
  66. package/esm2022/interfaces/index.mjs +9 -3
  67. package/esm2022/interfaces/text.mjs +1 -1
  68. package/esm2022/line.component.mjs +4 -4
  69. package/esm2022/plugins/with-geometry-create.mjs +31 -19
  70. package/esm2022/transforms/geometry.mjs +6 -6
  71. package/esm2022/utils/geometry.mjs +13 -5
  72. package/esm2022/utils/line-arrow.mjs +3 -3
  73. package/esm2022/utils/shape.mjs +3 -3
  74. package/fesm2022/plait-draw.mjs +750 -536
  75. package/fesm2022/plait-draw.mjs.map +1 -1
  76. package/interfaces/geometry.d.ts +19 -5
  77. package/interfaces/index.d.ts +2 -0
  78. package/interfaces/text.d.ts +2 -2
  79. package/package.json +1 -1
  80. package/plugins/with-geometry-create.d.ts +5 -0
  81. package/transforms/geometry.d.ts +2 -2
  82. package/transforms/index.d.ts +1 -1
  83. package/utils/geometry.d.ts +22 -3
  84. package/utils/shape.d.ts +2 -2
  85. package/engines/ellipse.d.ts +0 -4
  86. package/engines/parallelogram.d.ts +0 -4
  87. package/esm2022/engines/comment.mjs +0 -57
  88. package/esm2022/engines/cross.mjs +0 -46
  89. package/esm2022/engines/diamond.mjs +0 -30
  90. package/esm2022/engines/ellipse.mjs +0 -92
  91. package/esm2022/engines/hexagon.mjs +0 -40
  92. package/esm2022/engines/left-arrow.mjs +0 -45
  93. package/esm2022/engines/octagon.mjs +0 -42
  94. package/esm2022/engines/parallelogram.mjs +0 -39
  95. package/esm2022/engines/pentagon-arrow.mjs +0 -39
  96. package/esm2022/engines/pentagon.mjs +0 -39
  97. package/esm2022/engines/process-arrow.mjs +0 -41
  98. package/esm2022/engines/rectangle.mjs +0 -26
  99. package/esm2022/engines/right-arrow.mjs +0 -45
  100. package/esm2022/engines/round-comment.mjs +0 -81
  101. package/esm2022/engines/round-rectangle.mjs +0 -59
  102. package/esm2022/engines/star.mjs +0 -45
  103. package/esm2022/engines/trapezoid.mjs +0 -40
  104. package/esm2022/engines/triangle.mjs +0 -40
  105. package/esm2022/engines/two-way-arrow.mjs +0 -48
@@ -8,29 +8,43 @@ import { Subject } from 'rxjs';
8
8
  import { isKeyHotkey } from 'is-hotkey';
9
9
  import { Node } from 'slate';
10
10
 
11
- var GeometryShape;
12
- (function (GeometryShape) {
13
- GeometryShape["rectangle"] = "rectangle";
14
- GeometryShape["ellipse"] = "ellipse";
15
- GeometryShape["diamond"] = "diamond";
16
- GeometryShape["roundRectangle"] = "roundRectangle";
17
- GeometryShape["parallelogram"] = "parallelogram";
18
- GeometryShape["text"] = "text";
19
- GeometryShape["triangle"] = "triangle";
20
- GeometryShape["leftArrow"] = "leftArrow";
21
- GeometryShape["trapezoid"] = "trapezoid";
22
- GeometryShape["rightArrow"] = "rightArrow";
23
- GeometryShape["cross"] = "cross";
24
- GeometryShape["star"] = "star";
25
- GeometryShape["pentagon"] = "pentagon";
26
- GeometryShape["hexagon"] = "hexagon";
27
- GeometryShape["octagon"] = "octagon";
28
- GeometryShape["pentagonArrow"] = "pentagonArrow";
29
- GeometryShape["processArrow"] = "processArrow";
30
- GeometryShape["twoWayArrow"] = "twoWayArrow";
31
- GeometryShape["comment"] = "comment";
32
- GeometryShape["roundComment"] = "roundComment";
33
- })(GeometryShape || (GeometryShape = {}));
11
+ var BasicShapes;
12
+ (function (BasicShapes) {
13
+ BasicShapes["rectangle"] = "rectangle";
14
+ BasicShapes["ellipse"] = "ellipse";
15
+ BasicShapes["diamond"] = "diamond";
16
+ BasicShapes["roundRectangle"] = "roundRectangle";
17
+ BasicShapes["parallelogram"] = "parallelogram";
18
+ BasicShapes["text"] = "text";
19
+ BasicShapes["triangle"] = "triangle";
20
+ BasicShapes["leftArrow"] = "leftArrow";
21
+ BasicShapes["trapezoid"] = "trapezoid";
22
+ BasicShapes["rightArrow"] = "rightArrow";
23
+ BasicShapes["cross"] = "cross";
24
+ BasicShapes["star"] = "star";
25
+ BasicShapes["pentagon"] = "pentagon";
26
+ BasicShapes["hexagon"] = "hexagon";
27
+ BasicShapes["octagon"] = "octagon";
28
+ BasicShapes["pentagonArrow"] = "pentagonArrow";
29
+ BasicShapes["processArrow"] = "processArrow";
30
+ BasicShapes["twoWayArrow"] = "twoWayArrow";
31
+ BasicShapes["comment"] = "comment";
32
+ BasicShapes["roundComment"] = "roundComment";
33
+ })(BasicShapes || (BasicShapes = {}));
34
+ var FlowchartSymbols;
35
+ (function (FlowchartSymbols) {
36
+ FlowchartSymbols["process"] = "process";
37
+ FlowchartSymbols["decision"] = "decision";
38
+ FlowchartSymbols["data"] = "data";
39
+ FlowchartSymbols["connector"] = "connector";
40
+ FlowchartSymbols["terminal"] = "terminal";
41
+ FlowchartSymbols["manualInput"] = "manualInput";
42
+ FlowchartSymbols["preparation"] = "preparation";
43
+ FlowchartSymbols["manualLoop"] = "manualLoop";
44
+ FlowchartSymbols["merge"] = "merge";
45
+ FlowchartSymbols["delay"] = "delay";
46
+ FlowchartSymbols["storedData"] = "storedData";
47
+ })(FlowchartSymbols || (FlowchartSymbols = {}));
34
48
  const PlaitGeometry = {
35
49
  getTextEditor(element) {
36
50
  return PlaitGeometry.getTextManage(element).componentRef.instance.editor;
@@ -57,7 +71,7 @@ const DefaultGeometryActiveStyle = {
57
71
  strokeWidth: ACTIVE_STROKE_WIDTH,
58
72
  selectionStrokeWidth: ACTIVE_STROKE_WIDTH
59
73
  };
60
- const DefaultGeometryProperty = {
74
+ const DefaultBasicShapeProperty = {
61
75
  width: 100,
62
76
  height: 100,
63
77
  strokeColor: '#333',
@@ -71,9 +85,52 @@ const DefaultTextProperty = {
71
85
  const GeometryThreshold = {
72
86
  defaultTextMaxWidth: 34 * 14
73
87
  };
88
+ const DefaultConnectorProperty = {
89
+ width: 44,
90
+ height: 44
91
+ };
92
+ const DefaultFlowchartProperty = {
93
+ width: 120,
94
+ height: 60
95
+ };
96
+ const DefaultDecisionProperty = {
97
+ width: 140,
98
+ height: 70
99
+ };
100
+ const DefaultDataProperty = {
101
+ width: 124,
102
+ height: 60
103
+ };
104
+ const DefaultManualInputProperty = {
105
+ width: 117,
106
+ height: 59
107
+ };
108
+ const DefaultMergeProperty = {
109
+ width: 47,
110
+ height: 33
111
+ };
112
+ const DefaultFlowchartPropertyMap = {
113
+ [FlowchartSymbols.connector]: DefaultConnectorProperty,
114
+ [FlowchartSymbols.process]: DefaultFlowchartProperty,
115
+ [FlowchartSymbols.decision]: DefaultDecisionProperty,
116
+ [FlowchartSymbols.data]: DefaultDataProperty,
117
+ [FlowchartSymbols.terminal]: DefaultFlowchartProperty,
118
+ [FlowchartSymbols.manualInput]: DefaultManualInputProperty,
119
+ [FlowchartSymbols.preparation]: DefaultFlowchartProperty,
120
+ [FlowchartSymbols.manualLoop]: DefaultFlowchartProperty,
121
+ [FlowchartSymbols.merge]: DefaultMergeProperty,
122
+ [FlowchartSymbols.delay]: DefaultFlowchartProperty,
123
+ [FlowchartSymbols.storedData]: DefaultFlowchartProperty
124
+ };
74
125
 
75
126
  const getGeometryPointers = () => {
76
- return Object.keys(GeometryShape);
127
+ return [...Object.keys(BasicShapes), ...Object.keys(FlowchartSymbols)];
128
+ };
129
+ const getBasicPointers = () => {
130
+ return Object.keys(BasicShapes);
131
+ };
132
+ const getFlowchartPointers = () => {
133
+ return Object.keys(FlowchartSymbols);
77
134
  };
78
135
  const getLinePointers = () => {
79
136
  return Object.keys(LineShape);
@@ -155,33 +212,44 @@ const getCommentPoints = (rectangle) => {
155
212
  ];
156
213
  };
157
214
 
158
- const CrossEngine = {
159
- draw(board, rectangle, options) {
160
- const points = getCrossPoints(rectangle);
161
- const rs = PlaitBoard.getRoughSVG(board);
162
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
163
- setStrokeLinecap(polygon, 'round');
164
- return polygon;
165
- },
166
- isHit(rectangle, point) {
167
- const parallelogramPoints = getCrossPoints(rectangle);
168
- return isPointInPolygon(point, parallelogramPoints);
169
- },
170
- getCornerPoints(rectangle) {
171
- return getCrossPoints(rectangle);
172
- },
173
- getNearestPoint(rectangle, point) {
174
- return getNearestPointBetweenPointAndSegments(point, getCrossPoints(rectangle));
175
- },
176
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
177
- const corners = getCrossPoints(rectangle);
178
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
179
- return getEdgeOnPolygonByPoint(corners, point);
180
- },
181
- getConnectorPoints(rectangle) {
182
- return RectangleClient.getEdgeCenterPoints(rectangle);
215
+ function createPolygonEngine(options) {
216
+ const getPoints = options.getPolygonPoints;
217
+ const engine = {
218
+ draw(board, rectangle, options) {
219
+ const points = getPoints(rectangle);
220
+ const rs = PlaitBoard.getRoughSVG(board);
221
+ const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
222
+ setStrokeLinecap(polygon, 'round');
223
+ return polygon;
224
+ },
225
+ isHit(rectangle, point) {
226
+ const points = getPoints(rectangle);
227
+ return isPointInPolygon(point, points);
228
+ },
229
+ getCornerPoints(rectangle) {
230
+ return getPoints(rectangle);
231
+ },
232
+ getNearestPoint(rectangle, point) {
233
+ return getNearestPointBetweenPointAndSegments(point, getPoints(rectangle));
234
+ },
235
+ getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
236
+ const corners = getPoints(rectangle);
237
+ const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
238
+ return getEdgeOnPolygonByPoint(corners, point);
239
+ },
240
+ getConnectorPoints(rectangle) {
241
+ if (options.getConnectorPoints) {
242
+ return options.getConnectorPoints(rectangle);
243
+ }
244
+ return getPoints(rectangle);
245
+ }
246
+ };
247
+ if (options.getTextRectangle) {
248
+ engine.getTextRectangle = options.getTextRectangle;
183
249
  }
184
- };
250
+ return engine;
251
+ }
252
+
185
253
  const getCrossPoints = (rectangle) => {
186
254
  return [
187
255
  [rectangle.x + rectangle.width / 4, rectangle.y],
@@ -198,34 +266,32 @@ const getCrossPoints = (rectangle) => {
198
266
  [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height / 4]
199
267
  ];
200
268
  };
201
-
202
- const DiamondEngine = {
203
- draw(board, rectangle, options) {
204
- const points = RectangleClient.getEdgeCenterPoints(rectangle);
205
- const rs = PlaitBoard.getRoughSVG(board);
206
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
207
- setStrokeLinecap(polygon, 'round');
208
- return polygon;
209
- },
210
- isHit(rectangle, point) {
211
- const controlPoints = RectangleClient.getEdgeCenterPoints(rectangle);
212
- return isPointInPolygon(point, controlPoints);
213
- },
214
- getCornerPoints(rectangle) {
269
+ const CrossEngine = createPolygonEngine({
270
+ getPolygonPoints: getCrossPoints,
271
+ getConnectorPoints(rectangle) {
215
272
  return RectangleClient.getEdgeCenterPoints(rectangle);
216
273
  },
217
- getNearestPoint(rectangle, point) {
218
- return getNearestPointBetweenPointAndSegments(point, DiamondEngine.getCornerPoints(rectangle));
219
- },
220
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
221
- const corners = DiamondEngine.getCornerPoints(rectangle);
222
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
223
- return getEdgeOnPolygonByPoint(corners, point);
224
- },
274
+ getTextRectangle(element) {
275
+ const rectangle = getTextRectangle(element);
276
+ const width = rectangle.width;
277
+ rectangle.width = rectangle.width / 2;
278
+ rectangle.x += width / 4;
279
+ return rectangle;
280
+ }
281
+ });
282
+
283
+ const DiamondEngine = createPolygonEngine({
284
+ getPolygonPoints: RectangleClient.getEdgeCenterPoints,
225
285
  getConnectorPoints(rectangle) {
226
286
  return RectangleClient.getEdgeCenterPoints(rectangle);
287
+ },
288
+ getTextRectangle(element) {
289
+ const rectangle = getTextRectangle(element);
290
+ rectangle.width = rectangle.width / 2;
291
+ rectangle.x += rectangle.width / 2;
292
+ return rectangle;
227
293
  }
228
- };
294
+ });
229
295
 
230
296
  const EllipseEngine = {
231
297
  draw(board, rectangle, options) {
@@ -255,6 +321,13 @@ const EllipseEngine = {
255
321
  },
256
322
  getConnectorPoints(rectangle) {
257
323
  return RectangleClient.getEdgeCenterPoints(rectangle);
324
+ },
325
+ getTextRectangle(element) {
326
+ const rectangle = getTextRectangle(element);
327
+ const width = rectangle.width;
328
+ rectangle.width = (rectangle.width * 3) / 4;
329
+ rectangle.x += width / 8;
330
+ return rectangle;
258
331
  }
259
332
  };
260
333
  function getNearestPointBetweenPointAndEllipse(point, center, rx, ry, rotation = 0) {
@@ -318,33 +391,6 @@ function getVectorBySlope(x, y, slope) {
318
391
  return vector;
319
392
  }
320
393
 
321
- const HexagonEngine = {
322
- draw(board, rectangle, options) {
323
- const points = getHexagonPoints(rectangle);
324
- const rs = PlaitBoard.getRoughSVG(board);
325
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
326
- setStrokeLinecap(polygon, 'round');
327
- return polygon;
328
- },
329
- isHit(rectangle, point) {
330
- const parallelogramPoints = getHexagonPoints(rectangle);
331
- return isPointInPolygon(point, parallelogramPoints);
332
- },
333
- getCornerPoints(rectangle) {
334
- return getHexagonPoints(rectangle);
335
- },
336
- getNearestPoint(rectangle, point) {
337
- return getNearestPointBetweenPointAndSegments(point, getHexagonPoints(rectangle));
338
- },
339
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
340
- const corners = getHexagonPoints(rectangle);
341
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
342
- return getEdgeOnPolygonByPoint(corners, point);
343
- },
344
- getConnectorPoints(rectangle) {
345
- return RectangleClient.getEdgeCenterPoints(rectangle);
346
- }
347
- };
348
394
  const getHexagonPoints = (rectangle) => {
349
395
  return [
350
396
  [rectangle.x + rectangle.width / 4, rectangle.y],
@@ -355,38 +401,20 @@ const getHexagonPoints = (rectangle) => {
355
401
  [rectangle.x, rectangle.y + rectangle.height / 2]
356
402
  ];
357
403
  };
358
-
359
- const LeftArrowEngine = {
360
- draw(board, rectangle, options) {
361
- const points = getLeftArrowPoints(rectangle);
362
- const rs = PlaitBoard.getRoughSVG(board);
363
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
364
- setStrokeLinecap(polygon, 'round');
365
- return polygon;
366
- },
367
- getCornerPoints(rectangle) {
368
- return getLeftArrowPoints(rectangle);
369
- },
370
- isHit(rectangle, point) {
371
- const points = getLeftArrowPoints(rectangle);
372
- return isPointInPolygon(point, points);
373
- },
374
- getNearestPoint(rectangle, point) {
375
- const cornerPoints = getLeftArrowPoints(rectangle);
376
- return getNearestPointBetweenPointAndSegments(point, cornerPoints);
377
- },
378
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
379
- const corners = getLeftArrowPoints(rectangle);
380
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
381
- return getEdgeOnPolygonByPoint(corners, point);
382
- },
404
+ const HexagonEngine = createPolygonEngine({
405
+ getPolygonPoints: getHexagonPoints,
383
406
  getConnectorPoints(rectangle) {
384
- return [
385
- [rectangle.x, rectangle.y + rectangle.height / 2],
386
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
387
- ];
407
+ return RectangleClient.getEdgeCenterPoints(rectangle);
408
+ },
409
+ getTextRectangle(element) {
410
+ const rectangle = getTextRectangle(element);
411
+ const width = rectangle.width;
412
+ rectangle.width = (rectangle.width * 3) / 4;
413
+ rectangle.x += width / 8;
414
+ return rectangle;
388
415
  }
389
- };
416
+ });
417
+
390
418
  const getLeftArrowPoints = (rectangle) => {
391
419
  return [
392
420
  [rectangle.x, rectangle.y + rectangle.height / 2],
@@ -398,34 +426,23 @@ const getLeftArrowPoints = (rectangle) => {
398
426
  [rectangle.x + rectangle.width * 0.32, rectangle.y + rectangle.height]
399
427
  ];
400
428
  };
401
-
402
- const OctagonEngine = {
403
- draw(board, rectangle, options) {
404
- const points = getOctagonPoints(rectangle);
405
- const rs = PlaitBoard.getRoughSVG(board);
406
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
407
- setStrokeLinecap(polygon, 'round');
408
- return polygon;
409
- },
410
- isHit(rectangle, point) {
411
- const parallelogramPoints = getOctagonPoints(rectangle);
412
- return isPointInPolygon(point, parallelogramPoints);
413
- },
414
- getCornerPoints(rectangle) {
415
- return getOctagonPoints(rectangle);
416
- },
417
- getNearestPoint(rectangle, point) {
418
- return getNearestPointBetweenPointAndSegments(point, getOctagonPoints(rectangle));
419
- },
420
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
421
- const corners = getOctagonPoints(rectangle);
422
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
423
- return getEdgeOnPolygonByPoint(corners, point);
429
+ const LeftArrowEngine = createPolygonEngine({
430
+ getPolygonPoints: getLeftArrowPoints,
431
+ getConnectorPoints: (rectangle) => {
432
+ return [
433
+ [rectangle.x, rectangle.y + rectangle.height / 2],
434
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
435
+ ];
424
436
  },
425
- getConnectorPoints(rectangle) {
426
- return RectangleClient.getEdgeCenterPoints(rectangle);
437
+ getTextRectangle(element) {
438
+ const rectangle = getTextRectangle(element);
439
+ const width = rectangle.width;
440
+ rectangle.width = rectangle.width * (1 - 0.32);
441
+ rectangle.x += width * 0.32;
442
+ return rectangle;
427
443
  }
428
- };
444
+ });
445
+
429
446
  const getOctagonPoints = (rectangle) => {
430
447
  return [
431
448
  [rectangle.x + (rectangle.width * 3) / 10, rectangle.y],
@@ -438,36 +455,21 @@ const getOctagonPoints = (rectangle) => {
438
455
  [rectangle.x, rectangle.y + (rectangle.height * 3) / 10]
439
456
  ];
440
457
  };
441
-
442
- const ParallelogramEngine = {
443
- draw(board, rectangle, options) {
444
- const points = getParallelogramCornerPoints(rectangle);
445
- const rs = PlaitBoard.getRoughSVG(board);
446
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
447
- setStrokeLinecap(polygon, 'round');
448
- return polygon;
449
- },
450
- isHit(rectangle, point) {
451
- const parallelogramPoints = getParallelogramCornerPoints(rectangle);
452
- return isPointInPolygon(point, parallelogramPoints);
453
- },
454
- getCornerPoints(rectangle) {
455
- return getParallelogramCornerPoints(rectangle);
456
- },
457
- getNearestPoint(rectangle, point) {
458
- return getNearestPointBetweenPointAndSegments(point, ParallelogramEngine.getCornerPoints(rectangle));
459
- },
460
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
461
- const corners = getParallelogramCornerPoints(rectangle);
462
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
463
- return getEdgeOnPolygonByPoint(corners, point);
464
- },
458
+ const OctagonEngine = createPolygonEngine({
459
+ getPolygonPoints: getOctagonPoints,
465
460
  getConnectorPoints(rectangle) {
466
- const cornerPoints = getParallelogramCornerPoints(rectangle);
467
- return getCenterPointsOnPolygon(cornerPoints);
461
+ return RectangleClient.getEdgeCenterPoints(rectangle);
462
+ },
463
+ getTextRectangle(element) {
464
+ const rectangle = getTextRectangle(element);
465
+ const width = rectangle.width;
466
+ rectangle.width = (rectangle.width * 3) / 4;
467
+ rectangle.x += width / 8;
468
+ return rectangle;
468
469
  }
469
- };
470
- const getParallelogramCornerPoints = (rectangle) => {
470
+ });
471
+
472
+ const getParallelogramPoints = (rectangle) => {
471
473
  return [
472
474
  [rectangle.x + rectangle.width / 4, rectangle.y],
473
475
  [rectangle.x + rectangle.width, rectangle.y],
@@ -475,34 +477,21 @@ const getParallelogramCornerPoints = (rectangle) => {
475
477
  [rectangle.x, rectangle.y + rectangle.height]
476
478
  ];
477
479
  };
478
-
479
- const PentagonEngine = {
480
- draw(board, rectangle, options) {
481
- const points = getPentagonPoints(rectangle);
482
- const rs = PlaitBoard.getRoughSVG(board);
483
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
484
- setStrokeLinecap(polygon, 'round');
485
- return polygon;
486
- },
487
- isHit(rectangle, point) {
488
- const parallelogramPoints = getPentagonPoints(rectangle);
489
- return isPointInPolygon(point, parallelogramPoints);
490
- },
491
- getCornerPoints(rectangle) {
492
- return getPentagonPoints(rectangle);
493
- },
494
- getNearestPoint(rectangle, point) {
495
- return getNearestPointBetweenPointAndSegments(point, getPentagonPoints(rectangle));
496
- },
497
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
498
- const corners = getPentagonPoints(rectangle);
499
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
500
- return getEdgeOnPolygonByPoint(corners, point);
480
+ const ParallelogramEngine = createPolygonEngine({
481
+ getPolygonPoints: getParallelogramPoints,
482
+ getConnectorPoints: (rectangle) => {
483
+ const cornerPoints = getParallelogramPoints(rectangle);
484
+ return getCenterPointsOnPolygon(cornerPoints);
501
485
  },
502
- getConnectorPoints(rectangle) {
503
- return getPentagonPoints(rectangle);
486
+ getTextRectangle(element) {
487
+ const rectangle = getTextRectangle(element);
488
+ const width = rectangle.width;
489
+ rectangle.width = rectangle.width / 2;
490
+ rectangle.x += width / 4;
491
+ return rectangle;
504
492
  }
505
- };
493
+ });
494
+
506
495
  const getPentagonPoints = (rectangle) => {
507
496
  return [
508
497
  [rectangle.x + rectangle.width / 2, rectangle.y],
@@ -512,34 +501,23 @@ const getPentagonPoints = (rectangle) => {
512
501
  [rectangle.x, rectangle.y + (rectangle.height * 2) / 5]
513
502
  ];
514
503
  };
515
-
516
- const PentagonArrowEngine = {
517
- draw(board, rectangle, options) {
518
- const points = getPentagonArrowPoints(rectangle);
519
- const rs = PlaitBoard.getRoughSVG(board);
520
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
521
- setStrokeLinecap(polygon, 'round');
522
- return polygon;
523
- },
524
- isHit(rectangle, point) {
525
- const parallelogramPoints = getPentagonArrowPoints(rectangle);
526
- return isPointInPolygon(point, parallelogramPoints);
527
- },
528
- getCornerPoints(rectangle) {
529
- return getPentagonArrowPoints(rectangle);
530
- },
531
- getNearestPoint(rectangle, point) {
532
- return getNearestPointBetweenPointAndSegments(point, getPentagonArrowPoints(rectangle));
533
- },
534
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
535
- const corners = getPentagonArrowPoints(rectangle);
536
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
537
- return getEdgeOnPolygonByPoint(corners, point);
538
- },
539
- getConnectorPoints(rectangle) {
540
- return RectangleClient.getEdgeCenterPoints(rectangle);
504
+ const PentagonEngine = createPolygonEngine({
505
+ getPolygonPoints: getPentagonPoints,
506
+ getTextRectangle(element) {
507
+ const elementRectangle = getRectangleByPoints(element.points);
508
+ const strokeWidth = getStrokeWidthByElement(element);
509
+ const height = element.textHeight;
510
+ const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
511
+ const width = (originWidth * 3) / 5;
512
+ return {
513
+ height,
514
+ width: width > 0 ? width : 0,
515
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 5,
516
+ y: elementRectangle.y + elementRectangle.height / 5 + ((elementRectangle.height * 4) / 5 - height) / 2
517
+ };
541
518
  }
542
- };
519
+ });
520
+
543
521
  const getPentagonArrowPoints = (rectangle) => {
544
522
  return [
545
523
  [rectangle.x, rectangle.y],
@@ -549,59 +527,103 @@ const getPentagonArrowPoints = (rectangle) => {
549
527
  [rectangle.x, rectangle.y + rectangle.height]
550
528
  ];
551
529
  };
530
+ const PentagonArrowEngine = createPolygonEngine({
531
+ getPolygonPoints: getPentagonArrowPoints,
532
+ getConnectorPoints(rectangle) {
533
+ return RectangleClient.getEdgeCenterPoints(rectangle);
534
+ },
535
+ getTextRectangle(element) {
536
+ const rectangle = getTextRectangle(element);
537
+ rectangle.width = (rectangle.width * 3) / 5;
538
+ return rectangle;
539
+ }
540
+ });
552
541
 
553
- const ProcessArrowEngine = {
542
+ const getProcessArrowPoints = (rectangle) => {
543
+ const wider = rectangle.width > rectangle.height / 2;
544
+ return [
545
+ [rectangle.x, rectangle.y],
546
+ [rectangle.x + (wider ? rectangle.width - rectangle.height / 2 : 0), rectangle.y],
547
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
548
+ [rectangle.x + (wider ? rectangle.width - rectangle.height / 2 : 0), rectangle.y + rectangle.height],
549
+ [rectangle.x, rectangle.y + rectangle.height],
550
+ [rectangle.x + (wider ? rectangle.height / 2 : rectangle.width), rectangle.y + rectangle.height / 2]
551
+ ];
552
+ };
553
+ const ProcessArrowEngine = createPolygonEngine({
554
+ getPolygonPoints: getProcessArrowPoints,
555
+ getTextRectangle(element) {
556
+ const rectangle = getTextRectangle(element);
557
+ const elementRectangle = getRectangleByPoints(element.points);
558
+ const width = rectangle.width;
559
+ rectangle.width = elementRectangle.height / 2;
560
+ rectangle.x += elementRectangle.height / 2;
561
+ return rectangle;
562
+ }
563
+ });
564
+
565
+ const RectangleEngine = {
554
566
  draw(board, rectangle, options) {
555
- const points = getProcessArrowPoints(rectangle);
556
- const rs = PlaitBoard.getRoughSVG(board);
557
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
558
- setStrokeLinecap(polygon, 'round');
559
- return polygon;
567
+ return drawRectangle(board, rectangle, { ...options, fillStyle: 'solid' });
560
568
  },
561
569
  isHit(rectangle, point) {
562
- const parallelogramPoints = getProcessArrowPoints(rectangle);
563
- return isPointInPolygon(point, parallelogramPoints);
570
+ const rangeRectangle = RectangleClient.toRectangleClient([point, point]);
571
+ return RectangleClient.isHit(rectangle, rangeRectangle);
564
572
  },
565
573
  getCornerPoints(rectangle) {
566
- return getProcessArrowPoints(rectangle);
574
+ return RectangleClient.getCornerPoints(rectangle);
567
575
  },
568
576
  getNearestPoint(rectangle, point) {
569
- return getNearestPointBetweenPointAndSegments(point, getProcessArrowPoints(rectangle));
577
+ return getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
570
578
  },
571
579
  getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
572
- const corners = getProcessArrowPoints(rectangle);
580
+ const corners = RectangleEngine.getCornerPoints(rectangle);
573
581
  const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
574
582
  return getEdgeOnPolygonByPoint(corners, point);
575
583
  },
576
584
  getConnectorPoints(rectangle) {
577
- return getProcessArrowPoints(rectangle);
585
+ return RectangleClient.getEdgeCenterPoints(rectangle);
578
586
  }
579
587
  };
580
- const getProcessArrowPoints = (rectangle) => {
581
- const wider = rectangle.width > rectangle.height / 2;
588
+
589
+ const getRightArrowPoints = (rectangle) => {
582
590
  return [
583
- [rectangle.x, rectangle.y],
584
- [rectangle.x + (wider ? rectangle.width - rectangle.height / 2 : 0), rectangle.y],
591
+ [rectangle.x, rectangle.y + rectangle.height * 0.2],
592
+ [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height * 0.2],
593
+ [rectangle.x + rectangle.width * 0.68, rectangle.y],
585
594
  [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
586
- [rectangle.x + (wider ? rectangle.width - rectangle.height / 2 : 0), rectangle.y + rectangle.height],
587
- [rectangle.x, rectangle.y + rectangle.height],
588
- [rectangle.x + (wider ? rectangle.height / 2 : rectangle.width), rectangle.y + rectangle.height / 2]
595
+ [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height],
596
+ [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height * 0.8],
597
+ [rectangle.x, rectangle.y + rectangle.height * 0.8]
589
598
  ];
590
599
  };
600
+ const RightArrowEngine = createPolygonEngine({
601
+ getPolygonPoints: getRightArrowPoints,
602
+ getConnectorPoints: (rectangle) => {
603
+ return [
604
+ [rectangle.x, rectangle.y + rectangle.height / 2],
605
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
606
+ ];
607
+ },
608
+ getTextRectangle(element) {
609
+ const rectangle = getTextRectangle(element);
610
+ rectangle.width = rectangle.width * 0.68;
611
+ return rectangle;
612
+ }
613
+ });
591
614
 
592
- const RectangleEngine = {
615
+ const RoundRectangleEngine = {
593
616
  draw(board, rectangle, options) {
594
- return drawRectangle(board, rectangle, { ...options, fillStyle: 'solid' });
617
+ return drawRoundRectangle(PlaitBoard.getRoughSVG(board), rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height, { ...options, fillStyle: 'solid' }, false, getRoundRectangleRadius(rectangle));
595
618
  },
596
619
  isHit(rectangle, point) {
597
- const rangeRectangle = RectangleClient.toRectangleClient([point, point]);
598
- return RectangleClient.isHit(rectangle, rangeRectangle);
620
+ return isPointInRoundRectangle(point, rectangle, getRoundRectangleRadius(rectangle));
599
621
  },
600
622
  getCornerPoints(rectangle) {
601
623
  return RectangleClient.getCornerPoints(rectangle);
602
624
  },
603
625
  getNearestPoint(rectangle, point) {
604
- return getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
626
+ return getNearestPointBetweenPointAndRoundRectangle$1(point, rectangle, getRoundRectangleRadius(rectangle));
605
627
  },
606
628
  getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
607
629
  const corners = RectangleEngine.getCornerPoints(rectangle);
@@ -612,62 +634,237 @@ const RectangleEngine = {
612
634
  return RectangleClient.getEdgeCenterPoints(rectangle);
613
635
  }
614
636
  };
637
+ const getRoundRectangleRadius = (rectangle) => {
638
+ return Math.min(rectangle.width * 0.1, rectangle.height * 0.1);
639
+ };
640
+ function getNearestPointBetweenPointAndRoundRectangle$1(point, rectangle, radius) {
641
+ const { x: rectX, y: rectY, width, height } = rectangle;
642
+ const cornerPoints = RectangleClient.getCornerPoints(rectangle);
643
+ let result = getNearestPointBetweenPointAndSegments(point, cornerPoints);
644
+ let circleCenter = null;
645
+ const inLeftTop = point[0] >= rectX && point[0] <= rectX + radius && point[1] >= rectY && point[1] <= rectY + radius;
646
+ if (inLeftTop) {
647
+ circleCenter = [rectX + radius, rectY + radius];
648
+ }
649
+ const inLeftBottom = point[0] >= rectX && point[0] <= rectX + radius && point[1] >= rectY + height && point[1] <= rectY + height - radius;
650
+ if (inLeftBottom) {
651
+ circleCenter = [rectX + radius, rectY + height - radius];
652
+ }
653
+ const inRightTop = point[0] >= rectX + width - radius && point[0] <= rectX + width && point[1] >= rectY && point[1] <= rectY + radius;
654
+ if (inRightTop) {
655
+ circleCenter = [rectX + width - radius, rectY + radius];
656
+ }
657
+ const inRightBottom = point[0] >= rectX + width - radius &&
658
+ point[0] <= rectX + width &&
659
+ point[1] >= rectY + height - radius &&
660
+ point[1] <= rectY + height;
661
+ if (inRightBottom) {
662
+ circleCenter = [rectX + width - radius, rectY + height - radius];
663
+ }
664
+ if (circleCenter) {
665
+ result = getNearestPointBetweenPointAndEllipse(point, circleCenter, radius, radius);
666
+ }
667
+ return result;
668
+ }
615
669
 
616
- const RightArrowEngine = {
670
+ const heightRatio = 3 / 4;
671
+ const RoundCommentEngine = {
617
672
  draw(board, rectangle, options) {
618
- const points = getRightArrowPoints(rectangle);
619
673
  const rs = PlaitBoard.getRoughSVG(board);
620
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
621
- setStrokeLinecap(polygon, 'round');
622
- return polygon;
623
- },
624
- getCornerPoints(rectangle) {
625
- return getRightArrowPoints(rectangle);
674
+ const x1 = rectangle.x;
675
+ const y1 = rectangle.y;
676
+ const x2 = rectangle.x + rectangle.width;
677
+ const y2 = rectangle.y + rectangle.height * heightRatio;
678
+ const radius = getRoundRectangleRadius(rectangle);
679
+ const point1 = [x1 + radius, y1];
680
+ const point2 = [x2 - radius, y1];
681
+ const point3 = [x2, y1 + radius];
682
+ const point4 = [x2, y2 - radius];
683
+ const point5 = [x2 - radius, y2];
684
+ const point6 = [x1 + radius, y2];
685
+ const point7 = [x1, y2 - radius];
686
+ const point8 = [x1, y1 + radius];
687
+ const point9 = [x1 + rectangle.width / 4, y2];
688
+ const point10 = [x1 + rectangle.width / 4, rectangle.y + rectangle.height];
689
+ const point11 = [x1 + rectangle.width / 2, y2];
690
+ return rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point11[0]} ${point11[1]} ${point10[0]} ${point10[1]} ${point9[0]} ${point9[1]} ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, { ...options, fillStyle: 'solid' });
626
691
  },
627
692
  isHit(rectangle, point) {
628
- const points = getRightArrowPoints(rectangle);
629
- return isPointInPolygon(point, points);
693
+ const points = [
694
+ [rectangle.x + rectangle.width / 4, rectangle.y + (rectangle.height * 3) / 4],
695
+ [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height],
696
+ [rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height * 3) / 4]
697
+ ];
698
+ rectangle.height = (rectangle.height * 3) / 4;
699
+ return isPointInPolygon(point, points) || isPointInRoundRectangle(point, rectangle, getRoundRectangleRadius(rectangle));
700
+ },
701
+ getCornerPoints(rectangle) {
702
+ return getRoundCommentPoints(rectangle);
630
703
  },
631
704
  getNearestPoint(rectangle, point) {
632
- const cornerPoints = getRightArrowPoints(rectangle);
633
- return getNearestPointBetweenPointAndSegments(point, cornerPoints);
705
+ return getNearestPointBetweenPointAndSegments(point, getRoundCommentPoints(rectangle));
634
706
  },
635
707
  getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
636
- const corners = getRightArrowPoints(rectangle);
708
+ const corners = getRoundCommentPoints(rectangle);
637
709
  const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
638
710
  return getEdgeOnPolygonByPoint(corners, point);
639
711
  },
640
712
  getConnectorPoints(rectangle) {
641
713
  return [
642
- [rectangle.x, rectangle.y + rectangle.height / 2],
643
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
714
+ [rectangle.x + rectangle.width / 2, rectangle.y],
715
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
716
+ [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height * heightRatio],
717
+ [rectangle.x, rectangle.y + rectangle.height / 2]
644
718
  ];
719
+ },
720
+ getTextRectangle(element) {
721
+ const elementRectangle = getRectangleByPoints(element.points);
722
+ const strokeWidth = getStrokeWidthByElement(element);
723
+ const height = element.textHeight;
724
+ const width = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
725
+ return {
726
+ height,
727
+ width: width > 0 ? width : 0,
728
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
729
+ y: elementRectangle.y + (elementRectangle.height * heightRatio - height) / 2
730
+ };
645
731
  }
646
732
  };
647
- const getRightArrowPoints = (rectangle) => {
733
+ const getRoundCommentPoints = (rectangle) => {
648
734
  return [
649
- [rectangle.x, rectangle.y + rectangle.height * 0.2],
650
- [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height * 0.2],
651
- [rectangle.x + rectangle.width * 0.68, rectangle.y],
735
+ [rectangle.x, rectangle.y],
736
+ [rectangle.x + rectangle.width, rectangle.y],
737
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height * heightRatio],
738
+ [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height * heightRatio],
739
+ [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height],
740
+ [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height * heightRatio],
741
+ [rectangle.x, rectangle.y + rectangle.height * heightRatio]
742
+ ];
743
+ };
744
+
745
+ const getTrapezoidPoints = (rectangle) => {
746
+ return [
747
+ [rectangle.x + rectangle.width * 0.15, rectangle.y],
748
+ [rectangle.x + rectangle.width * 0.85, rectangle.y],
749
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
750
+ [rectangle.x, rectangle.y + rectangle.height]
751
+ ];
752
+ };
753
+ const TrapezoidEngine = createPolygonEngine({
754
+ getPolygonPoints: getTrapezoidPoints,
755
+ getConnectorPoints(rectangle) {
756
+ const points = getTrapezoidPoints(rectangle);
757
+ return getCenterPointsOnPolygon(points);
758
+ },
759
+ getTextRectangle(element) {
760
+ const rectangle = getTextRectangle(element);
761
+ const width = rectangle.width;
762
+ rectangle.width = (rectangle.width * 3) / 4;
763
+ rectangle.x += width / 8;
764
+ return rectangle;
765
+ }
766
+ });
767
+
768
+ const getTrianglePoints = (rectangle) => {
769
+ return [
770
+ [rectangle.x + rectangle.width / 2, rectangle.y],
771
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
772
+ [rectangle.x, rectangle.y + rectangle.height]
773
+ ];
774
+ };
775
+ const TriangleEngine = createPolygonEngine({
776
+ getPolygonPoints: getTrianglePoints,
777
+ getConnectorPoints(rectangle) {
778
+ const cornerPoints = getTrianglePoints(rectangle);
779
+ const lineCenterPoints = getCenterPointsOnPolygon(cornerPoints);
780
+ return [...lineCenterPoints, ...cornerPoints];
781
+ },
782
+ getTextRectangle(element) {
783
+ const elementRectangle = getRectangleByPoints(element.points);
784
+ const strokeWidth = getStrokeWidthByElement(element);
785
+ const height = element.textHeight;
786
+ const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
787
+ const width = (originWidth * 2) / 3;
788
+ return {
789
+ height,
790
+ width: width > 0 ? width : 0,
791
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
792
+ y: elementRectangle.y + (elementRectangle.height * 3) / 5 + ((elementRectangle.height * 2) / 5 - height) / 2
793
+ };
794
+ }
795
+ });
796
+
797
+ const getTwoWayArrowPoints = (rectangle) => {
798
+ return [
799
+ [rectangle.x, rectangle.y + rectangle.height / 2],
800
+ [rectangle.x + (rectangle.width * 8) / 25, rectangle.y],
801
+ [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + rectangle.height / 5],
802
+ [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + rectangle.height / 5],
803
+ [rectangle.x + (rectangle.width * 17) / 25, rectangle.y],
652
804
  [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
653
- [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height],
654
- [rectangle.x + rectangle.width * 0.68, rectangle.y + rectangle.height * 0.8],
655
- [rectangle.x, rectangle.y + rectangle.height * 0.8]
805
+ [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + rectangle.height],
806
+ [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + (rectangle.height * 4) / 5],
807
+ [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + (rectangle.height * 4) / 5],
808
+ [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + rectangle.height]
809
+ ];
810
+ };
811
+ const TwoWayArrowEngine = createPolygonEngine({
812
+ getPolygonPoints: getTwoWayArrowPoints,
813
+ getConnectorPoints: (rectangle) => {
814
+ return [
815
+ [rectangle.x, rectangle.y + rectangle.height / 2],
816
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
817
+ ];
818
+ }
819
+ });
820
+
821
+ const getStarPoints = (rectangle) => {
822
+ return [
823
+ [rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height * 75) / 91],
824
+ [rectangle.x + (rectangle.width * 18.61) / 96, rectangle.y + rectangle.height],
825
+ [rectangle.x + (rectangle.width * 24.2235871) / 96, rectangle.y + (rectangle.height * 57.7254249) / 91],
826
+ [rectangle.x, rectangle.y + (rectangle.height * 34.5491503) / 91],
827
+ [rectangle.x + (rectangle.width * 33.3053687) / 96, rectangle.y + (rectangle.height * 29.7745751) / 91],
828
+ [rectangle.x + rectangle.width / 2, rectangle.y],
829
+ [rectangle.x + (rectangle.width * 62.6946313) / 96, rectangle.y + (rectangle.height * 29.7745751) / 91],
830
+ [rectangle.x + rectangle.width, rectangle.y + (rectangle.height * 34.5491503) / 91],
831
+ [rectangle.x + (rectangle.width * 71.7764129) / 96, rectangle.y + (rectangle.height * 57.7254249) / 91],
832
+ [rectangle.x + (rectangle.width * 77.3892626) / 96, rectangle.y + rectangle.height]
656
833
  ];
657
834
  };
835
+ const StarEngine = createPolygonEngine({
836
+ getPolygonPoints: getStarPoints,
837
+ getConnectorPoints: (rectangle) => {
838
+ const points = getStarPoints(rectangle);
839
+ return [points[1], points[3], points[5], points[7], points[9]];
840
+ },
841
+ getTextRectangle(element) {
842
+ const elementRectangle = getRectangleByPoints(element.points);
843
+ const strokeWidth = getStrokeWidthByElement(element);
844
+ const height = element.textHeight;
845
+ const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
846
+ const width = originWidth / 2;
847
+ return {
848
+ height,
849
+ width: width > 0 ? width : 0,
850
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 4,
851
+ y: elementRectangle.y + (elementRectangle.height * 1) / 5 + ((elementRectangle.height * 4) / 5 - height) / 2
852
+ };
853
+ }
854
+ });
658
855
 
659
- const RoundRectangleEngine = {
856
+ const TerminalEngine = {
660
857
  draw(board, rectangle, options) {
661
- return drawRoundRectangle(PlaitBoard.getRoughSVG(board), rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height, { ...options, fillStyle: 'solid' }, false, getRoundRectangleRadius(rectangle));
858
+ return drawRoundRectangle(PlaitBoard.getRoughSVG(board), rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height, { ...options, fillStyle: 'solid' }, false, getStartEndRadius(rectangle));
662
859
  },
663
860
  isHit(rectangle, point) {
664
- return isPointInRoundRectangle(point, rectangle, getRoundRectangleRadius(rectangle));
861
+ return isPointInRoundRectangle(point, rectangle, getStartEndRadius(rectangle));
665
862
  },
666
863
  getCornerPoints(rectangle) {
667
864
  return RectangleClient.getCornerPoints(rectangle);
668
865
  },
669
866
  getNearestPoint(rectangle, point) {
670
- return getNearestPointBetweenPointAndRoundRectangle(point, rectangle, getRoundRectangleRadius(rectangle));
867
+ return getNearestPointBetweenPointAndRoundRectangle(point, rectangle, getStartEndRadius(rectangle));
671
868
  },
672
869
  getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
673
870
  const corners = RectangleEngine.getCornerPoints(rectangle);
@@ -678,8 +875,8 @@ const RoundRectangleEngine = {
678
875
  return RectangleClient.getEdgeCenterPoints(rectangle);
679
876
  }
680
877
  };
681
- const getRoundRectangleRadius = (rectangle) => {
682
- return Math.min(rectangle.width * 0.1, rectangle.height * 0.1);
878
+ const getStartEndRadius = (rectangle) => {
879
+ return Math.min(rectangle.width / 2, rectangle.height / 2);
683
880
  };
684
881
  function getNearestPointBetweenPointAndRoundRectangle(point, rectangle, radius) {
685
882
  const { x: rectX, y: rectY, width, height } = rectangle;
@@ -711,57 +908,21 @@ function getNearestPointBetweenPointAndRoundRectangle(point, rectangle, radius)
711
908
  return result;
712
909
  }
713
910
 
714
- const heightRatio = 3 / 4;
715
- const RoundCommentEngine = {
716
- draw(board, rectangle, options) {
717
- const rs = PlaitBoard.getRoughSVG(board);
718
- const x1 = rectangle.x;
719
- const y1 = rectangle.y;
720
- const x2 = rectangle.x + rectangle.width;
721
- const y2 = rectangle.y + rectangle.height * heightRatio;
722
- const radius = getRoundRectangleRadius(rectangle);
723
- const point1 = [x1 + radius, y1];
724
- const point2 = [x2 - radius, y1];
725
- const point3 = [x2, y1 + radius];
726
- const point4 = [x2, y2 - radius];
727
- const point5 = [x2 - radius, y2];
728
- const point6 = [x1 + radius, y2];
729
- const point7 = [x1, y2 - radius];
730
- const point8 = [x1, y1 + radius];
731
- const point9 = [x1 + rectangle.width / 4, y2];
732
- const point10 = [x1 + rectangle.width / 4, rectangle.y + rectangle.height];
733
- const point11 = [x1 + rectangle.width / 2, y2];
734
- return rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point11[0]} ${point11[1]} ${point10[0]} ${point10[1]} ${point9[0]} ${point9[1]} ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, options);
735
- },
736
- isHit(rectangle, point) {
737
- const points = [
738
- [rectangle.x + rectangle.width / 4, rectangle.y + (rectangle.height * 3) / 4],
739
- [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height],
740
- [rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height * 3) / 4]
741
- ];
742
- rectangle.height = (rectangle.height * 3) / 4;
743
- return isPointInPolygon(point, points) || isPointInRoundRectangle(point, rectangle, getRoundRectangleRadius(rectangle));
744
- },
745
- getCornerPoints(rectangle) {
746
- return getRoundCommentPoints(rectangle);
747
- },
748
- getNearestPoint(rectangle, point) {
749
- return getNearestPointBetweenPointAndSegments(point, getRoundCommentPoints(rectangle));
750
- },
751
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
752
- const corners = getRoundCommentPoints(rectangle);
753
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
754
- return getEdgeOnPolygonByPoint(corners, point);
755
- },
756
- getConnectorPoints(rectangle) {
757
- return [
758
- [rectangle.x + rectangle.width / 2, rectangle.y],
759
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
760
- [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height * heightRatio],
761
- [rectangle.x, rectangle.y + rectangle.height / 2]
762
- ];
911
+ const getManualInputPoints = (rectangle) => {
912
+ return [
913
+ [rectangle.x, rectangle.y + rectangle.height / 4],
914
+ [rectangle.x + rectangle.width, rectangle.y],
915
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
916
+ [rectangle.x, rectangle.y + rectangle.height]
917
+ ];
918
+ };
919
+ const ManualInputEngine = createPolygonEngine({
920
+ getPolygonPoints: getManualInputPoints,
921
+ getConnectorPoints: (rectangle) => {
922
+ const cornerPoints = getManualInputPoints(rectangle);
923
+ return getCenterPointsOnPolygon(cornerPoints);
763
924
  },
764
- getTextRectangle(element) {
925
+ getTextRectangle: (element) => {
765
926
  const elementRectangle = getRectangleByPoints(element.points);
766
927
  const strokeWidth = getStrokeWidthByElement(element);
767
928
  const height = element.textHeight;
@@ -770,208 +931,231 @@ const RoundCommentEngine = {
770
931
  height,
771
932
  width: width > 0 ? width : 0,
772
933
  x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth,
773
- y: elementRectangle.y + (elementRectangle.height * heightRatio - height) / 2
934
+ y: elementRectangle.y + elementRectangle.height / 4 + ((elementRectangle.height * 3) / 4 - height) / 2
774
935
  };
775
936
  }
776
- };
777
- const getRoundCommentPoints = (rectangle) => {
937
+ });
938
+
939
+ const getPreparationPoints = (rectangle) => {
778
940
  return [
779
- [rectangle.x, rectangle.y],
780
- [rectangle.x + rectangle.width, rectangle.y],
781
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height * heightRatio],
782
- [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height * heightRatio],
783
- [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height],
784
- [rectangle.x + rectangle.width / 4, rectangle.y + rectangle.height * heightRatio],
785
- [rectangle.x, rectangle.y + rectangle.height * heightRatio]
941
+ [rectangle.x, rectangle.y + rectangle.height / 2],
942
+ [rectangle.x + rectangle.width / 6, rectangle.y],
943
+ [rectangle.x + (rectangle.width * 5) / 6, rectangle.y],
944
+ [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
945
+ [rectangle.x + (rectangle.width * 5) / 6, rectangle.y + rectangle.height],
946
+ [rectangle.x + rectangle.width / 6, rectangle.y + rectangle.height]
786
947
  ];
787
948
  };
788
-
789
- const StarEngine = {
790
- draw(board, rectangle, options) {
791
- const points = getStarPoints(rectangle);
792
- const rs = PlaitBoard.getRoughSVG(board);
793
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
794
- setStrokeLinecap(polygon, 'round');
795
- return polygon;
796
- },
797
- isHit(rectangle, point) {
798
- const parallelogramPoints = getStarPoints(rectangle);
799
- return isPointInPolygon(point, parallelogramPoints);
800
- },
801
- getCornerPoints(rectangle) {
802
- return getStarPoints(rectangle);
803
- },
804
- getNearestPoint(rectangle, point) {
805
- return getNearestPointBetweenPointAndSegments(point, getStarPoints(rectangle));
806
- },
807
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
808
- const corners = getStarPoints(rectangle);
809
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
810
- return getEdgeOnPolygonByPoint(corners, point);
949
+ const PreparationEngine = createPolygonEngine({
950
+ getPolygonPoints: getPreparationPoints,
951
+ getConnectorPoints: (rectangle) => {
952
+ return RectangleClient.getEdgeCenterPoints(rectangle);
811
953
  },
812
- getConnectorPoints(rectangle) {
813
- const points = getStarPoints(rectangle);
814
- return [points[1], points[3], points[5], points[7], points[9]];
954
+ getTextRectangle(element) {
955
+ const rectangle = getTextRectangle(element);
956
+ const width = rectangle.width;
957
+ rectangle.width = (rectangle.width * 2) / 3;
958
+ rectangle.x += width / 6;
959
+ return rectangle;
815
960
  }
816
- };
817
- const getStarPoints = (rectangle) => {
961
+ });
962
+
963
+ const getManualLoopPoints = (rectangle) => {
818
964
  return [
819
- [rectangle.x + rectangle.width / 2, rectangle.y + (rectangle.height * 75) / 91],
820
- [rectangle.x + (rectangle.width * 18.61) / 96, rectangle.y + rectangle.height],
821
- [rectangle.x + (rectangle.width * 24.2235871) / 96, rectangle.y + (rectangle.height * 57.7254249) / 91],
822
- [rectangle.x, rectangle.y + (rectangle.height * 34.5491503) / 91],
823
- [rectangle.x + (rectangle.width * 33.3053687) / 96, rectangle.y + (rectangle.height * 29.7745751) / 91],
824
- [rectangle.x + rectangle.width / 2, rectangle.y],
825
- [rectangle.x + (rectangle.width * 62.6946313) / 96, rectangle.y + (rectangle.height * 29.7745751) / 91],
826
- [rectangle.x + rectangle.width, rectangle.y + (rectangle.height * 34.5491503) / 91],
827
- [rectangle.x + (rectangle.width * 71.7764129) / 96, rectangle.y + (rectangle.height * 57.7254249) / 91],
828
- [rectangle.x + (rectangle.width * 77.3892626) / 96, rectangle.y + rectangle.height]
965
+ [rectangle.x, rectangle.y],
966
+ [rectangle.x + rectangle.width, rectangle.y],
967
+ [rectangle.x + (rectangle.width * 7) / 8, rectangle.y + rectangle.height],
968
+ [rectangle.x + rectangle.width / 8, rectangle.y + rectangle.height]
829
969
  ];
830
970
  };
831
-
832
- const TrapezoidEngine = {
833
- draw(board, rectangle, options) {
834
- const points = getTrapezoidPoints(rectangle);
835
- const rs = PlaitBoard.getRoughSVG(board);
836
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
837
- setStrokeLinecap(polygon, 'round');
838
- return polygon;
839
- },
840
- isHit(rectangle, point) {
841
- const points = getTrapezoidPoints(rectangle);
842
- return isPointInPolygon(point, points);
843
- },
844
- getNearestPoint(rectangle, point) {
845
- const cornerPoints = getTrapezoidPoints(rectangle);
846
- return getNearestPointBetweenPointAndSegments(point, cornerPoints);
847
- },
848
- getConnectorPoints(rectangle) {
849
- const points = getTrapezoidPoints(rectangle);
850
- return getCenterPointsOnPolygon(points);
851
- },
852
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
853
- const corners = getTrapezoidPoints(rectangle);
854
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
855
- return getEdgeOnPolygonByPoint(corners, point);
971
+ const ManualLoopEngine = createPolygonEngine({
972
+ getPolygonPoints: getManualLoopPoints,
973
+ getConnectorPoints: (rectangle) => {
974
+ const cornerPoints = getManualLoopPoints(rectangle);
975
+ return getCenterPointsOnPolygon(cornerPoints);
856
976
  },
857
- getCornerPoints(rectangle) {
858
- return getTrapezoidPoints(rectangle);
977
+ getTextRectangle(element) {
978
+ const rectangle = getTextRectangle(element);
979
+ const width = rectangle.width;
980
+ rectangle.width = (rectangle.width * 3) / 4;
981
+ rectangle.x += width / 8;
982
+ return rectangle;
859
983
  }
860
- };
861
- const getTrapezoidPoints = (rectangle) => {
984
+ });
985
+
986
+ const getMergePoints = (rectangle) => {
862
987
  return [
863
- [rectangle.x + rectangle.width * 0.15, rectangle.y],
864
- [rectangle.x + rectangle.width * 0.85, rectangle.y],
865
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
866
- [rectangle.x, rectangle.y + rectangle.height]
988
+ [rectangle.x, rectangle.y],
989
+ [rectangle.x + rectangle.width, rectangle.y],
990
+ [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height]
867
991
  ];
868
992
  };
993
+ const MergeEngine = createPolygonEngine({
994
+ getPolygonPoints: getMergePoints,
995
+ getConnectorPoints: (rectangle) => {
996
+ const cornerPoints = getMergePoints(rectangle);
997
+ const lineCenterPoints = getCenterPointsOnPolygon(cornerPoints);
998
+ return [...lineCenterPoints, ...cornerPoints];
999
+ },
1000
+ getTextRectangle(element) {
1001
+ const elementRectangle = getRectangleByPoints(element.points);
1002
+ const strokeWidth = getStrokeWidthByElement(element);
1003
+ const height = element.textHeight;
1004
+ const originWidth = elementRectangle.width - ShapeDefaultSpace.rectangleAndText * 2 - strokeWidth * 2;
1005
+ const width = (originWidth * 2) / 3;
1006
+ return {
1007
+ height,
1008
+ width: width > 0 ? width : 0,
1009
+ x: elementRectangle.x + ShapeDefaultSpace.rectangleAndText + strokeWidth + originWidth / 6,
1010
+ y: elementRectangle.y + ((elementRectangle.height * 2) / 3 - height) / 2
1011
+ };
1012
+ }
1013
+ });
869
1014
 
870
- const TriangleEngine = {
1015
+ const DelayEngine = {
871
1016
  draw(board, rectangle, options) {
872
- const points = getTrianglePoints(rectangle);
873
1017
  const rs = PlaitBoard.getRoughSVG(board);
874
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
875
- setStrokeLinecap(polygon, 'round');
876
- return polygon;
1018
+ const shape = rs.path(`M${rectangle.x} ${rectangle.y} L${rectangle.x + (rectangle.width * 3) / 4} ${rectangle.y} A ${rectangle.width /
1019
+ 4} ${rectangle.height / 2}, 0, 0, 1,${rectangle.x + (rectangle.width * 3) / 4} ${rectangle.y + rectangle.height} L${rectangle.x} ${rectangle.y + rectangle.height} Z`, { ...options, fillStyle: 'solid' });
1020
+ setStrokeLinecap(shape, 'round');
1021
+ return shape;
877
1022
  },
878
1023
  isHit(rectangle, point) {
879
- const points = getTrianglePoints(rectangle);
880
- return isPointInPolygon(point, points);
1024
+ //split shape to rectangle and a half ellipse
1025
+ const rangeRectangle = RectangleClient.toRectangleClient([point, point]);
1026
+ const isInRectangle = RectangleClient.isHit({
1027
+ ...rectangle,
1028
+ width: (rectangle.width * 3) / 4
1029
+ }, rangeRectangle);
1030
+ const isInEllipse = isPointInEllipse(point, [rectangle.x + (rectangle.width * 3) / 4, rectangle.y + rectangle.height / 2], rectangle.width / 4, rectangle.height / 2);
1031
+ return isInRectangle || isInEllipse;
881
1032
  },
882
- getNearestPoint(rectangle, point) {
883
- const cornerPoints = getTrianglePoints(rectangle);
884
- return getNearestPointBetweenPointAndSegments(point, cornerPoints);
1033
+ getCornerPoints(rectangle) {
1034
+ return RectangleClient.getCornerPoints(rectangle);
885
1035
  },
886
- getConnectorPoints(rectangle) {
887
- const cornerPoints = getTrianglePoints(rectangle);
888
- const lineCenterPoints = getCenterPointsOnPolygon(cornerPoints);
889
- return [...lineCenterPoints, ...cornerPoints];
1036
+ getNearestPoint(rectangle, point) {
1037
+ const nearestPoint = getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
1038
+ if (nearestPoint[0] > rectangle.x + (rectangle.width * 3) / 4) {
1039
+ return getNearestPointBetweenPointAndEllipse(point, [rectangle.x + (rectangle.width * 3) / 4, rectangle.y + rectangle.height / 2], rectangle.width / 4, rectangle.height / 2);
1040
+ }
1041
+ return nearestPoint;
890
1042
  },
891
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
892
- const corners = getTrianglePoints(rectangle);
893
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
894
- return getEdgeOnPolygonByPoint(corners, point);
1043
+ getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
1044
+ const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
1045
+ const centerPoint = [rectangle.x + (rectangle.width * 3) / 4, rectangle.y + rectangle.height / 2];
1046
+ const point = [connectionPoint[0] - centerPoint[0], -(connectionPoint[1] - centerPoint[1])];
1047
+ const a = rectangle.width / 4;
1048
+ const b = rectangle.height / 2;
1049
+ const slope = getTangentSlope(point[0], point[1], a, b);
1050
+ return getVectorBySlope(point[0], point[1], slope);
895
1051
  },
896
- getCornerPoints(rectangle) {
897
- return getTrianglePoints(rectangle);
1052
+ getConnectorPoints(rectangle) {
1053
+ return RectangleClient.getEdgeCenterPoints(rectangle);
898
1054
  }
899
1055
  };
900
- const getTrianglePoints = (rectangle) => {
901
- return [
902
- [rectangle.x + rectangle.width / 2, rectangle.y],
903
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height],
904
- [rectangle.x, rectangle.y + rectangle.height]
905
- ];
906
- };
907
1056
 
908
- const TwoWayArrowEngine = {
1057
+ const StoredDataEngine = {
909
1058
  draw(board, rectangle, options) {
910
- const points = getTwoWayArrowPoints(rectangle);
911
1059
  const rs = PlaitBoard.getRoughSVG(board);
912
- const polygon = rs.polygon(points, { ...options, fillStyle: 'solid' });
913
- setStrokeLinecap(polygon, 'round');
914
- return polygon;
915
- },
916
- getCornerPoints(rectangle) {
917
- return getTwoWayArrowPoints(rectangle);
1060
+ const shape = rs.path(`M${rectangle.x + rectangle.width / 10} ${rectangle.y} L${rectangle.x + rectangle.width} ${rectangle.y} A ${rectangle.width /
1061
+ 10} ${rectangle.height / 2}, 1, 0, 0,${rectangle.x + rectangle.width} ${rectangle.y + rectangle.height} L${rectangle.x +
1062
+ rectangle.width / 10} ${rectangle.y + rectangle.height}A ${rectangle.width / 10} ${rectangle.height /
1063
+ 2}, 0, 0, 1,${rectangle.x + rectangle.width / 10} ${rectangle.y}`, { ...options, fillStyle: 'solid' });
1064
+ setStrokeLinecap(shape, 'round');
1065
+ return shape;
918
1066
  },
919
1067
  isHit(rectangle, point) {
920
- const points = getTwoWayArrowPoints(rectangle);
921
- return isPointInPolygon(point, points);
1068
+ //split shape to rectangle and a half ellipse
1069
+ const rangeRectangle = RectangleClient.toRectangleClient([point, point]);
1070
+ const isInRectangle = RectangleClient.isHit({
1071
+ ...rectangle,
1072
+ x: rectangle.x + rectangle.width / 10,
1073
+ width: (rectangle.width * 9) / 10
1074
+ }, rangeRectangle);
1075
+ const isInFrontEllipse = isPointInEllipse(point, [rectangle.x + rectangle.width / 10, rectangle.y + rectangle.height / 2], rectangle.width / 10, rectangle.height / 2);
1076
+ const notInBackEllipse = !isPointInEllipse(point, [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2], rectangle.width / 10, rectangle.height / 2);
1077
+ return (isInRectangle && notInBackEllipse) || isInFrontEllipse;
1078
+ },
1079
+ getCornerPoints(rectangle) {
1080
+ return RectangleClient.getCornerPoints(rectangle);
922
1081
  },
923
1082
  getNearestPoint(rectangle, point) {
924
- const cornerPoints = getTwoWayArrowPoints(rectangle);
925
- return getNearestPointBetweenPointAndSegments(point, cornerPoints);
1083
+ const nearestPoint = getNearestPointBetweenPointAndSegments(point, RectangleEngine.getCornerPoints(rectangle));
1084
+ if (nearestPoint[0] < rectangle.x + rectangle.width / 10) {
1085
+ const nearestPoint = getNearestPointBetweenPointAndEllipse(point, [rectangle.x + rectangle.width / 10, rectangle.y + rectangle.height / 2], rectangle.width / 10, rectangle.height / 2);
1086
+ if (nearestPoint[0] > rectangle.x + rectangle.width / 10) {
1087
+ nearestPoint[0] = (rectangle.x + rectangle.width / 10) * 2 - nearestPoint[0];
1088
+ }
1089
+ return nearestPoint;
1090
+ }
1091
+ if (nearestPoint[0] > rectangle.x + (rectangle.width * 9) / 10) {
1092
+ return getNearestPointBetweenPointAndEllipse(point, [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2], rectangle.width / 10, rectangle.height / 2);
1093
+ }
1094
+ return nearestPoint;
926
1095
  },
927
- getEdgeByConnectionPoint(rectangle, pointOfRectangle) {
928
- const corners = getTwoWayArrowPoints(rectangle);
929
- const point = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
930
- return getEdgeOnPolygonByPoint(corners, point);
1096
+ getTangentVectorByConnectionPoint(rectangle, pointOfRectangle) {
1097
+ const connectionPoint = RectangleClient.getConnectionPoint(rectangle, pointOfRectangle);
1098
+ let centerPoint = [rectangle.x + rectangle.width / 10, rectangle.y + rectangle.height / 2];
1099
+ let a = rectangle.width / 10;
1100
+ let b = rectangle.height / 2;
1101
+ const isBackEllipse = connectionPoint[0] > rectangle.x + (rectangle.width * 9) / 10 && connectionPoint[1] > rectangle.y;
1102
+ if (isBackEllipse) {
1103
+ centerPoint = [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2];
1104
+ }
1105
+ const point = [connectionPoint[0] - centerPoint[0], -(connectionPoint[1] - centerPoint[1])];
1106
+ const slope = getTangentSlope(point[0], point[1], a, b);
1107
+ const vector = getVectorBySlope(point[0], point[1], slope);
1108
+ return isBackEllipse ? vector.map(num => -num) : vector;
931
1109
  },
932
1110
  getConnectorPoints(rectangle) {
933
1111
  return [
934
- [rectangle.x, rectangle.y + rectangle.height / 2],
935
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2]
1112
+ [rectangle.x + rectangle.width / 2, rectangle.y],
1113
+ [rectangle.x + (rectangle.width * 9) / 10, rectangle.y + rectangle.height / 2],
1114
+ [rectangle.x + rectangle.width / 2, rectangle.y + rectangle.height],
1115
+ [rectangle.x, rectangle.y + rectangle.height / 2]
936
1116
  ];
1117
+ },
1118
+ getTextRectangle(element) {
1119
+ const rectangle = getTextRectangle(element);
1120
+ const width = rectangle.width;
1121
+ rectangle.width = (rectangle.width * 3) / 4;
1122
+ rectangle.x += width / 8;
1123
+ return rectangle;
937
1124
  }
938
1125
  };
939
- const getTwoWayArrowPoints = (rectangle) => {
940
- return [
941
- [rectangle.x, rectangle.y + rectangle.height / 2],
942
- [rectangle.x + (rectangle.width * 8) / 25, rectangle.y],
943
- [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + rectangle.height / 5],
944
- [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + rectangle.height / 5],
945
- [rectangle.x + (rectangle.width * 17) / 25, rectangle.y],
946
- [rectangle.x + rectangle.width, rectangle.y + rectangle.height / 2],
947
- [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + rectangle.height],
948
- [rectangle.x + (rectangle.width * 17) / 25, rectangle.y + (rectangle.height * 4) / 5],
949
- [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + (rectangle.height * 4) / 5],
950
- [rectangle.x + (rectangle.width * 8) / 25, rectangle.y + rectangle.height]
951
- ];
952
- };
953
1126
 
954
1127
  const ShapeEngineMap = {
955
- [GeometryShape.rectangle]: RectangleEngine,
956
- [GeometryShape.diamond]: DiamondEngine,
957
- [GeometryShape.ellipse]: EllipseEngine,
958
- [GeometryShape.parallelogram]: ParallelogramEngine,
959
- [GeometryShape.roundRectangle]: RoundRectangleEngine,
960
- [GeometryShape.text]: RectangleEngine,
961
- [GeometryShape.triangle]: TriangleEngine,
962
- [GeometryShape.leftArrow]: LeftArrowEngine,
963
- [GeometryShape.trapezoid]: TrapezoidEngine,
964
- [GeometryShape.rightArrow]: RightArrowEngine,
965
- [GeometryShape.cross]: CrossEngine,
966
- [GeometryShape.star]: StarEngine,
967
- [GeometryShape.pentagon]: PentagonEngine,
968
- [GeometryShape.hexagon]: HexagonEngine,
969
- [GeometryShape.octagon]: OctagonEngine,
970
- [GeometryShape.pentagonArrow]: PentagonArrowEngine,
971
- [GeometryShape.processArrow]: ProcessArrowEngine,
972
- [GeometryShape.twoWayArrow]: TwoWayArrowEngine,
973
- [GeometryShape.comment]: CommentEngine,
974
- [GeometryShape.roundComment]: RoundCommentEngine
1128
+ [BasicShapes.rectangle]: RectangleEngine,
1129
+ [BasicShapes.diamond]: DiamondEngine,
1130
+ [BasicShapes.ellipse]: EllipseEngine,
1131
+ [BasicShapes.parallelogram]: ParallelogramEngine,
1132
+ [BasicShapes.roundRectangle]: RoundRectangleEngine,
1133
+ [BasicShapes.text]: RectangleEngine,
1134
+ [BasicShapes.triangle]: TriangleEngine,
1135
+ [BasicShapes.leftArrow]: LeftArrowEngine,
1136
+ [BasicShapes.trapezoid]: TrapezoidEngine,
1137
+ [BasicShapes.rightArrow]: RightArrowEngine,
1138
+ [BasicShapes.cross]: CrossEngine,
1139
+ [BasicShapes.star]: StarEngine,
1140
+ [BasicShapes.pentagon]: PentagonEngine,
1141
+ [BasicShapes.hexagon]: HexagonEngine,
1142
+ [BasicShapes.octagon]: OctagonEngine,
1143
+ [BasicShapes.pentagonArrow]: PentagonArrowEngine,
1144
+ [BasicShapes.processArrow]: ProcessArrowEngine,
1145
+ [BasicShapes.twoWayArrow]: TwoWayArrowEngine,
1146
+ [BasicShapes.comment]: CommentEngine,
1147
+ [BasicShapes.roundComment]: RoundCommentEngine,
1148
+ [FlowchartSymbols.process]: RectangleEngine,
1149
+ [FlowchartSymbols.decision]: DiamondEngine,
1150
+ [FlowchartSymbols.connector]: EllipseEngine,
1151
+ [FlowchartSymbols.data]: ParallelogramEngine,
1152
+ [FlowchartSymbols.terminal]: TerminalEngine,
1153
+ [FlowchartSymbols.manualInput]: ManualInputEngine,
1154
+ [FlowchartSymbols.preparation]: PreparationEngine,
1155
+ [FlowchartSymbols.manualLoop]: ManualLoopEngine,
1156
+ [FlowchartSymbols.merge]: MergeEngine,
1157
+ [FlowchartSymbols.delay]: DelayEngine,
1158
+ [FlowchartSymbols.storedData]: StoredDataEngine
975
1159
  };
976
1160
  const getEngine = (shape) => {
977
1161
  return ShapeEngineMap[shape];
@@ -979,7 +1163,7 @@ const getEngine = (shape) => {
979
1163
 
980
1164
  const getShape = (value) => {
981
1165
  if (PlaitDrawElement.isImage(value)) {
982
- return GeometryShape.rectangle;
1166
+ return BasicShapes.rectangle;
983
1167
  }
984
1168
  return value.shape;
985
1169
  };
@@ -987,10 +1171,14 @@ const getShape = (value) => {
987
1171
  const createGeometryElement = (shape, points, text, options) => {
988
1172
  let textOptions = {};
989
1173
  let alignment = Alignment.center;
990
- if (shape === GeometryShape.text) {
1174
+ if (shape === BasicShapes.text) {
991
1175
  textOptions = { autoSize: true };
992
1176
  alignment = undefined;
993
1177
  }
1178
+ let flowchartOptions = {};
1179
+ if (getFlowchartPointers().includes(shape)) {
1180
+ flowchartOptions = { fill: '#ffffff' };
1181
+ }
994
1182
  return {
995
1183
  id: idCreator(),
996
1184
  type: 'geometry',
@@ -1001,7 +1189,8 @@ const createGeometryElement = (shape, points, text, options) => {
1001
1189
  text: buildText(text, alignment),
1002
1190
  points,
1003
1191
  ...textOptions,
1004
- ...options
1192
+ ...options,
1193
+ ...flowchartOptions
1005
1194
  };
1006
1195
  };
1007
1196
  const getPointsByCenterPoint = (point, width, height) => {
@@ -1073,6 +1262,9 @@ const getEdgeOnPolygonByPoint = (corners, point) => {
1073
1262
  }
1074
1263
  return null;
1075
1264
  };
1265
+ const getDefaultFlowchartProperty = (symbol) => {
1266
+ return DefaultFlowchartPropertyMap[symbol];
1267
+ };
1076
1268
 
1077
1269
  const drawLineArrow = (element, points, options) => {
1078
1270
  const arrowG = createG();
@@ -1112,11 +1304,11 @@ const getArrow = (element, arrowOptions, options) => {
1112
1304
  break;
1113
1305
  }
1114
1306
  case LineMarkerType.oneSideUp: {
1115
- targetArrow = drawOneSideArrow(source, target, 'up', options);
1307
+ targetArrow = drawOneSideArrow(source, target, isSource ? 'down' : 'up', options);
1116
1308
  break;
1117
1309
  }
1118
1310
  case LineMarkerType.oneSideDown: {
1119
- targetArrow = drawOneSideArrow(source, target, 'down', options);
1311
+ targetArrow = drawOneSideArrow(source, target, isSource ? 'up' : 'down', options);
1120
1312
  break;
1121
1313
  }
1122
1314
  case LineMarkerType.hollowTriangle: {
@@ -1593,7 +1785,7 @@ const PlaitDrawElement = {
1593
1785
  return value.type === 'line';
1594
1786
  },
1595
1787
  isText: (value) => {
1596
- return value.type === 'geometry' && value.shape === GeometryShape.text;
1788
+ return value.type === 'geometry' && value.shape === BasicShapes.text;
1597
1789
  },
1598
1790
  isImage: (value) => {
1599
1791
  return value.type === 'image';
@@ -1608,6 +1800,12 @@ const PlaitDrawElement = {
1608
1800
  },
1609
1801
  isShape: (value) => {
1610
1802
  return PlaitDrawElement.isImage(value) || PlaitDrawElement.isGeometry(value);
1803
+ },
1804
+ isBaseShape: (value) => {
1805
+ return Object.keys(BasicShapes).includes(value.type);
1806
+ },
1807
+ isFlowchart: (value) => {
1808
+ return Object.keys(FlowchartSymbols).includes(value.type);
1611
1809
  }
1612
1810
  };
1613
1811
 
@@ -1618,7 +1816,7 @@ class GeometryShapeGenerator extends Generator {
1618
1816
  baseDraw(element, data) {
1619
1817
  const rectangle = getRectangleByPoints(element.points);
1620
1818
  const shape = element.shape;
1621
- if (shape === GeometryShape.text) {
1819
+ if (shape === BasicShapes.text) {
1622
1820
  return;
1623
1821
  }
1624
1822
  const strokeWidth = getStrokeWidthByElement(element);
@@ -1636,15 +1834,15 @@ class GeometryShapeGenerator extends Generator {
1636
1834
 
1637
1835
  const insertGeometry = (board, points, shape) => {
1638
1836
  let newElement = createGeometryElement(shape, points, '', {
1639
- strokeColor: DefaultGeometryProperty.strokeColor,
1640
- strokeWidth: DefaultGeometryProperty.strokeWidth
1837
+ strokeColor: DefaultBasicShapeProperty.strokeColor,
1838
+ strokeWidth: DefaultBasicShapeProperty.strokeWidth
1641
1839
  });
1642
1840
  Transforms.insertNode(board, newElement, [board.children.length]);
1643
1841
  clearSelectedElement(board);
1644
1842
  addSelectedElement(board, newElement);
1645
1843
  };
1646
1844
  const insertText = (board, points, text = '文本') => {
1647
- let newElement = createGeometryElement(GeometryShape.text, points, text);
1845
+ let newElement = createGeometryElement(BasicShapes.text, points, text);
1648
1846
  Transforms.insertNode(board, newElement, [board.children.length]);
1649
1847
  clearSelectedElement(board);
1650
1848
  addSelectedElement(board, newElement);
@@ -1864,7 +2062,11 @@ class GeometryComponent extends CommonPluginElement {
1864
2062
  }
1865
2063
  },
1866
2064
  getMaxWidth: () => {
1867
- const width = getTextRectangle(this.element).width;
2065
+ let width = getTextRectangle(this.element).width;
2066
+ const getRectangle = getEngine(this.element.shape).getTextRectangle;
2067
+ if (getRectangle) {
2068
+ width = getRectangle(this.element).width;
2069
+ }
1868
2070
  return this.element?.autoSize ? GeometryThreshold.defaultTextMaxWidth : width;
1869
2071
  },
1870
2072
  textPlugins: plugins
@@ -1877,10 +2079,10 @@ class GeometryComponent extends CommonPluginElement {
1877
2079
  this.destroy$.next();
1878
2080
  this.destroy$.complete();
1879
2081
  }
1880
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: GeometryComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
1881
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.3", type: GeometryComponent, isStandalone: true, selector: "plait-draw-geometry", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2082
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GeometryComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2083
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: GeometryComponent, isStandalone: true, selector: "plait-draw-geometry", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1882
2084
  }
1883
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: GeometryComponent, decorators: [{
2085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GeometryComponent, decorators: [{
1884
2086
  type: Component,
1885
2087
  args: [{
1886
2088
  selector: 'plait-draw-geometry',
@@ -2118,10 +2320,10 @@ class LineComponent extends PlaitPluginElementComponent {
2118
2320
  this.destroy$.next();
2119
2321
  this.destroy$.complete();
2120
2322
  }
2121
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: LineComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2122
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.3", type: LineComponent, isStandalone: true, selector: "plait-draw-line", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2323
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2324
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: LineComponent, isStandalone: true, selector: "plait-draw-line", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2123
2325
  }
2124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: LineComponent, decorators: [{
2326
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LineComponent, decorators: [{
2125
2327
  type: Component,
2126
2328
  args: [{
2127
2329
  selector: 'plait-draw-line',
@@ -2174,15 +2376,15 @@ const withGeometryCreateByDrag = (board) => {
2174
2376
  const pointer = PlaitBoard.getPointer(board);
2175
2377
  if (dragMode) {
2176
2378
  const points = getDefaultGeometryPoints(pointer, movingPoint);
2177
- if (pointer === GeometryShape.text) {
2379
+ if (pointer === BasicShapes.text) {
2178
2380
  const textG = getTemporaryTextG(movingPoint);
2179
2381
  geometryShapeG.appendChild(textG);
2180
2382
  PlaitBoard.getElementActiveHost(board).append(geometryShapeG);
2181
2383
  }
2182
2384
  else {
2183
2385
  const temporaryElement = createGeometryElement(pointer, points, '', {
2184
- strokeColor: DefaultGeometryProperty.strokeColor,
2185
- strokeWidth: DefaultGeometryProperty.strokeWidth
2386
+ strokeColor: DefaultBasicShapeProperty.strokeColor,
2387
+ strokeWidth: DefaultBasicShapeProperty.strokeWidth
2186
2388
  });
2187
2389
  geometryGenerator.draw(temporaryElement, geometryShapeG);
2188
2390
  PlaitBoard.getElementActiveHost(board).append(geometryShapeG);
@@ -2198,7 +2400,7 @@ const withGeometryCreateByDrag = (board) => {
2198
2400
  if (dragMode) {
2199
2401
  const targetPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
2200
2402
  const points = getDefaultGeometryPoints(pointer, targetPoint);
2201
- if (pointer === GeometryShape.text) {
2403
+ if (pointer === BasicShapes.text) {
2202
2404
  DrawTransforms.insertText(board, points);
2203
2405
  }
2204
2406
  else {
@@ -2235,9 +2437,9 @@ const withGeometryCreateByDrawing = (board) => {
2235
2437
  start = point;
2236
2438
  const pointer = PlaitBoard.getPointer(board);
2237
2439
  preventTouchMove(board, event, true);
2238
- if (pointer === GeometryShape.text) {
2440
+ if (pointer === BasicShapes.text) {
2239
2441
  const points = getDefaultGeometryPoints(pointer, point);
2240
- const textElement = createGeometryElement(GeometryShape.text, points, DefaultTextProperty.text);
2442
+ const textElement = createGeometryElement(BasicShapes.text, points, DefaultTextProperty.text);
2241
2443
  Transforms.insertNode(board, textElement, [board.children.length]);
2242
2444
  clearSelectedElement(board);
2243
2445
  addSelectedElement(board, textElement);
@@ -2254,11 +2456,11 @@ const withGeometryCreateByDrawing = (board) => {
2254
2456
  const drawMode = !!start;
2255
2457
  const movingPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
2256
2458
  const pointer = PlaitBoard.getPointer(board);
2257
- if (drawMode && pointer !== GeometryShape.text) {
2459
+ if (drawMode && pointer !== BasicShapes.text) {
2258
2460
  const points = normalizeShapePoints([start, movingPoint], isShift);
2259
2461
  temporaryElement = createGeometryElement(pointer, points, '', {
2260
- strokeColor: DefaultGeometryProperty.strokeColor,
2261
- strokeWidth: DefaultGeometryProperty.strokeWidth
2462
+ strokeColor: DefaultBasicShapeProperty.strokeColor,
2463
+ strokeWidth: DefaultBasicShapeProperty.strokeWidth
2262
2464
  });
2263
2465
  geometryGenerator.draw(temporaryElement, geometryShapeG);
2264
2466
  PlaitBoard.getElementActiveHost(board).append(geometryShapeG);
@@ -2273,10 +2475,10 @@ const withGeometryCreateByDrawing = (board) => {
2273
2475
  if (Math.hypot(width, height) === 0) {
2274
2476
  const pointer = PlaitBoard.getPointer(board);
2275
2477
  const points = getDefaultGeometryPoints(pointer, targetPoint);
2276
- if (pointer !== GeometryShape.text) {
2478
+ if (pointer !== BasicShapes.text) {
2277
2479
  temporaryElement = createGeometryElement(pointer, points, '', {
2278
- strokeColor: DefaultGeometryProperty.strokeColor,
2279
- strokeWidth: DefaultGeometryProperty.strokeWidth
2480
+ strokeColor: DefaultBasicShapeProperty.strokeColor,
2481
+ strokeWidth: DefaultBasicShapeProperty.strokeWidth
2280
2482
  });
2281
2483
  }
2282
2484
  }
@@ -2297,9 +2499,21 @@ const withGeometryCreateByDrawing = (board) => {
2297
2499
  return board;
2298
2500
  };
2299
2501
  const getDefaultGeometryPoints = (pointer, targetPoint) => {
2300
- return pointer === GeometryShape.text
2301
- ? getPointsByCenterPoint(targetPoint, DefaultTextProperty.width, DefaultTextProperty.height)
2302
- : getPointsByCenterPoint(targetPoint, DefaultGeometryProperty.width, DefaultGeometryProperty.height);
2502
+ const defaultProperty = getGeometryDefaultProperty(pointer);
2503
+ return getPointsByCenterPoint(targetPoint, defaultProperty.width, defaultProperty.height);
2504
+ };
2505
+ const getGeometryDefaultProperty = (pointer) => {
2506
+ const isText = pointer === BasicShapes.text;
2507
+ const isFlowChart = getFlowchartPointers().includes(pointer);
2508
+ if (isText) {
2509
+ return DefaultTextProperty;
2510
+ }
2511
+ else if (isFlowChart) {
2512
+ return getDefaultFlowchartProperty(pointer);
2513
+ }
2514
+ else {
2515
+ return DefaultBasicShapeProperty;
2516
+ }
2303
2517
  };
2304
2518
  const getTemporaryTextG = (movingPoint) => {
2305
2519
  const textG = createG();
@@ -2836,10 +3050,10 @@ class ImageComponent extends CommonPluginElement {
2836
3050
  this.destroy$.complete();
2837
3051
  this.imageGenerator.destroy();
2838
3052
  }
2839
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ImageComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
2840
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.3", type: ImageComponent, isStandalone: true, selector: "plait-draw-geometry", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3053
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ImageComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
3054
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ImageComponent, isStandalone: true, selector: "plait-draw-geometry", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2841
3055
  }
2842
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ImageComponent, decorators: [{
3056
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ImageComponent, decorators: [{
2843
3057
  type: Component,
2844
3058
  args: [{
2845
3059
  selector: 'plait-draw-geometry',
@@ -2938,5 +3152,5 @@ const withDraw = (board) => {
2938
3152
  * Generated bundle index. Do not edit.
2939
3153
  */
2940
3154
 
2941
- export { DEFAULT_IMAGE_WIDTH, DefaultGeometryActiveStyle, DefaultGeometryProperty, DefaultGeometryStyle, DefaultTextProperty, DrawTransforms, GeometryComponent, GeometryShape, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, ShapeDefaultSpace, StrokeStyle, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getEdgeOnPolygonByPoint, getElbowPoints, getExtendPoint, getFillByElement, getGeometryPointers, getHitConnectorPoint, getHitLineTextIndex, getLineDashByElement, getLineHandleRefPair, getLinePointers, getLinePoints, getLineTextRectangle, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTextRectangle, getVectorByConnection, isHitLineText, isHitPolyLine, removeDuplicatePoints, transformOpsToPoints, transformPointToConnection, withDraw };
3155
+ export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultBasicShapeProperty, DefaultConnectorProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultGeometryActiveStyle, DefaultGeometryStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultTextProperty, DrawTransforms, FlowchartSymbols, GeometryComponent, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, ShapeDefaultSpace, StrokeStyle, createGeometryElement, createLineElement, drawBoundMask, drawGeometry, drawLine, getBasicPointers, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultFlowchartProperty, getEdgeOnPolygonByPoint, getElbowPoints, getExtendPoint, getFillByElement, getFlowchartPointers, getGeometryPointers, getHitConnectorPoint, getHitLineTextIndex, getLineDashByElement, getLineHandleRefPair, getLinePointers, getLinePoints, getLineTextRectangle, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTextRectangle, getVectorByConnection, isHitLineText, isHitPolyLine, removeDuplicatePoints, transformOpsToPoints, transformPointToConnection, withDraw };
2942
3156
  //# sourceMappingURL=plait-draw.mjs.map