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