Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- BufferDemo.lua
- --
- local function test(l, t)
- write(l..": ")
- if type(t) == "function" then
- t = t()
- end
- if t then
- term.setTextColor(colors.lime)
- print("Success")
- else
- term.setTextColor(colors.red)
- print("Failed")
- end
- term.setTextColor(colors.white)
- end
- os.loadAPI("lib/FrameBuffer")
- b = FrameBuffer
- test("create", b.create(100, 67))
- test("clear", b.clear(colors.red))
- test("set", b.set(b.get()))
- test("saveToFile", b.saveToFile("test.buf"))
- test("loadFromFile", b.loadFromFile("test.buf"))
- test("setPixel", b.setPixel(1, 1, colors.blue))
- test("getPixel", function () return b.getPixel(1,1) == colors.blue end)
- --[[
- b2 = FrameBuffer
- test("create2", b2.create(100, 67))
- test("clear2", b2.clear(colors.blue))
- test("unique", function () return not b.getPixel(1,1) == b2.getPixel(1,1) end)
- ]]
- test("paintLine", b.paintLine(10, 10, 15, 15, colors.green))
- test("paintVector", b.paintVector(1, 10, 10, 45, colors.yellow))
- test("paintVector", b.paintVector(1, 10, 10, 45, colors.yellow))
- local rect = { {30, 30}, {35, 30}, {35, 35}, {30, 35} }
- test("paintPolygon", b.paintPolygon(rect, colors.pink, true))
- test("paintCircle", b.paintCircle(b.getWidth()/2, b.getHeight()/2, 10, colors.lime))
- test("paintEllipse", b.paintEllipse(b.getWidth()/2, b.getHeight()/2, 10, 15, colors.lime))
- test("floodFill", b.floodFill(b.getWidth()/2, b.getHeight()/2, colors.white))
- local bm = { {0,1,1,0},
- {1,0,0,1},
- {1,0,0,1},
- {0,1,1,0}
- }
- test("paintBitmap", b.paintBitmap(bm, colors.purple))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement