Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("TabletAPI")
- local gpu = peripheral.wrap("right")
- local _x, _y = gpu.getSize()
- local r = 0
- local b = 0
- local g = 0
- local s = 1
- TabletAPI.clear(gpu)
- local function drawBar()
- gpu.setColor(141, 141, 141)
- gpu.filledRectangle(0, _y-30, _x, _y)
- gpu.setColor(81, 81, 81)
- gpu.filledRectangle(0, _y-30, _x, 1)
- gpu.setColor(0, 0, 0)
- gpu.drawText("R: "..r, 1, _y-27)
- gpu.drawText("G: "..g, 1, _y-18)
- gpu.drawText("B: "..b, 1, _y-9)
- if s == 1 then
- gpu.setColor(255, 0, 0)
- gpu.drawText("R: "..r, 1, _y-27)
- elseif s == 2 then
- gpu.setColor(0, 155, 0)
- gpu.drawText("G: "..g, 1, _y-18)
- elseif s == 3 then
- gpu.setColor(0, 0, 255)
- gpu.drawText("B: "..b, 1, _y-9)
- end
- gpu.setColor(81, 81, 81)
- gpu.filledRectangle(35, _y-30, 1, 30)
- gpu.setColor(r, g, b)
- gpu.filledRectangle(40, _y-25, 20, 20)
- end
- while true do
- drawBar()
- ev, key, x, y = os.pullEvent()
- if ev == "key" then
- if key == keys.up then
- if s == 1 then
- s = 3
- else
- s = s - 1
- end
- elseif key == keys.down then
- if s == 3 then
- s = 1
- else
- s = s + 1
- end
- elseif key == keys.left then
- if s == 1 then
- if r == 0 then
- r = 255
- else
- r = r - 1
- end
- elseif s == 2 then
- if g == 0 then
- g = 255
- else
- g = g - 1
- end
- elseif s == 3 then
- if b == 0 then
- b = 255
- else
- b = b - 1
- end
- end
- elseif key == keys.right then
- if s == 1 then
- if r == 255 then
- r = 0
- else
- r = r + 1
- end
- elseif s == 2 then
- if g == 255 then
- g = 0
- else
- g = g + 1
- end
- elseif s == 3 then
- if b == 255 then
- b = 0
- else
- b = b + 1
- end
- end
- end
- elseif ev == "monitor_down" or ev == "monitor_move" then
- TabletAPI.setPixel(gpu, math.ceil(x/4), math.ceil(y/4), {r, g, b}, 4)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement