Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gpu = require("component").gpu
- local function createFunction(x1, y1, x2, y2)
- local slope = (y1-y2)/(x1-x2)
- local b = y1 - (slope*x1)
- local function f(x)
- return slope*x+b
- end
- return f
- end
- local function drawLine(x1, y1, x2, y2)
- f = createFunction(x1, y1, x2, y2)
- for x = x1, x2, 0.1 do
- gpu.set(x, f(x), "X")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement