Class FillPixer

  • All Implemented Interfaces:
    Pixer

    public class FillPixer
    extends java.lang.Object
    implements Pixer
    Pixer that iterates over all points inside a polygon. Should handle all polygons (convex, concave, re-entrant). I think(?) the algorithm is about as efficient as it's going to get for a single-threaded implementation. Memory consumption is low.
    Since:
    6 Oct 2021
    Author:
    Mark Taylor
    See Also:
    https://alienryderflex.com/polygon_fill/
    • Constructor Summary

      Constructors 
      Constructor Description
      FillPixer​(int[] xs, int[] ys, int np, java.awt.Rectangle bounds)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getX()
      Returns the X coordinate of the current point.
      int getY()
      Returns the Y coordinate of the current point.
      boolean next()
      Advances to the next point to be dispensed by this iterator.
      • Methods inherited from class java.lang.Object

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

      • FillPixer

        public FillPixer​(int[] xs,
                         int[] ys,
                         int np,
                         java.awt.Rectangle bounds)
        Constructor.
        Parameters:
        xs - np-element array giving graphics X vertex coordinates
        ys - np-element array giving graphics Y vertex coordinates
        np - number of vertices
        bounds - actual bounds within which pixels are required, or null for all pixels
    • Method Detail

      • next

        public boolean next()
        Description copied from interface: Pixer
        Advances to the next point to be dispensed by this iterator. Must be called before any calls to getX/getY.
        Specified by:
        next in interface Pixer
        Returns:
        true iff there is another point
      • getX

        public int getX()
        Description copied from interface: Pixer
        Returns the X coordinate of the current point.
        Specified by:
        getX in interface Pixer
        Returns:
        X coordinate
      • getY

        public int getY()
        Description copied from interface: Pixer
        Returns the Y coordinate of the current point.
        Specified by:
        getY in interface Pixer
        Returns:
        Y coordinate