算法2.1 画斜率0≤k≤1的直线的改进的Bresenham画线算法: �void BresenhamLine (int x0, int y0, int x1, int y1, long color) �{ ��int x, y, dx, dy; ��float k, e; ��dx = x1-x0; ��dy = y1- y0; ��e=-dx; ��x = x0; ��y = y0; ��if (dx = = 0) ��{ ���for (i=0;i≤dy;i++) ���{ ����DrawPixel (x, y+i, color);//画像素(x,y+i) ���} ���return; ��} ��for (i=0;i≤dx;i++) ��{ ���DrawPixel (x, y, color);//画像素(x,y) ���x++; ���e += e+2*dy; ���if (e≥0) ���{ ����y++; ����e -= 2*dx; ���} ��} �} |