CS488 PA6
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Rasterizer2D Class Reference

#include <Rasterizer2D.h>

Public Member Functions

 Rasterizer2D (FrameBuffer *fb)
 
void clear (const Color &color)
 
void drawLine (const Matrix< 2, 1 > &p, const Matrix< 2, 1 > &q, const Color &color)
 
void drawPoint (int x, int y, const Color &color)
 
void drawPoint (const Matrix< 2, 1 > &point, const Color &color)
 
void drawQuadrilateral (const Matrix< 2, 4 > &quad, const Color &color)
 
void drawTriangle (const Matrix< 2, 3 > &triangle, const Color &color)
 
void fillQuadrilateral (const Matrix< 2, 4 > &quad, const Color &color)
 
void fillTriangle (const Matrix< 2, 3 > &triangle, const Color &color)
 
void pointwiseFillQuadrilateral (const Matrix< 2, 4 > &quad, const Color &color)
 
void pointwiseFillTriangle (const Matrix< 2, 3 > &triangle, const Color &color)
 

Static Public Attributes

static const int SCAN_LINE = 0
 
static const int POINTWISE = 1
 

Private Attributes

FrameBufferfb
 
int fillTechnique
 

Detailed Description

An encapsulation of objects that can render various 2-D shapes.

Note: Since we don't need to transform points, they are in Cartesian (rather than homogeneous) coordinates and stored in a Matrix<2, 1> (i.e., a 2-element column vector which is the same as a Vector<2>).

Constructor & Destructor Documentation

◆ Rasterizer2D()

Rasterizer2D::Rasterizer2D ( FrameBuffer fb)
explicit

Explicit Value Constructor.

Parameters
fbA pointer to the FrameBuffer to use

Member Function Documentation

◆ clear()

void Rasterizer2D::clear ( const Color color)

Fill the entire FrameBuffer with the given color.

Parameters
colorThe Color to use

◆ drawLine()

void Rasterizer2D::drawLine ( const Matrix< 2, 1 > &  p,
const Matrix< 2, 1 > &  q,
const Color color 
)

Draw a line using the (non-incremental) parametric approach.

Parameters
pOne end point
qThe other end point
colorThe color to use

◆ drawPoint() [1/2]

void Rasterizer2D::drawPoint ( int  x,
int  y,
const Color color 
)

Set the color of a single pixel.

Parameters
xThe horizontal coordinate
yThe vertical coordinate
colorThe Color to use

◆ drawPoint() [2/2]

void Rasterizer2D::drawPoint ( const Matrix< 2, 1 > &  point,
const Color color 
)

Set the color of a single pixel.

Parameters
pointThe point
colorThe Color to use

◆ drawQuadrilateral()

void Rasterizer2D::drawQuadrilateral ( const Matrix< 2, 4 > &  quad,
const Color color 
)

Draw the edges of a quadrilateral.

Parameters
quadThe vertices of the quadrilateral
colorThe color to use

◆ drawTriangle()

void Rasterizer2D::drawTriangle ( const Matrix< 2, 3 > &  triangle,
const Color color 
)

Draw the edges of a triangle.

Parameters
triangleThe vertices of the triangle
colorThe color to use

◆ fillQuadrilateral()

void Rasterizer2D::fillQuadrilateral ( const Matrix< 2, 4 > &  quad,
const Color color 
)

Fill a quadrilateral.

Parameters
quadThe vertices of the quadrilateral
colorThe color to use

◆ fillTriangle()

void Rasterizer2D::fillTriangle ( const Matrix< 2, 3 > &  triangle,
const Color color 
)

Fill a triangle.

Parameters
triangleThe vertices of the triangle
colorThe color to use

◆ pointwiseFillQuadrilateral()

void Rasterizer2D::pointwiseFillQuadrilateral ( const Matrix< 2, 4 > &  quad,
const Color color 
)

Fill a quadrilateral by testing all of the points in its bounding rectangle using the halfspace test.

Parameters
quadThe vertices of the quadrilateral
colorThe color to use

◆ pointwiseFillTriangle()

void Rasterizer2D::pointwiseFillTriangle ( const Matrix< 2, 3 > &  triangle,
const Color color 
)

Fill a triangle point-by-point in the given color using the signed-area algorithm.

Parameters
triangleThe vertices of the triangle
colorThe color to use

Member Data Documentation

◆ fb

FrameBuffer* Rasterizer2D::fb
private

The FrameBuffer to use.

◆ fillTechnique

int Rasterizer2D::fillTechnique
private

The fill alorithm to use (SCAN_LINE or POINTWISE)

◆ POINTWISE

const int Rasterizer2D::POINTWISE = 1
static

A constant indicating that a pointwise algorithm should be used.

◆ SCAN_LINE

const int Rasterizer2D::SCAN_LINE = 0
static

A constant indicating that a scan-line algorithm should be used.


The documentation for this class was generated from the following files: