用DDA画线算法编写一个画一条一个象素宽的直线,一个像素是什么意思,要是画三个像素怎么改程序
dda_line(x1,y1,x2,y2,c)intx1,y1,x2,y2,c;{floatdelta_x,delta_y,x,y;intdx,dy,steps,k;dx...
dda_line (x1, y1, x2, y2, c)
int x1, y1, x2, y2, c;
{
float delta_x, delta_y, x, y;
int dx, dy, steps, k;
dx=x2-x1;
dy=y2-y1;
if (abs(dx)>abs(dy)) steps=abs(dx);
else steps=abs (dy);
delta_x=(float)dx / (float)steps;
delta_y=(float)dy / (float)steps;
x=x1;
y=y1;
for (k=1; k<=steps; k++)
{
putpixel((int)(x+0.5), (int)(y+0.5), c);
x+=delta_x;
y+=delta_y;
}
} 展开
int x1, y1, x2, y2, c;
{
float delta_x, delta_y, x, y;
int dx, dy, steps, k;
dx=x2-x1;
dy=y2-y1;
if (abs(dx)>abs(dy)) steps=abs(dx);
else steps=abs (dy);
delta_x=(float)dx / (float)steps;
delta_y=(float)dy / (float)steps;
x=x1;
y=y1;
for (k=1; k<=steps; k++)
{
putpixel((int)(x+0.5), (int)(y+0.5), c);
x+=delta_x;
y+=delta_y;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询