Skip to content

Intersection

Collision tests for nodes: GetIntersectingNodes finds the nodes a dragged node overlaps, or the nodes inside any rectangle, and IsNodeIntersecting tests one node against a rectangle. Drag nodes onto each other and into the dashed zone to see both - the building blocks of drop targets, snapping a node into a group, or keeping nodes apart.

Overlapping the dragged node: none · In the zone: none
Drag me
A
B
C
D
Zone
bit Blow

Try it

  • Drag the large Drag me node over A, B or C: every node it overlaps turns orange while you drag, and the toolbar names them.
  • Drag any node into the dashed zone: the zone lights up while the dragged node touches it, and the toolbar lists every node inside it. D starts there.
  • Untick Partial overlap counts: now only a node lying entirely within counts - cover a small node completely with Drag me to colour it, and push a node all the way into the zone to light it.
  • Let go: the orange clears, and the zone list keeps the result.

How it works

  • OnNodeDrag is raised on every pointer move of a drag with the node being dragged, and OnNodeDragStop once it ends; the tests run there.
  • GetIntersectingNodes(node, partially) returns the other nodes whose rectangles overlap that node's, the node itself left out. With partially: false it returns only those lying entirely within it.
  • GetIntersectingNodes(BlowRect area, partially) does the same against any flow-space rectangle - here the zone, a new BlowRect(x, y, width, height).
  • IsNodeIntersecting(node, area, partially) tests a single node: true when it overlaps the area, or with partially: false when it lies entirely inside it. It lights the zone.
  • partially defaults to true in all three. A node's rectangle is its position and its size - Width and Height where set, otherwise what was measured - and hidden nodes are skipped.
  • OnNodesInitialized fills the zone list once every node has been measured. BlowViewportPortal draws the zone inside the zoomed layer, positioned in flow coordinates.
An unhandled error has occurred. Reload 🗙