GT_pixel_and_lines.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- luacheck: globals T r disp millis lcg_rnd
  2. local M, module = {}, ...
  3. _G[module] = M
  4. function M.run()
  5. -- make this a volatile module:
  6. package.loaded[module] = nil
  7. print("Running component pixel_and_lines...")
  8. local mx
  9. local x, xx
  10. mx = disp:getWidth() / 2
  11. --my = disp:getHeight() / 2
  12. disp:setColor(0, 0, 0, 150)
  13. disp:setColor(1, 0, 60, 40)
  14. disp:setColor(2, 60, 0, 40)
  15. disp:setColor(3, 120, 120, 200)
  16. disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight())
  17. disp:setColor(255, 255, 255)
  18. disp:setPrintPos(2, 18)
  19. disp:setPrintDir(0)
  20. disp:print("Pix&Line")
  21. disp:drawPixel(0, 0)
  22. disp:drawPixel(1, 0)
  23. --disp:drawPixel(disp:getWidth()-1, 0)
  24. --disp:drawPixel(0, disp:getHeight()-1)
  25. disp:drawPixel(disp:getWidth()-1, disp:getHeight()-1)
  26. disp:drawPixel(disp:getWidth()-1-1, disp:getHeight()-1)
  27. x = 0
  28. while x < mx do
  29. xx = ((x)*255)/mx
  30. disp:setColor(255, 255-xx/2, 255-xx)
  31. disp:drawPixel(x, 24)
  32. disp:drawVLine(x+7, 26, 13)
  33. x = x + 1
  34. end
  35. print("...done")
  36. end
  37. return M