GT_text.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 text...")
  8. local x, y, w, h, i
  9. local m
  10. disp:setColor(0, 80, 40, 0)
  11. disp:setColor(1, 60, 0, 40)
  12. disp:setColor(2, 20, 0, 20)
  13. disp:setColor(3, 60, 0, 0)
  14. disp:drawGradientBox(0, 0, disp:getWidth(), disp:getHeight())
  15. disp:setColor(255, 255, 255)
  16. disp:setPrintPos(2,18)
  17. disp:setPrintDir(0)
  18. disp:print("Text")
  19. m = millis() + T
  20. i = 0
  21. while millis() < m do
  22. disp:setColor(bit.band(lcg_rnd(), 31), bit.band(lcg_rnd(), 127) + 127, bit.band(lcg_rnd(), 127) + 64)
  23. w = 40
  24. h = 22
  25. x = bit.rshift(lcg_rnd() * (disp:getWidth() - w), 8)
  26. y = bit.rshift(lcg_rnd() * (disp:getHeight() - h), 8)
  27. disp:setPrintPos(x, y+h)
  28. disp:setPrintDir(bit.band(bit.rshift(i, 2), 3))
  29. i = i + 1
  30. disp:print("Ucglib")
  31. end
  32. disp:setPrintDir(0)
  33. print("...done")
  34. end
  35. return M