[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
SQUAREXT
Implementation
SQUAREXT
is extremely simple. After standard housekeeping
chores are completed (determining size, saving data segment, clearing
playground), it extracts the sidelen,
xoff, and yoff arguments, and then uses a for
loop
over the length of a side, filling in pixels with WHITE
. The
COORD
macro translates cartesian coordinates into the index
of the picture array.
#define COORD(x,y) (((y)+HEIGHT_CENTER)*WIDTH+((x)+WIDTH_CENTER)) ... sidehalf = sidelen / 2; for (i=-sidehalf; i<sidehalf; i++) { A[COORD(-sidehalf+xoff, i+yoff)] = WHITE; A[COORD( sidehalf+xoff, i+yoff)] = WHITE; A[COORD( i+xoff, sidehalf+yoff)] = WHITE; A[COORD( i+xoff, -sidehalf+yoff)] = WHITE; } |