Class ShadedTriangle

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

class ShadedTriangle extends Object
This is an assistant class for accomplishing type 4, 5, 6 and 7 shading. It describes a triangle actually, which is used to compose a patch. It contains the degenerated cases, a triangle degenerates to a line or to a point. This was done as part of GSoC2014, Tilman Hausherr is the mentor.
  • Field Details

    • corner

      protected final Point2D[] corner
    • color

      protected final float[][] color
    • area

      private final double area
    • degree

      private final int degree
    • line

      private final Line line
    • v0

      private final double v0
    • v1

      private final double v1
    • v2

      private final double v2
  • Constructor Details

    • ShadedTriangle

      ShadedTriangle(Point2D[] p, float[][] c)
      Constructor.
      Parameters:
      p - an array of the 3 vertices of a triangle; the Point2D objects should not be modified by the caller.
      c - an array of color corresponding the vertex array p
  • Method Details

    • calcDeg

      private int calcDeg(Point2D[] p)
      Calculate the degree value of a triangle.
      Parameters:
      p - 3 vertices coordinates
      Returns:
      number of unique points in the 3 vertices of a triangle, 3, 2 or 1
    • getDeg

      public int getDeg()
    • getBoundary

      public int[] getBoundary()
      get the boundary of a triangle.
      Returns:
      {xmin, xmax, ymin, ymax}
    • getLine

      public Line getLine()
      Get the line of a triangle.
      Returns:
      points of the line, or null if this triangle isn't a line
    • contains

      public boolean contains(Point2D p)
      Whether a point is contained in this ShadedTriangle.
      Parameters:
      p - the target point
      Returns:
      false if p is outside of this triangle, otherwise true
    • overlaps

      private boolean overlaps(Point2D p0, Point2D p1)
    • edgeEquationValue

      private double edgeEquationValue(Point2D p, Point2D p1, Point2D p2)
    • getArea

      private double getArea(Point2D a, Point2D b, Point2D c)
    • calcColor

      public float[] calcColor(Point2D p)
      Calculate the color of a point.
      Parameters:
      p - the target point
      Returns:
      an array denotes the point's color
    • toString

      public String toString()
      Overrides:
      toString in class Object