here are the 2 functions used for this
Code: Select all
function compOutCode(x, y)
local outcode = 0
if y <0 then
outcode = bottom
end
if y > 272 then
outcode = top
end
if x < 0 then
outcode = outcode + left
end
if x > 480 then
outcode = outcode + right
end
return outcode
end
function drawLineClipped(x0,y0,x1,y1,col)
local accept, done = false
local out1, out2, outout, _x, _y = 0
out1 = compOutCode(x0, y0)
out2 = compOutCode(x1, y1)
repeat
if (out1 == inside and out2 == indide) then
accept = true
done = true
break
elseif not out1 * out2 == inside then -- <<<HERE!
done = true
break
end
if out1 == inside then
outout = out2
else
outout = out1
end
-- if top in outout
if outout == 2 or outout == 10 or outout == 11 then
_x = x0 + (x1 - x0) * (272 - y0) / (y1 - y0)
_y = ymax
end
-- if bottom
if outout == 4 or outout == 12 or outout == 13 then
_x = x0 + (x1 - x0) * (-y0) / (y1 - y0);
_y = 272
-- else if right
elseif outout == 9 or outout == 13 or outout == 11 then
_y = y0 + (y1 - y0) * (480 - x0) / (x1 - x0);
_x = 480
-- else if left
elseif outout == 8 or outout == 12 or outout == 14 then
_y = y0 + (y1 - y0) * (-x0) / (x1 - x0);
_x = 0
end
if outout == out1 then
x0 = _x
y0 = _y
out1 = compOutCode(x0,y0)
else
x1 = _x
y1 = _y
out2 = compOutCode(x1,y1)
end
until done == true
if accept == true then
screen:drawLine(x0,y0,x1,y1,col)
end
end
so umm... help? please say if you dont get what im saying here.