Skip to content

Function: cellInDirection() ​

ts
function cellInDirection(
   layout, 
   from, 
   direction, 
   accept?
): Cell | undefined;

The cell to move to from from in a direction, for arrow-key navigation over any tiling.

Looks at cells whose center lies ahead (within 60° of the direction first, then anywhere ahead) and picks the nearest, with sideways distance counting double, so moving keeps to a "row" or "column" where the tiling has one. accept limits it to some cells (those with content, say). Returns undefined at the edge.

Parameters ​

ParameterType
layoutLayout
fromCell
directionDirection
accept(cell) => boolean

Returns ​

Cell | undefined

Hat tiling and isohedral tilings after Craig S. Kaplan's hatviz and Tactile (BSD 3-Clause).