Package squidpony.squidmath
Class DDALine
java.lang.Object
squidpony.squidmath.DDALine
public class DDALine extends Object
A fixed-point line-drawing algorithm that should have good performance; may be useful for LOS.
Algorithm is from https://hbfs.wordpress.com/2009/07/28/faster-than-bresenhams-algorithm/
Created by Tommy Ettinger on 1/10/2016.
-
Constructor Summary
Constructors Constructor Description DDALine()
-
Method Summary
Modifier and Type Method Description static List<Coord>
line(int startX, int startY, int endX, int endY)
Draws a line from (startX, startY) to (endX, endY) using the DDA algorithm.static List<Coord>
line(int startX, int startY, int endX, int endY, int modifierX, int modifierY)
Not intended for external use; prefer the overloads without a modifier argument.static List<Coord>
line(Coord start, Coord end)
Draws a line from start to end using the DDA algorithm.static Coord[]
line_(int startX, int startY, int endX, int endY)
Draws a line from (startX, startY) to (endX, endY) using the DDA algorithm.static Coord[]
line_(int startX, int startY, int endX, int endY, int modifierX, int modifierY)
Not intended for external use; prefer the overloads without a modifier argument.static Coord[]
line_(Coord start, Coord end)
Draws a line from start to end using the DDA algorithm.
-
Constructor Details
-
Method Details
-
line
Draws a line from (startX, startY) to (endX, endY) using the DDA algorithm. Returns a List of Coord in order.- Parameters:
startX
- x of starting pointstartY
- y of starting pointendX
- x of ending pointendY
- y of ending point- Returns:
- List of Coord, including (startX, startY) and (endX, endY) and all points walked between
-
line
public static List<Coord> line(int startX, int startY, int endX, int endY, int modifierX, int modifierY)Not intended for external use; prefer the overloads without a modifier argument.- Parameters:
startX
- x of starting pointstartY
- y of starting pointendX
- x of ending pointendY
- y of ending pointmodifierX
- an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfffmodifierY
- an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfff- Returns:
- List of Coord, including (startX, startY) and (endX, endY) and all points walked between
-
line
Draws a line from start to end using the DDA algorithm. Returns a List of Coord in order.- Parameters:
start
- starting pointend
- ending point- Returns:
- List of Coord, including start and end and all points walked between
-
line_
Draws a line from (startX, startY) to (endX, endY) using the DDA algorithm. Returns an array of Coord in order.- Parameters:
startX
- x of starting pointstartY
- y of starting pointendX
- x of ending pointendY
- y of ending point- Returns:
- array of Coord, including (startX, startY) and (endX, endY) and all points walked between
-
line_
public static Coord[] line_(int startX, int startY, int endX, int endY, int modifierX, int modifierY)Not intended for external use; prefer the overloads without a modifier argument.- Parameters:
startX
- x of starting pointstartY
- y of starting pointendX
- x of ending pointendY
- y of ending pointmodifierX
- an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfffmodifierY
- an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfff- Returns:
- array of Coord, including (startX, startY) and (endX, endY) and all points walked between
-
line_
Draws a line from start to end using the DDA algorithm. Returns an array of Coord in order.- Parameters:
start
- starting pointend
- ending point- Returns:
- array of Coord, including start and end and all points walked between
-