原画线函数会出现画不了斜线,而转为画直角的严重BUG
这次运用位运算重新设计了画线函数。
sub DrawLine(DrawLine_Page,DrawLine_X1,DrawLine_Y1,DrawLine_X2,DrawLine_Y2,DrawLine_Color)
dim DrawLine_dx,DrawLine_dy,DrawLine_dx2,DrawLine_dy2,DrawLine_x_inc,DrawLine_y_inc,DrawLine_e,DrawLine_index
DrawLine_dx = DrawLine_x2-DrawLine_x1
DrawLine_dy = DrawLine_y2-DrawLine_y1
if(DrawLine_dx>=0) then
DrawLine_x_inc = 1
else
DrawLine_x_inc = -1
DrawLine_dx = -DrawLine_dx
end if
if(DrawLine_dy>=0)then
DrawLine_y_inc = 1
else
DrawLine_y_inc = -1
DrawLine_dy = -DrawLine_dy
end if
DrawLine_dx2 = ESHL(DrawLine_dx, 1)
DrawLine_dy2 = ESHL(DrawLine_dy, 1)
if(DrawLine_dx > DrawLine_dy) then
DrawLine_e = DrawLine_dy2 - DrawLine_dx
DrawLine_index=0
while DrawLine_index <= DrawLine_dx
PIXEL(DrawLine_PAGE,DrawLine_x1,DrawLine_y1,DrawLine_COLOR)
if (DrawLine_e >= 0) then
DrawLine_e=DrawLine_e-DrawLine_dx2
DrawLine_y1=DrawLine_y1+DrawLine_y_inc
end if
DrawLine_e=DrawLine_e+DrawLine_dy2
DrawLine_x1=DrawLine_x1+DrawLine_x_inc
DrawLine_index=DrawLine_index+1
wend
else
DrawLine_e = DrawLine_dy2 - DrawLine_dx
DrawLine_index=0
while DrawLine_index <= DrawLine_dy
PIXEL(DrawLine_PAGE,DrawLine_x1,DrawLine_y1,DrawLine_COLOR)
if (DrawLine_e >= 0) then
DrawLine_e=DrawLine_e-DrawLine_dy2
DrawLine_x1=DrawLine_x1+DrawLine_x_inc
end if
DrawLine_e=DrawLine_e+DrawLine_dx2
DrawLine_y1=DrawLine_y1+DrawLine_y_inc
DrawLine_index=DrawLine_index+1
wend
end if
end sub
需要使用2.1版本的BB ,因为加入了位运算来加速。
这次运用位运算重新设计了画线函数。
sub DrawLine(DrawLine_Page,DrawLine_X1,DrawLine_Y1,DrawLine_X2,DrawLine_Y2,DrawLine_Color)
dim DrawLine_dx,DrawLine_dy,DrawLine_dx2,DrawLine_dy2,DrawLine_x_inc,DrawLine_y_inc,DrawLine_e,DrawLine_index
DrawLine_dx = DrawLine_x2-DrawLine_x1
DrawLine_dy = DrawLine_y2-DrawLine_y1
if(DrawLine_dx>=0) then
DrawLine_x_inc = 1
else
DrawLine_x_inc = -1
DrawLine_dx = -DrawLine_dx
end if
if(DrawLine_dy>=0)then
DrawLine_y_inc = 1
else
DrawLine_y_inc = -1
DrawLine_dy = -DrawLine_dy
end if
DrawLine_dx2 = ESHL(DrawLine_dx, 1)
DrawLine_dy2 = ESHL(DrawLine_dy, 1)
if(DrawLine_dx > DrawLine_dy) then
DrawLine_e = DrawLine_dy2 - DrawLine_dx
DrawLine_index=0
while DrawLine_index <= DrawLine_dx
PIXEL(DrawLine_PAGE,DrawLine_x1,DrawLine_y1,DrawLine_COLOR)
if (DrawLine_e >= 0) then
DrawLine_e=DrawLine_e-DrawLine_dx2
DrawLine_y1=DrawLine_y1+DrawLine_y_inc
end if
DrawLine_e=DrawLine_e+DrawLine_dy2
DrawLine_x1=DrawLine_x1+DrawLine_x_inc
DrawLine_index=DrawLine_index+1
wend
else
DrawLine_e = DrawLine_dy2 - DrawLine_dx
DrawLine_index=0
while DrawLine_index <= DrawLine_dy
PIXEL(DrawLine_PAGE,DrawLine_x1,DrawLine_y1,DrawLine_COLOR)
if (DrawLine_e >= 0) then
DrawLine_e=DrawLine_e-DrawLine_dy2
DrawLine_x1=DrawLine_x1+DrawLine_x_inc
end if
DrawLine_e=DrawLine_e+DrawLine_dx2
DrawLine_y1=DrawLine_y1+DrawLine_y_inc
DrawLine_index=DrawLine_index+1
wend
end if
end sub
需要使用2.1版本的BB ,因为加入了位运算来加速。
