public class SolidPolygon extends AbstractCoordinateShape
A solid-color triangle renderer with mouse interaction support.

This class implements a high-performance triangle rasterizer using scanline algorithms. It handles: - Perspective-correct edge interpolation - Alpha blending with background pixels - Viewport clipping - Mouse hover detection via point-in-polygon tests - Optional flat shading based on light sources

The static drawPolygon method is designed for reuse by other polygon types.

  • Constructor Details

  • Method Details

    • drawHorizontalLine

      public static void drawHorizontalLine(LineInterpolator line1, LineInterpolator line2, int y, RenderingContext renderBuffer, Color color)
    • drawPolygon

      public static void drawPolygon(RenderingContext context, Point2D onScreenPoint1, Point2D onScreenPoint2, Point2D onScreenPoint3, MouseInteractionController mouseInteractionController, Color color)
    • getColor

      public Color getColor()
    • setColor

      public void setColor(Color color)
    • getLightingManager

      public LightingManager getLightingManager()
      Returns the lighting manager used for shading calculations.
      Returns:
      the lighting manager, or null if shading is not enabled
    • isShadingEnabled

      public boolean isShadingEnabled()
      Checks if shading is enabled for this polygon.
      Returns:
      true if shading is enabled, false otherwise
    • setShadingEnabled

      public void setShadingEnabled(boolean shadingEnabled, LightingManager lightingManager)
      Enables or disables shading for this polygon.
      Parameters:
      shadingEnabled - true to enable shading, false to disable
      lightingManager - the lighting manager to use for shading calculations
    • isBackfaceCullingEnabled

      public boolean isBackfaceCullingEnabled()
    • setBackfaceCulling

      public void setBackfaceCulling(boolean backfaceCulling)
    • paint

      public void paint(RenderingContext renderBuffer)
      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:
      renderBuffer - the rendering context containing the pixel buffer and graphics context