java.lang.Object
org.apache.pdfbox.pdmodel.graphics.shading.Line

class Line extends Object
This class describes a rasterized line. This was done as part of GSoC2014, Tilman Hausherr is the mentor.
  • Field Details

    • point0

      private final Point point0
    • point1

      private final Point point1
    • color0

      private final float[] color0
    • color1

      private final float[] color1
    • linePoints

      protected final Set<Point> linePoints
  • Constructor Details

    • Line

      Line(Point p0, Point p1, float[] c0, float[] c1)
      Constructor of class Line.
      Parameters:
      p0 - one end of a line
      p1 - the other end of the line
      c0 - color of point p0
      c1 - color of point p1
  • Method Details

    • calcLine

      private Set<Point> calcLine(int x0, int y0, int x1, int y1)
      Calculate the points of a line with Bresenham's line algorithm Bresenham's line algorithm
      Parameters:
      x0 - coordinate
      y0 - coordinate
      x1 - coordinate
      y1 - coordinate
      Returns:
      all the points on the rasterized line from (x0, y0) to (x1, y1)
    • calcColor

      protected float[] calcColor(Point p)
      Calculate the color of a point on a rasterized line by linear interpolation.
      Parameters:
      p - target point, p should always be contained in linePoints
      Returns:
      color