Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. os.loadAPI("TabletAPI")
  2. local gpu = peripheral.wrap("right")
  3. local _x, _y = gpu.getSize()
  4. local r = 0
  5. local b = 0
  6. local g = 0
  7. local s = 1
  8.  
  9. TabletAPI.clear(gpu)
  10.  
  11.  
  12.  
  13. local function drawBar()
  14. gpu.setColor(141, 141, 141)
  15. gpu.filledRectangle(0, _y-30, _x, _y)
  16. gpu.setColor(81, 81, 81)
  17. gpu.filledRectangle(0, _y-30, _x, 1)
  18. gpu.setColor(0, 0, 0)
  19. gpu.drawText("R: "..r, 1, _y-27)
  20. gpu.drawText("G: "..g, 1, _y-18)
  21. gpu.drawText("B: "..b, 1, _y-9)
  22. if s == 1 then
  23. gpu.setColor(255, 0, 0)
  24. gpu.drawText("R: "..r, 1, _y-27)
  25. elseif s == 2 then
  26. gpu.setColor(0, 155, 0)
  27. gpu.drawText("G: "..g, 1, _y-18)
  28. elseif s == 3 then
  29. gpu.setColor(0, 0, 255)
  30. gpu.drawText("B: "..b, 1, _y-9)
  31. end
  32. gpu.setColor(81, 81, 81)
  33. gpu.filledRectangle(35, _y-30, 1, 30)
  34. gpu.setColor(r, g, b)
  35. gpu.filledRectangle(40, _y-25, 20, 20)
  36. end
  37.  
  38. while true do
  39. drawBar()
  40. ev, key, x, y = os.pullEvent()
  41. if ev == "key" then
  42. if key == keys.up then
  43. if s == 1 then
  44. s = 3
  45. else
  46. s = s - 1
  47. end
  48. elseif key == keys.down then
  49. if s == 3 then
  50. s = 1
  51. else
  52. s = s + 1
  53. end
  54. elseif key == keys.left then
  55. if s == 1 then
  56. if r == 0 then
  57. r = 255
  58. else
  59. r = r - 1
  60. end
  61. elseif s == 2 then
  62. if g == 0 then
  63. g = 255
  64. else
  65. g = g - 1
  66. end
  67. elseif s == 3 then
  68. if b == 0 then
  69. b = 255
  70. else
  71. b = b - 1
  72. end
  73. end
  74. elseif key == keys.right then
  75. if s == 1 then
  76. if r == 255 then
  77. r = 0
  78. else
  79. r = r + 1
  80. end
  81. elseif s == 2 then
  82. if g == 255 then
  83. g = 0
  84. else
  85. g = g + 1
  86. end
  87. elseif s == 3 then
  88. if b == 255 then
  89. b = 0
  90. else
  91. b = b + 1
  92. end
  93. end
  94. end
  95. elseif ev == "monitor_down" or ev == "monitor_move" then
  96. if key == 0 then
  97. TabletAPI.setPixel(gpu, (x/4)-4, (y/4)-4, {r, g, b}, 4)
  98. elseif key == 1 then
  99. Pixels[y] = Pixels[y] or {}
  100. Pixels[y][x] = nil
  101. end
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement