基本绘图函数



除了 _putpixel(), 所有这些例程都将受当前的绘图模式和 目标位图的剪裁矩形影响.

void putpixel(BITMAP *bmp, int x, int y, int color);
使用当前的绘图模式和位图剪裁矩形向位图的指定位置写一个点.


void _putpixel(BITMAP *bmp, int x, int y, unsigned char color);
和常规的 putpixel() 差不多, 但是要快的多,因为它用 在线汇编函数写成. 这个不能工作在 mode-X 或 真彩 显示模式下, 不做任何剪裁 (如果你尝试向 位图以外画点,将死掉!), 并且忽略绘图模式. 它破坏了 %fs 寄存器, 因此你不能和使用了 _farsetsel() 和 _farns*() 函数的代码混用.

int getpixel(BITMAP *bmp, int x, int y);
从位图的 x,y 处读一个点. 如果点在位图以外则返回 -1.


unsigned char _getpixel(BITMAP *bmp, int x, int y);
getpixel() 的更快的在线版本. 这个不能工作在 mode-X 或 真彩显示模式下, 它不作任何剪裁, 因此你必须 确保点在位图里面.

void vline(BITMAP *bmp, int x, int y1, int y2, int color);
在位图里,从点 (x, y1) 到 (x, y2) 画一条垂线.

void hline(BITMAP *bmp, int x1, int y, int x2, int color);
在位图里,从点 (x1, y) 到 (x2, y) 画一条水平线.

void do_line(BITMAP *bmp, int x1, y1, x2, y2, int d, void (*proc)());
计算从点 (x1, y1) 到 (x2, y2) 之间直线上的所有点, 在每个点上调用所提供的函数. 这个函数将被传入 bmp 参数, x 和 y 坐标, 和参数 d, 因此 这适合于 putpixel() 一起使用.

void line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
向位图从点 (x1, y1) 到 (x2, y2) 画一条直线.

void triangle(BITMAP *bmp, int x1, y1, x2, y2, x3, y3, int color);
填充三个点之间的三角形.

void polygon(BITMAP *bmp, int vertices, int *points, int color);
填充任意角个数的多边形. 传入边的条数 和包含了一串 x, y 点值的数组 (总数为边数*2).

void rect(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
画出作为对角的两个给定的点所描述的空心矩形.

void rectfill(BITMAP *bmp, int x1, int y1, int x2, int y2, int color);
填充一个矩形,参数为描述相对角的两个点.


void do_circle(BITMAP *bmp, int x, int y, int radius, int d, void (*proc)());
计算圆心为 (x, y) 半径为 r 的圆上的所有点, 在每个点上调用所提供的函数. 这个函数将被传入一个 bmp 参数, x 和 y 坐标, 和参数 d, 因此这适合于 putpixel() 一起使用.

void circle(BITMAP *bmp, int x, int y, int radius, int color);
以指定的中心和半径画一个圆.

void circlefill(BITMAP *bmp, int x, int y, int radius, int color);
以指定的中心和半径填充一个圆.

void do_ellipse(BITMAP *bmp, int x, y, int rx, ry, int d, void (*proc)());
计算以点 (x, y) 为中心 rx,ry 为半径的椭圆上的所有点, 在每个点上调用所提供的函数. 这个函数将被传入 一个 bmp 参数, x 和 y 坐标, 和参数 d, 因此这适合于 putpixel() 一起使用.

void ellipse(BITMAP *bmp, int x, int y, int rx, int ry, int color);
以指定中心和半径画一个椭圆.

void ellipsefill(BITMAP *bmp, int x, int y, int rx, int ry, int color);
以指定中心和半径填充一个椭圆.

void do_arc(BITMAP *bmp, int x, y, fixed a1, a2, int r, d, void (*proc)());
计算以点 (x,y) 为中心 r 位半径的弧上的所有点, 对每个点调用支持函数. 将传去一个 bmp 参数的备份, x,y 坐标, 一个 d 参数的备份, 因此它适合被 putpixel() 使用. 弧将被逆时针从 a1 角旋转到 a2 角. 这些值都以 16.16 的定点数格式存放, 256 等于整个圆弧, 64 是直角, 等等. 0 点在中心的右侧, 比它大的值将从这儿逆时针旋转.


void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);
画一段圆弧, 中心在 x,y 半径为 r, 逆时针从 a1 角开始旋转到 a2. 这些值以 16.16的定点数格式存放, 256 等于整圆, 64 是直角, 等等. 0 在中心的右侧, 比它大的数值将从这逆时针旋转.

void calc_spline(int points[8], int npts, int *x, int *y);
计算沿着一条 bezier 曲线的一串 npts 值, 将它们储存在 输出的 x 和 y 数组里. bezier曲线由点数组里的四个 x/y 控制点指定: points[0] 和 points[1] 包含了 第一个控制点的坐标, points[2] 和 points[3] 是 第二个点, 等等. 控制点 0 和 3 是曲线的端点, 点 1 和 2 决定曲线的走向. 曲线可能不会通过 点 1 和 2 , 但这两个点影响着点 0 和 3 之间的弯曲程度 (直线 p0-p1 和 p2-p3 是曲线的切线). 最简单的想象它的方法是 曲线从 p0 开始, 向 p1 的方向延伸, 但是曲线会转回来以便于从 p2 的方向到达 p3. 除了它们的基本作用以外, 曲线可以用来在围绕一串控制点来产生一条平滑的路径, 参考 ex23.c .

void spline(BITMAP *bmp, int points[8], int color);
使用点数组里指定的四个控制点画一条 bezier 曲线.


void floodfill(BITMAP *bmp, int x, int y, int color);
用指定的颜色从点 (x, y) 开始填充一个封闭的区域.





返回