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.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry 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
OnNodeDragis raised on every pointer move of a drag with the node being dragged, andOnNodeDragStoponce it ends; the tests run there.GetIntersectingNodes(node, partially)returns the other nodes whose rectangles overlap that node's, the node itself left out. Withpartially: falseit returns only those lying entirely within it.GetIntersectingNodes(BlowRect area, partially)does the same against any flow-space rectangle - here the zone, anew BlowRect(x, y, width, height).IsNodeIntersecting(node, area, partially)tests a single node: true when it overlaps the area, or withpartially: falsewhen it lies entirely inside it. It lights the zone.partiallydefaults totruein all three. A node's rectangle is its position and its size -WidthandHeightwhere set, otherwise what was measured - and hidden nodes are skipped.OnNodesInitializedfills the zone list once every node has been measured.BlowViewportPortaldraws the zone inside the zoomed layer, positioned in flow coordinates.