01 - A ray between two points

Drag the ring to reposition the source. The cross marks the destination and follows the pointer.

castTo(startX, startY, endX, endY, options)
Casts a ray from (startX, startY) to (endX, endY) and returns the nearest object or tile that blocks it as a RayHit.

It returns null if the ray reaches its destination without hitting anything.
options.ignoreInside makes the ray ignore geometry that contains its starting point.

each(originX, originY, directionX, directionY, maxDistance, callback, options)
Walks along the ray and calls the callback once for every cell it reaches, including empty cells.
Returning false from the callback stops the traversal early.