Skip to main content

edge_path_cells

Function edge_path_cells 

Source
pub fn edge_path_cells(a: TreeCoord, b: TreeCoord) -> Vec<(i32, i32)>
Expand description

Cells along the rendered edge between two nodes, in canonical lo→hi lot order (lex on (x, y)). Returns an empty Vec if either endpoint has no node.

Canonical direction is load-bearing: bresenham_path(A, B) and bresenham_path(B, A) produce DIFFERENT cell sequences for the same endpoints, so we sort the inputs here. Pre-buy and post-buy rendering, plus the unlock-anim’s completion check, all call this function with the same pair of lots — without canonicalization the wave would energize a different staircase shape from the grey base line, and you’d see the path geometry flip the moment the wave started.

The case-split mirrors ui::tree::draw_edge:

  • boxes vertically aligned within ±2 columns → straight vertical run at the midpoint x.
  • boxes horizontally aligned within ±2 rows → straight horizontal run at the midpoint y.
  • otherwise → Bresenham staircase between the two centers.