APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.math

public Class Bresenham2

extends Object
Class Inheritance
Imports
com.badlogic.gdx.utils.Array, .Pool

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

Author
badlogic

Field Summary

Modifier and TypeField and Description
private final Array<GridPoint2>
private final Pool<GridPoint2>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Array<GridPoint2>

Returns:

the list of points on the line at integer coordinates
line
(GridPoint2
the start of the line
start
,
GridPoint2
the end of the line
end
)

Returns a list of GridPoint2 instances along the given line, at integer coordinates.

public Array<GridPoint2>

Returns:

the list of points on the line at integer coordinates
line
(int
the start x coordinate of the line
startX
,
int
the start y coordinate of the line
startY
,
int
the end x coordinate of the line
endX
,
int
the end y coordinate of the line
endY
)

Returns a list of GridPoint2 instances along the given line, at integer coordinates.

public Array<GridPoint2>

Returns:

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

Returns a list of GridPoint2 instances along the given line, at integer coordinates.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pointsback to summary
private final Array<GridPoint2> points
poolback to summary
private final Pool<GridPoint2> pool

Constructor Detail

Bresenham2back to summary
public Bresenham2()

Method Detail

lineback to summary
public Array<GridPoint2> line(GridPoint2 start, GridPoint2 end)

Returns a list of GridPoint2 instances along the given line, at integer coordinates.

Parameters
start:GridPoint2

the start of the line

end:GridPoint2

the end of the line

Returns:Array<GridPoint2>

the list of points on the line at integer coordinates

lineback to summary
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:int

the start x coordinate of the line

startY:int

the start y coordinate of the line

endX:int

the end x coordinate of the line

endY:int

the end y coordinate of the line

Returns:Array<GridPoint2>

the list of points on the line at integer coordinates

lineback to summary
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:int

the start x coordinate of the line

startY:int

the start y coordinate of the line

endX:int

the end x coordinate of the line

endY:int

the end y coordinate of the line

pool:Pool<GridPoint2>

the pool from which GridPoint2 instances are fetched

output:Array<GridPoint2>

the output array, will be cleared in this method

Returns:Array<GridPoint2>

the list of points on the line at integer coordinates