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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • line

      public 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. Returns a List of Coord in order.
      Parameters:
      startX - x of starting point
      startY - y of starting point
      endX - x of ending point
      endY - 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 point
      startY - y of starting point
      endX - x of ending point
      endY - y of ending point
      modifierX - an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfff
      modifierY - 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

      public static List<Coord> line​(Coord start, Coord end)
      Draws a line from start to end using the DDA algorithm. Returns a List of Coord in order.
      Parameters:
      start - starting point
      end - ending point
      Returns:
      List of Coord, including start and end and all points walked between
    • line_

      public static Coord[] line_​(int startX, int startY, int endX, int endY)
      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 point
      startY - y of starting point
      endX - x of ending point
      endY - 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 point
      startY - y of starting point
      endX - x of ending point
      endY - y of ending point
      modifierX - an integer that should typically be one of 0x3fff, 0x7fff, or 0xbfff
      modifierY - 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_

      public static Coord[] line_​(Coord start, Coord end)
      Draws a line from start to end using the DDA algorithm. Returns an array of Coord in order.
      Parameters:
      start - starting point
      end - ending point
      Returns:
      array of Coord, including start and end and all points walked between