Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grid = {}
- width, height = term.getSize()
- function straightLineEquation(x,y,x2,y2)
- dim = {width:(x2 - x),height:(y2 - y)}
- gradient = dim[height]/dim[width]
- heightIntercept = -(gradient*dim[width]) + dim[height]
- end
- for w=1,width do
- grid[w] = {}
- for h=1,height do
- grid[w][h] = ""
- equation = gradient*w + heightIntercept
- if equation%1 < 0.5 then
- equation = math.floor(equation)
- else
- equation = math.ceil(equation)
- end
- term.setCursorPos(w,h)
- if w == 1 or h == 1 or w == width or h == height then
- term.setBackgroundColor(colors.green)
- term.write(" ")
- elseif h == equation then
- term.setBackgroundColor(colors.green)
- term.write("x")
- else
- term.setBackgroundColor(colors.lime)
- term.write(" ")
- end
- end
- end
- sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment