Class Bresenham2


  • public class Bresenham2
    extends java.lang.Object
    Returns a list of points at integer coordinates for a line on a 2D grid, using the Bresenham algorithm.

    Instances of this class own the returned array of points and the points themselves to avoid garbage collection as much as possible. Calling any of the methods will result in the reuse of the previously returned array and vectors, expect

    • Constructor Detail

      • Bresenham2

        public Bresenham2()
    • Method Detail

      • line

        public Array<GridPoint2> line​(GridPoint2 start,
                                      GridPoint2 end)
        Returns a list of GridPoint2 instances along the given line, at integer coordinates.
        Parameters:
        start - the start of the line
        end - the end of the line
        Returns:
        the list of points on the line at integer coordinates
      • line

        public Array<GridPoint2> line​(int startX,
                                      int startY,
                                      int endX,
                                      int endY)
        Returns a list of GridPoint2 instances along the given line, at integer coordinates.
        Parameters:
        startX - the start x coordinate of the line
        startY - the start y coordinate of the line
        endX - the end x coordinate of the line
        endY - the end y coordinate of the line
        Returns:
        the list of points on the line at integer coordinates
      • line

        public Array<GridPoint2> line​(int startX,
                                      int startY,
                                      int endX,
                                      int endY,
                                      Pool<GridPoint2> pool,
                                      Array<GridPoint2> output)
        Returns a list of GridPoint2 instances along the given line, at integer coordinates.
        Parameters:
        startX - the start x coordinate of the line
        startY - the start y coordinate of the line
        endX - the end x coordinate of the line
        endY - the end y coordinate of the line
        pool - the pool from which GridPoint2 instances are fetched
        output - the output array, will be cleared in this method
        Returns:
        the list of points on the line at integer coordinates