Purpose: A class that rasterizes two-dimensional line segements, triangles, and convex polygons.
About the System: This class will be used by itself and by a 3D renderer (and, perhaps, other classes).
Details
Constants:
public static final int SCAN_LINE = 0; public static final int POINTWISE = 1;
The Explicit Value Constructor:
/** * Explicit Value Constructor * * @param fb The FrameBuffer containing the pixels */ public Rasterizer2D(FrameBuffer fb)
The clear() Method:
/** * Fill the entire FrameBuffer with the given color */ public void clear(Color c)
The drawLine() Method:
/** * Draw the line segment connecting two points * * @param color The Color * @param p One point * @param q The other point */ public void drawLine(Color color, double[] p, double[] q)
This method must use either the DDA algorithm, the mid-point algorithm, Bresenham's algorithm, or the parametric form algorithm.
The drawPolygon() Method:
/** * Draw the edges of a polygon * * * @param color The Color to use * @param r The vertices of the polygon */ public void drawPolygon(Color c, double[]... r)
This method must call the drawLine()
method
iteratively.
The fillPolygon() Method:
/** * Fill the polygon defined by the vertices in r * * @param color The Color to use * @param r The vertices of the polygon */ public void fillPolygon(Color color, double[]... r)
This method must call pointwiseFillPolygon()
if the current fill technique is POINTWISE
and
must do nothing otherwise.
The fillTriangle() Method:
/** * Fill the triangle defined by the vertices in r * * @param color The Color to use * @param r The vertices of the triangle */ public void fillTriangle(Color color, double[]... r)
This method must call pointwiseFillTriangle()
if the current fill technique is POINTWISE
and
must do nothing otherwise.
The setFillTechnique() Method:
/** * Set the fill technique to use * * @param fillTechnique Either SCAN_LINE or POINTWISE */ public void setFillTechnique(int fillTechnique)
This method must update the current fill technique (which is used by the fill methods).
The pointwiseFillPolygon() Method:
/** * Fill a polygon by testing all of the points * in its bounding rectangle * * @param color The Color to use * @param r The vertices of the polygon */ public void pointwiseFillPolygon(Color color, double[]... r)
This method must use the halfspace test algorithm.
The pointwiseFillTriangle() Method:
/** * Fill a triangle point-by-point in the given color * * @param color The color to use * @param r The vertices of the triangle */ public void pointwiseFillTriangle(Color color, double[]... r)
This method must use the signed area algorithm
Copyright 2007