Doob

ComputronicsCamera

Jul 6th, 2015
444
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require('component')
  2. local unicode = require('unicode')
  3. local term = require('term')
  4. local camera = component.camera
  5. local gpu = component.gpu
  6. local color = {0x000000, 0xAA00FF, 0xFF00FF, 0x0000FF, 0x00DDDD, 0x22FF00, 0xDDDD00, 0xFFAA00, 0xFF0000}
  7. local array = ' -:!=░▒▓█'
  8.  
  9. function render(size, side)
  10.   if side == 'up' then
  11.     look = camera.distanceUp
  12.   elseif side == 'down' then
  13.     look = camera.distanceDown
  14.   else
  15.     look = camera.distance
  16.   end
  17.   term.clear()
  18.   term.setCursor(1,1)
  19.   local yp = 1
  20.   for j = -1, 1, size do
  21.     for i = 1, -1, -size do
  22.       local d = look(i, 0-j)
  23.       local a = 1
  24.       if d>0 then a = 2+(8-math.min(8, (d/1.2))) end
  25.       gpu.setForeground(color[math.floor(a)])
  26.       term.write(unicode.sub(array, a, a)..unicode.sub(array, a, a))
  27.     end
  28.     yp=yp+1
  29.     term.setCursor(1,yp)
  30.   end
  31.   gpu.setForeground(0xFFFFFF)
  32. end
  33.  
  34. tArgs = {...}
  35.  
  36. if tArgs[1] == nil then
  37.   tArgs[1] = 0.14
  38. elseif tArgs[2] == nil then
  39.   tArgs[2] = 'front'
  40. end
  41.  
  42. render(tArgs[1], tArgs[2])
RAW Paste Data