Rather than filling a polygon with a solid color, we may want to fill it with a pattern or texture.

We store the pattern in an N x M array (e.g. 8 x 8), then we
want:

row 0 of the pattern to be in rows 0, 8, 16, etc. of the polygon.

row 1 of the pattern to be in rows 1, 9, 17, etc. of the polygon.

Similarly, column 0 of the pattern will be in column 0, 8, 16, etc. of the polygon, column 1 of the pattern will be in column 1, 9, 17, etc. of the polygon.

So, we will have a row pointer and a column pointer:

for each scan line (Y): rowptr <-- y mod 8

for each column (X) colptr <-- x mod 8

Then to display the pixel, we use set_pixel(x, y, pattern[rowptr, colptr]).

Solid Polygon menu

HyperGraph
Table of Contents.

HyperGraph Home
page.