API Reference › Grid › Grid.line
method

Grid.line

Grid.line(x0, y0, x1, y1) -> []Cell

Returns the cells a straight line from (x0, y0) to (x1, y1) passes through, endpoints included, using integer Bresenham — the basis of line-of-sight, ray-casting, and drawing on the grid.

Example

program Demo {
  handler H phase Update {
    let cells = Grid.line(0, 0, 5, 3)
    print(len(cells))
  }
}
← All symbols