Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.35 KB | None | 0 0
  1. local gpu = require("component").gpu
  2. local function createFunction(x1, y1, x2, y2)
  3.   local slope = (y1-y2)/(x1-x2)
  4.   local b = y1 - (slope*x1)
  5.   local function f(x)
  6.     return slope*x+b
  7.   end
  8.   return f
  9. end
  10.  
  11. local function drawLine(x1, y1, x2, y2)
  12.   f = createFunction(x1, y1, x2, y2)
  13.   for x = x1, x2, 0.1 do
  14.     gpu.set(x, f(x), "X")
  15.   end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement