Bresenham算法的美丽(2016)

2021-04-13 18:20:05

Warning: Can only detect less than 5000 characters

void plotlinewidth((int x0,int y0,int x1,int y1,float wd) { int dx = abs(x1-x0),sx = x0< x1? 1:-1; int dy = abs(y1-y0),sy = y0< Y1? 1:-1; int err = dx-dy,e2,x2,y2; / *错误值e_xy * / floated = dx + dy == 0? 1:SQRT((浮法)DX * DX +(浮动)DY * DY); for(wd =(wd + 1)/ 2;;){/ *像素循环* / setpixelcolor(x0,y0,max(0,255 *(abs(err-dx + dy)/ ed-wd + 1))))); e2 = err; x2 = x0; if(2 * e2> = -dx){/ * x步骤* / for(e2 + = dy,Y2 = y0; e2< Ed * wd&(y1!= y2 || dx> dy); e2 + = dx) setpixelcolor(x0,y2 + = sy,max(0,255 *(abs(e2)/ ed-wd + 1)))); if(x0 == x1)中断; e2 = err; 呃 - = dy; x0 + = sx; } if(2 * e2< dy){/ * y步骤* / 对于(E2 = DX-E2; E2< ED * WD&(x1!= x2 || dx< dy); e2 + = dy) setpixelcolor(x2 + = sx,y0,max(0,255 *(abs(e2)/ ed-wd-wd + 1)))); 如果(y0 == y1)打破; err + = dx; y0 + = sy; } } }