@@ -31,7 +31,7 @@ import { intersectionCircleLine } from './utils/vector-math';
3131export const MIN_RADIUS = 150 ;
3232export const CLOSE_DISTANCE_THRESHOLD = 0.75 ; // Multiplier for the smallest rectangle dimension
3333
34- export class ArcConnection < T extends BaseNodeInfo > extends Connection < T > {
34+ export class LineConnection < T extends BaseNodeInfo > extends Connection < T > {
3535 startPointElement : IThumbNodeComponent < T > | undefined ;
3636 endPointElement : IThumbNodeComponent < T > | undefined ;
3737
@@ -344,10 +344,22 @@ export class ArcConnection<T extends BaseNodeInfo> extends Connection<T> {
344344 const x2 = this . points . endX + endOffsetX ;
345345 const y2 = this . points . endY + endOffsetY ;
346346
347- const path = this . getLinePath (
347+ // const path = this.getLinePath(
348+ // { x: 0, y: 0 },
349+ // startOffsetX,
350+ // startOffsetY,
351+ // x1,
352+ // y1,
353+ // x2,
354+ // y2
355+ // );
356+
357+ const path = this . getArc (
348358 { x : 0 , y : 0 } ,
349359 startOffsetX ,
350360 startOffsetY ,
361+ 1 ,
362+ 1 ,
351363 x1 ,
352364 y1 ,
353365 x2 ,
@@ -372,10 +384,21 @@ export class ArcConnection<T extends BaseNodeInfo> extends Connection<T> {
372384 const y1 = this . points . beginY - bbox . y + startOffsetY ;
373385 const x2 = this . points . endX - bbox . x + endOffsetX ;
374386 const y2 = this . points . endY - bbox . y + endOffsetY ;
375- const path = this . getLinePath (
387+ // const path = this.getLinePath(
388+ // bbox,
389+ // startOffsetX,
390+ // startOffsetY,
391+ // x1,
392+ // y1,
393+ // x2,
394+ // y2
395+ // );
396+ const path = this . getArc (
376397 bbox ,
377398 startOffsetX ,
378399 startOffsetY ,
400+ 1 ,
401+ 1 ,
379402 x1 ,
380403 y1 ,
381404 x2 ,
@@ -389,32 +412,52 @@ export class ArcConnection<T extends BaseNodeInfo> extends Connection<T> {
389412 ) ;
390413 }
391414
392- protected updateArrow ( factor = 1 , factor2 = 1 ) {
415+ protected getArc (
416+ bbox : { x : number ; y : number } ,
417+ startOffsetX : number ,
418+ startOffsetY : number ,
419+ factor = 1 ,
420+ factor2 = 1 ,
421+ x1 : number ,
422+ y1 : number ,
423+ x2 : number ,
424+ y2 : number
425+ ) {
426+ const spacingAABB = 10 ;
427+
393428 const startNode = this . nodeComponent ?. startNode ;
394429 const endNode = this . nodeComponent ?. endNode ;
395- const halfStartWidth = startNode ?. width ? startNode . width / 2 : 0 ;
396- const halfStartHeight = startNode ?. height ? startNode . height / 2 : 0 ;
397- const halfEndWidth = endNode ?. width ? endNode . width / 2 : 0 ;
398- const halfEndHeight = endNode ?. height ? endNode . height / 2 : 0 ;
399-
400- const startX = this . points . beginX ;
401- const startY = this . points . beginY ;
402- const endX = this . points . endX ;
403- const endY = this . points . endY ;
404-
405- const startWidth = startNode ?. width ?? 0 ;
406- const startHeight = startNode ?. height ?? 0 ;
407- const endWidth = endNode ?. width ?? 0 ;
408- const endHeight = endNode ?. height ?? 0 ;
430+ const halfStartWidth = startNode ?. width ? startNode . width / 2 : 50 ;
431+ const halfStartHeight = startNode ?. height ? startNode . height / 2 : 50 ;
432+ const halfEndWidth = endNode ?. width ? endNode . width / 2 : 50 ;
433+ const halfEndHeight = endNode ?. height ? endNode . height / 2 : 50 ;
434+
435+ const startX = startNode
436+ ? ( startNode ?. x ?? 0 ) - bbox . x + startOffsetX - spacingAABB
437+ : x1 ;
438+ const startY = startNode
439+ ? ( startNode ?. y ?? 0 ) - bbox . y + startOffsetY - spacingAABB
440+ : y1 ;
441+ const endX = endNode
442+ ? ( endNode ?. x ?? 0 ) - bbox . x + startOffsetX + spacingAABB * 2
443+ : x2 ;
444+ const endY = endNode
445+ ? ( endNode ?. y ?? 0 ) - bbox . y + startOffsetY + spacingAABB * 2
446+ : y2 ;
447+
448+ const startWidth = startNode ?. width ?? 100 ;
449+ const startHeight = startNode ?. height ?? 100 ;
450+ const endWidth = endNode ?. width ?? 100 ;
451+ const endHeight = endNode ?. height ?? 100 ;
409452
410453 const start = {
411- x : this . points . beginX + halfStartWidth ,
412- y : this . points . beginY + halfStartHeight ,
454+ x : startX + halfStartWidth ,
455+ y : startY + halfStartHeight ,
413456 } ;
414457
415458 const end = {
416- x : this . points . endX + halfEndWidth ,
417- y : this . points . endY + halfEndHeight ,
459+ x : endX + halfEndWidth ,
460+ y : endY + halfEndHeight ,
418461 } ;
419462
420463 // Check if rectangles are overlapping or very close
@@ -561,7 +604,7 @@ export class ArcConnection<T extends BaseNodeInfo> extends Connection<T> {
561604 const controlX = ( startX + endX ) / 2 ;
562605 const controlY = ( startY + endY ) / 2 ;
563606 //canvas.updateControlPoint(controlX, controlY);
564- const d = `M ${ startX } ${ startY } L ${ endX } ${ endY } ` ;
607+ return `M ${ startX } ${ startY } L ${ endX } ${ endY } ` ;
565608 //canvas.updateTestArcPath(d);
566609 } else {
567610 //canvas.updateControlPoint(controlX, controlY);
@@ -576,18 +619,20 @@ export class ArcConnection<T extends BaseNodeInfo> extends Connection<T> {
576619 bestIntersection2 . y
577620 } `;
578621 //canvas.updateTestArcPath(d);
622+ return d ;
579623 }
580624
581- const finalSweepFlag = isOverlapping ? 1 : angleDiff > 0 ? 1 : 0 ;
582- const finalLargeArcFlag = isOverlapping
583- ? 0
584- : radius < 150
585- ? 0 // Force small arc for small radii
586- : isLargeArc ( bestIntersection1 , bestIntersection2 , centerX , centerY )
587- ? 1
588- : 0 ;
625+ // const finalSweepFlag = isOverlapping ? 1 : angleDiff > 0 ? 1 : 0;
626+ // const finalLargeArcFlag = isOverlapping
627+ // ? 0
628+ // : radius < 150
629+ // ? 0 // Force small arc for small radii
630+ // : isLargeArc(bestIntersection1, bestIntersection2, centerX, centerY)
631+ // ? 1
632+ // : 0;
589633 } else {
590634 //canvas.updateTestArcPath('');
635+ return '' ;
591636 }
592637
593638 //canvas.updateIntersectionPoints([...intersections1, ...intersections2]);
0 commit comments