Advertisement
olmok

BufferDemo

Jan 26th, 2013
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. --
  2. -- BufferDemo.lua
  3. --
  4.  
  5. local function test(l, t)
  6.     write(l..": ")
  7.     if type(t) == "function" then
  8.         t = t()
  9.     end
  10.     if t then
  11.         term.setTextColor(colors.lime)
  12.         print("Success")
  13.     else
  14.         term.setTextColor(colors.red)
  15.         print("Failed")
  16.     end
  17.     term.setTextColor(colors.white)
  18. end
  19.  
  20. os.loadAPI("lib/FrameBuffer")
  21.  
  22. b = FrameBuffer
  23.  
  24. test("create", b.create(100, 67))
  25. test("clear", b.clear(colors.red))
  26. test("set", b.set(b.get()))
  27. test("saveToFile", b.saveToFile("test.buf"))
  28. test("loadFromFile", b.loadFromFile("test.buf"))
  29.  
  30. test("setPixel", b.setPixel(1, 1, colors.blue))
  31. test("getPixel", function () return b.getPixel(1,1) == colors.blue end)
  32.  
  33. --[[
  34. b2 = FrameBuffer
  35. test("create2", b2.create(100, 67))
  36. test("clear2", b2.clear(colors.blue))
  37. test("unique", function () return not b.getPixel(1,1) == b2.getPixel(1,1) end)
  38. ]]
  39.  
  40. test("paintLine", b.paintLine(10, 10, 15, 15, colors.green))
  41. test("paintVector", b.paintVector(1, 10, 10, 45, colors.yellow))
  42. test("paintVector", b.paintVector(1, 10, 10, 45, colors.yellow))
  43.  
  44. local rect = { {30, 30}, {35, 30}, {35, 35}, {30, 35} }
  45. test("paintPolygon", b.paintPolygon(rect, colors.pink, true))
  46. test("paintCircle", b.paintCircle(b.getWidth()/2, b.getHeight()/2, 10, colors.lime))
  47. test("paintEllipse", b.paintEllipse(b.getWidth()/2, b.getHeight()/2, 10, 15, colors.lime))
  48. test("floodFill", b.floodFill(b.getWidth()/2, b.getHeight()/2, colors.white))
  49.  
  50. local bm = { {0,1,1,0},
  51.                          {1,0,0,1},
  52.                          {1,0,0,1},
  53.                          {0,1,1,0}
  54.                     }
  55. test("paintBitmap", b.paintBitmap(bm, colors.purple))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement