y_at_x = function(startx,starty, endx,endy, x)
-- y at a given x on a line
-- Could be nil when the line is parallel to the y axis.
if startx == endx then
return
end
return (endy-starty)/(endx-startx)*(x-startx) + starty