Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,23 @@
|
|||
function line(img, x0::Int, y0::Int, x1::Int, y1::Int, col)
|
||||
dx = int(abs(x1-x0))
|
||||
dy = int(abs(y1-y0))
|
||||
|
||||
sx = x0<x1 ? 1 : -1
|
||||
sy = y0<y1 ? 1 : -1;
|
||||
|
||||
err = (dx>dy ? dx : -dy)/2
|
||||
|
||||
while true
|
||||
@inbounds img[x0,y0]=col
|
||||
if (x0==x1 && y0==y1); break; end
|
||||
e2 = err;
|
||||
if e2 > -dx
|
||||
err -= dy
|
||||
x0 += sx
|
||||
end
|
||||
if e2 < dy
|
||||
err += dx
|
||||
y0 += sy
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue