Advertisement
DOGGYWOOF

Doggy OS Modern boot anim test

Oct 12th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. local w, h = term.getSize()
  2.  
  3. -- Function to center text horizontally
  4. local function centerText(y, text)
  5. local x = math.floor((w - #text) / 2)
  6. term.setCursorPos(x, y)
  7. term.write(text)
  8. end
  9.  
  10. -- Function to draw the spinner animation
  11. local function drawSpinner(x, y, duration)
  12. local spinnerFrames = {
  13. "[ ]",
  14. "[= ]",
  15. "[== ]",
  16. "[=== ]",
  17. "[====]",
  18. "[ ===]",
  19. "[ ==]",
  20. "[ =]",
  21. "[ ]",
  22. "[ =]",
  23. "[ ==]",
  24. "[ ===]",
  25. "[====]",
  26. "[=== ]",
  27. "[== ]",
  28. "[= ]"
  29. }
  30. local delay = 0.1
  31. local frameCount = #spinnerFrames
  32.  
  33. local spinnerX = x
  34. local spinnerY = y
  35.  
  36. local spinnerIndex = 1
  37. local startTime = os.clock()
  38. while os.clock() - startTime < duration do
  39. term.setCursorPos(spinnerX, spinnerY)
  40. term.write(spinnerFrames[spinnerIndex])
  41.  
  42. spinnerIndex = spinnerIndex % frameCount + 1
  43. os.sleep(delay)
  44. end
  45. end
  46.  
  47. -- ASCII art dog image
  48. local dogImage = {
  49. " |\\_/| ",
  50. " | @ @ Doggy OS ",
  51. " | <> _ ",
  52. " | _/\\------____ ((| |))",
  53. " | `--' | ",
  54. " _____|_ ___| |___.' ",
  55. "/_/_____/____/_______| "
  56. }
  57.  
  58. -- Function to draw the ASCII art
  59. local function drawASCIIArt(y, textColor)
  60. term.setTextColor(textColor)
  61. for i, line in ipairs(dogImage) do
  62. centerText(y + i - 1, line)
  63. end
  64. end
  65.  
  66. -- Function to perform a fade-in animation
  67. local function fadeIn(duration)
  68. term.setBackgroundColor(colors.black)
  69. term.clear()
  70.  
  71. local artHeight = #dogImage
  72. local artY = math.floor((h - artHeight) / 2)
  73. local fadeSteps = 10
  74. local delay = duration / fadeSteps
  75.  
  76. for i = 1, fadeSteps do
  77. local brightness = math.floor(255 * (i / fadeSteps))
  78. local color = colors.white -- Use colors.white for final color
  79.  
  80. -- Draw the ASCII art with gradual increasing brightness
  81. drawASCIIArt(artY, color)
  82. os.sleep(delay)
  83. end
  84. end
  85.  
  86. -- Function to draw the shutdown screen
  87. local function drawShutdownScreen()
  88. fadeIn(1.5) -- Fade in duration is 1.5 seconds
  89.  
  90. term.setTextColor(colors.white)
  91. local artHeight = #dogImage
  92. local artY = math.floor((h - artHeight) / 2)
  93. drawASCIIArt(artY, colors.white)
  94.  
  95. -- Calculate spinner position
  96. local spinnerX = math.floor(w / 2) - 3
  97. local spinnerY = artY + artHeight + 2
  98.  
  99. -- Start spinner animation
  100. drawSpinner(spinnerX, spinnerY, 9) -- Spinner runs for 9 seconds
  101. end
  102.  
  103. -- Main program
  104. drawShutdownScreen()
  105.  
  106. -- Clear screen after shutdown
  107. term.setBackgroundColor(colors.black)
  108. term.clear()
  109.  
  110. -- Shutdown the computer
  111. shell.run("disk/os/lock.lua")
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement