connectionOffset method

Offset connectionOffset(
  1. Size portSize
)

Returns the offset from port's top-left to the connection attachment point.

Connections attach at the port's outer edge (the edge aligned with the node boundary):

  • Left port: left edge, vertically centered
  • Right port: right edge, vertically centered
  • Top port: horizontally centered, top edge
  • Bottom port: horizontally centered, bottom edge
Left port:     Right port:    Top port:      Bottom port:
●───┐          ┌───●          ──●──          ┌───┐
│   │          │   │          │   │          │   │
└───┘          └───┘          └───┘          ──●──

Implementation

Offset connectionOffset(Size portSize) {
  return switch (this) {
    PortPosition.left => Offset(0, portSize.height / 2),
    PortPosition.right => Offset(portSize.width, portSize.height / 2),
    PortPosition.top => Offset(portSize.width / 2, 0),
    PortPosition.bottom => Offset(portSize.width / 2, portSize.height),
  };
}