public class Line extends AbstractCoordinateShape
A 3D line segment with perspective-correct width and alpha blending.

This class represents a line between two 3D points, rendered with a specified width that adjusts based on perspective (distance from the viewer). The line is drawn using interpolators to handle edge cases and alpha blending for transparency effects.

The rendering algorithm: 1. For thin lines (below a threshold), draws single-pixel lines with alpha adjustment based on perspective. 2. For thicker lines, creates four interpolators to define the line's rectangular area and fills it scanline by scanline.

Note: The width is scaled by the LINE_WIDTH_MULTIPLIER and adjusted based on the distance from the viewer (z-coordinate) to maintain a consistent visual size.

  • Field Details

    • width

      public final double width
      width of the line.
    • color

      public Color color
      Color of the line.
  • Constructor Details

    • Line

      public Line(Line parentLine)
    • Line

      public Line(Point3D point1, Point3D point2, Color color, double width)
  • Method Details

    • paint

      public void paint(RenderingContext buffer)
      Description copied from class: AbstractCoordinateShape
      Paints this shape onto the rendering context's pixel buffer.

      This method is called after all shapes have been transformed and sorted by depth. Implementations should use the transformed screen-space coordinates from Vertex.transformedCoordinate to draw pixels.

      Specified by:
      paint in class AbstractCoordinateShape
      Parameters:
      buffer - the rendering context containing the pixel buffer and graphics context