Except for _putpixel(), all these routines are affected by the current drawing mode and the clipping rectangle of the destination bitmap.
void putpixel(BITMAP *bmp, int x, int y, int color);
Writes a pixel to the specified position in the bitmap, using the current
drawing mode and the bitmap's clipping rectangle.
void _putpixel(BITMAP *bmp, int x, int y, unsigned char color);
Like the regular putpixel(), but much faster because it is implemented as
an inline assembler function. This won't work in mode-X or truecolor
video modes, doesn't perform any clipping (it will crash if you try to
draw outside the bitmap!), and ignores the drawing mode. It clobbers the
%fs register, so you shouldn't mix it with code that uses the
_farsetsel() and _farns*() functions.
int getpixel(BITMAP *bmp, int x, int y);
Reads a pixel from point x, y in the bitmap. Returns -1 if the point lies
outside the bitmap.
unsigned char _getpixel(BITMAP *bmp, int x, int y);
Faster inline version of getpixel(). This won't work in mode-X or
truecolor video modes, and it doesn't do any clipping, so you must make
sure the point lies inside the bitmap.
void vline(BITMAP *bmp, int x, int y1, int y2, int color);
Draws a vertical line onto the bitmap, from point (x, y1) to (x, y2).
void hline(BITMAP *bmp, int x1, int y, int x2, int color);
Draws a horizontal line onto the bitmap, from point (x1, y) to (x2, y).
void do_line(BITMAP *bmp, int x1, y1, x2, y2, int d, void (*proc)());
Calculates all the points along a line from point (x1, y1) to (x2, y2),
calling the supplied function for each one. This will be passed a copy of
the bmp parameter, the x and y position, and a copy of the d parameter,
so it is suitable for use with putpixel().
void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
Draws a line onto the bitmap, from point (x1, y1) to (x2, y2).
void triangle(BITMAP *bmp, int x1, y1, x2, y2, x3, y3, int color);
Draws a filled triangle between the three points.
void polygon(BITMAP *bmp, int vertices, int *points, int color);
Draws a filled polygon with an arbitrary number of corners. Pass the
number of vertices and an array containing a series of x, y points (a
total of vertices*2 values).
void rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
Draws an outline rectangle with the two points as its opposite corners.
void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
Draws a solid, filled rectangle with the two points as its opposite
corners.
void do_circle(BITMAP *bmp, int x, int y, int radius, int d, void (*proc)());
Calculates all the points in a circle around point (x, y) with radius r,
calling the supplied function for each one. This will be passed a copy of
the bmp parameter, the x and y position, and a copy of the d parameter,
so it is suitable for use with putpixel().
void circle(BITMAP *bmp, int x, int y, int radius, int color);
Draws a circle with the specified centre and radius.
void circlefill(BITMAP *bmp, int x, int y, int radius, int color);
Draws a filled circle with the specified centre and radius.
void do_ellipse(BITMAP *bmp, int x, y, int rx, ry, int d, void (*proc)());
Calculates all the points in an ellipse around point (x, y) with radius
rx and ry, calling the supplied function for each one. This will be
passed a copy of the bmp parameter, the x and y position, and a copy of
the d parameter, so it is suitable for use with putpixel().
void ellipse(BITMAP *bmp, int x, int y, int rx, int ry, int color);
Draws an ellipse with the specified centre and radius.
void ellipsefill(BITMAP *bmp, int x, int y, int rx, int ry, int color);
Draws a filled ellipse with the specified centre and radius.
void do_arc(BITMAP *bmp, int x, y, fixed a1, a2, int r, d, void (*proc)());
Calculates all the points in a circular arc around point (x, y) with
radius r, calling the supplied function for each one. This will be passed
a copy of the bmp parameter, the x and y position, and a copy of the d
parameter, so it is suitable for use with putpixel(). The arc will be
plotted in an anticlockwise direction starting from the angle a1 and
ending when it reaches a2. These values are specified in 16.16 fixed
point format, with 256 equal to a full circle, 64 a right angle, etc.
Zero is to the right of the centre point, and larger values rotate
anticlockwise from there.
void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);
Draws a circular arc with centre x, y and radius r, in an anticlockwise
direction starting from the angle a1 and ending when it reaches a2. These
values are specified in 16.16 fixed point format, with 256 equal to a
full circle, 64 a right angle, etc. Zero is to the right of the centre
point, and larger values rotate anticlockwise from there.
void calc_spline(int points[8], int npts, int *x, int *y);
Calculates a series of npts values along a bezier spline, storing them in
the output x and y arrays. The bezier curve is specified by the four x/y
control points in the points array: points[0] and points[1] contain the
coordinates of the first control point, points[2] and points[3] are the
second point, etc. Control points 0 and 3 are the ends of the spline, and
points 1 and 2 are guides. The curve probably won't pass through points 1
and 2, but they affect the shape of the curve between points 0 and 3 (the
lines p0-p1 and p2-p3 are tangents to the spline). The easiest way to
think of it is that the curve starts at p0, heading in the direction of
p1, but curves round so that it arrives at p3 from the direction of p2.
In addition to their role as graphics primitives, spline curves can be
useful for constructing smooth paths around a series of control points,
as in ex23.c.
void spline(BITMAP *bmp, int points[8], int color);
Draws a bezier spline using the four control points specified in the
points array.
void floodfill(BITMAP *bmp, int x, int y, int color);
Floodfills an enclosed area, starting at point (x, y), with the specified
color.