randomize timer()
alt_line(rnd(640),rnd(480),rnd(640),rnd(480))
wait key
function alt_line(x1 as integer,y1 as integer,x2 as integer,y2 as integer)
`line drawing funtion, based off code from http://www.gamedev.net/reference/articles/article1275.asp
local deltax,deltay,x,y,i,xinc1,xinc2,yinc1,yinc2,den,num,numadd,numpixels as integer
deltax = abs(x2-x1) : deltay = abs(y2-y1)
x = x1 : y = y1
if x2>=x1 then xinc1 = 1 : xinc2 = 1 else xinc1 = -1 : xinc2 = -1
if y2>=y1 then yinc1 = 1 : yinc2 = 1 else yinc1 = -1 : yinc2 = -1
if deltax >= deltay
xinc1 = 0 : yinc2 = 0 : den = deltax : num = deltax / 2
numadd = deltay : numpixels = deltax
else
xinc2 = 0 : yinc1 = 0 : den = deltay : num = deltay / 2
numadd = deltax : numpixels = deltay
endif
for i = 0 to numpixels
dot x,y : inc num,numadd
if num >= den
num = num - den : x = x + xinc1 : y = y + yinc1
endif
x = x + xinc2 : y = y + yinc2
next i
endfunction
You know the Programming talk section is a better place for programming stuff.
dbhelp - online dbpro help files with user comments