Driftix

paint opencomputer

Aug 4th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local event = require("event")
  2. local component = require("component")
  3. local colors = require("colors")
  4. local gpu = component.gpu
  5. local resolutionx , resolutionyp = gpu.getResolution()
  6. local resolutiony = resolutionyp
  7. local a = ""
  8. local bouton = 73
  9.  
  10. function top()
  11.   gpu.setBackground(colors.blue,true)
  12.   while resolutiony > resolutionyp - 3 do
  13.     while resolutionx > 0 do
  14.       a = a .. " "
  15.       resolutionx = resolutionx -1
  16.     end
  17.     resolutionx = gpu.getResolution()
  18.     print(a)
  19.     a = ""
  20.     resolutiony = resolutiony - 1
  21.   end
  22.   resolutionx = gpu.getResolution()
  23. end
  24.  
  25. function main()
  26.   while resolutiony > 0 do
  27.     gpu.setBackground(colors.yellow,true)
  28.     while resolutionx > 0 do
  29.       a = a .. " "
  30.       resolutionx = resolutionx - 1
  31.     end
  32.     resolutionx = gpu.getResolution()
  33.     print(a)
  34.     a = ""
  35.     resolutiony = resolutiony - 1
  36.   end
  37. end
  38.  
  39. function couleur()
  40.   local _,_,x,y = event.pull("touch")
  41.   gpu.setBackground(colors.black,true)
  42.   gpu.setForeground(colors.black,true)
  43.   gpu.set(x,y,"X")
  44.  
  45. end
  46.  
  47. function palette()
  48.   local _,_,x,y = event.pull("touch")
  49.     if x >= 73 and y >= 24 then
  50.       couleur()
  51.   end
  52. end
  53.  
  54. function button()
  55.   while bouton < 80 do
  56.     gpu.setBackground(colors.blue,true)
  57.     gpu.setForeground(colors.blue,true)
  58.     gpu.set(bouton,24," ")
  59.     gpu.set(bouton,25," ")
  60.     bouton = bouton +1
  61.     gpu.setForeground(colors.white,true)
  62.     gpu.set(73,24,"Palette")
  63.   end
  64.   bouton = 73
  65. end
  66.  
  67. while true do
  68.   top()
  69.   main()
  70.   button()
  71.   couleur()
  72.   gpu.setBackground(colors.blue,true)
  73.   gpu.setForeground(colors.white,true)
  74.   gpu.set(2,2,"Bienvenue dans le paint de willem")
  75. --  palette()
  76.  
  77. end
Advertisement
Add Comment
Please, Sign In to add comment