Anyone familiar with this? It's a basic algorithm to plot pixels in a straight line between to points, and it's the basis for how all modern computers perform a DrawLine function.
I found this code in an article on Wikipedia but it's written in C, of which I admit I am wholly ignorant on, and as such I am confused on how to convert some of the lines. Anyone want to do a BlitzMax conversion?
I found this code in an article on Wikipedia but it's written in C, of which I admit I am wholly ignorant on, and as such I am confused on how to convert some of the lines. Anyone want to do a BlitzMax conversion?
function line(x0, x1, y0, y1) boolean steep := abs(y1 - y0) > abs(x1 - x0) if steep then swap(x0, y0) swap(x1, y1) int deltax := abs(x1 - x0) int deltay := abs(y1 - y0) int error := 0 int deltaerr := deltay int x := x0 int y := y0 if x0 < x1 then xstep := 1 else xstep := -1 if y0 < y1 then ystep := 1 else ystep := -1 if steep then plot(y,x) else plot(x,y) while x != x1 x := x + xstep error := error + deltaerr if 2×error > deltax y := y + ystep error := error - deltax if steep then plot(y,x) else plot(x,y)