Advertisement
9551

rainbow font

Aug 4th, 2021 (edited)
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.25 KB | None | 0 0
  1. --rainbow font!--
  2. --program by 9551Dev--
  3. --you can use this if you dont claim you made it--
  4. --made for making computer colors rainbow !--
  5. --default: white. this program also adds--
  6. --colors.rainbow color--
  7. --this program is reccomended--
  8. --to be a startup file--
  9. ----CONFIG---------------------------------
  10. local ColorToObliterate = {colors.white}
  11. local ColorSpeed = 0.5
  12. local smoothing = 0.5
  13. local RainbowOffset = true
  14. local OffSetFirst = true
  15. local offsetR = 0.2
  16. local offsetG = 0
  17. local offsetB = 0.2
  18. local colorsRainbow = "random"
  19. local terms = {term}
  20. local offSetTerms = true
  21. local loadConfigFromFile = "filename.clr"
  22. --------------------------------------------
  23. local MAIN = function()
  24. end
  25. local startups = function()
  26.     if fs.exists("startup") and fs.isDir("startup") then
  27.         for k, v in ipairs(fs.list("startup")) do
  28.             shell.run("./startup/" .. v)
  29.         end
  30.     end
  31. end
  32. local backs = MAIN
  33. if loadConfigFromFile:match("/?.+%.(.-)$") ~= "clr" then
  34.     error("loadConfigFromFile needs to be .clr file", 0)
  35. end
  36. if loadConfigFromFile and fs.exists(loadConfigFromFile) then
  37.     lines = {}
  38.     for l in io.lines(loadConfigFromFile) do
  39.         lines[#lines + 1] = l
  40.     end
  41.     ColorToObliterate = loadstring("return " .. "{" .. lines[1] .. "}")()
  42.     ColorSpeed = tonumber(lines[2])
  43.     smoothing = tonumber(lines[3])
  44.     RainbowOffset = loadstring("return " .. lines[4])()
  45.     OffSetFirst = loadstring("return " .. lines[5])()
  46.     offsetR = tonumber(lines[6])
  47.     offsetG = tonumber(lines[7])
  48.     offsetB = tonumber(lines[8])
  49.     colorsRainbow = lines[9]
  50.     terms = loadstring("return " .. "{" .. (lines[10] or "") .. "}")()
  51.     offSetTerms = loadstring("return "..(lines[12] or ""))()
  52.     if ColorToObliterate == "" or not ColorToObliterate then ColorToObliterate = colors.white end
  53.     if ColorSpeed == "" or not ColorSpeed then ColorSpeed = 0.5 end
  54.     if smoothing == "" or not smoothing then smoothing = 0.5 end
  55.     if RainbowOffset == "" then RainbowOffset = true end
  56.     if OffSetFirst == "" then OffSetFirst = true end
  57.     if offsetR == "" or not offsetR then offsetR = 0.2 end
  58.     if offsetG == "" or not offsetG then offsetG = 0 end
  59.     if offsetB == "" or not offsetB then offsetB = 0.2 end
  60.     if colorsRainbow == "" or not colorsRainbow then colorsRainbow = "random" end
  61.     if terms == {""} or not terms then terms = {term} end
  62.     if lines[11] ~= "" and lines[11] then
  63.         MAIN = loadstring("return function() " .. lines[11] .. " end")()
  64.         if type(MAIN) ~= "function" then MAIN = function() end end
  65.     end
  66.     if offSetTerms == "" then offSetTerms = true end
  67. end
  68. local selects = 1
  69. if colorsRainbow == "random" then selects = math.random(1, #ColorToObliterate) end
  70. if colorsRainbow == "max" then selects = #ColorToObliterate end
  71. if tonumber(colorsRainbow) then selects = tonumber(colorsRainbow) end
  72. if not next(ColorToObliterate) then ColorToObliterate = {colors.white} end
  73. _G.colors.rainbow = ColorToObliterate[selects]
  74. _G.colours.rainbow = ColorToObliterate[selects]
  75. local function HSVToRGB(hue, saturation, value)
  76.     if saturation == 0 then return value, value, value end
  77.     local hue_sector = math.floor(hue / 60)
  78.     local hue_sector_offset = (hue / 60) - hue_sector
  79.     local p = value * (1 - saturation)
  80.     local q = value * (1 - saturation * hue_sector_offset)
  81.     local t = value * (1 - saturation * (1 - hue_sector_offset))
  82.     if hue_sector == 0 then return value, t, p
  83.     elseif hue_sector == 1 then return q, value, p
  84.     elseif hue_sector == 2 then return p, value, t
  85.     elseif hue_sector == 3 then return p, q, value
  86.     elseif hue_sector == 4 then return t, p, value
  87.     elseif hue_sector == 5 then return value, p, q end
  88. end
  89. local function rgbgen()
  90.     while true do
  91.         for i = 1, 360 * smoothing do
  92.             local counterR = 0
  93.             local counterG = 0
  94.             local counterB = 0
  95.             local r, g, b = HSVToRGB(i / smoothing, 1, 1)
  96.             for k, v in ipairs(ColorToObliterate) do
  97.                 if RainbowOffset then
  98.                     r, b, g = (r or 1), (g or 0), (b or 0)
  99.                     r, b, g = r + counterR, b + counterB, g + counterG
  100.                     if r > 1 then r = 1 end
  101.                     if b > 1 then b = 1 end
  102.                     if g > 1 then g = 1 end
  103.                     if OffSetFirst and not offSetTerms then
  104.                         counterR = counterR + offsetR
  105.                         counterG = counterG + offsetG
  106.                         counterB = counterB + offsetB
  107.                     end
  108.                     if OffSetFirst and offSetTerms then
  109.                         counterR = counterR + offsetR/10
  110.                         counterG = counterG + offsetG/10
  111.                         counterB = counterB + offsetB/10
  112.                         r, b, g = (r or 1), (g or 0), (b or 0)
  113.                         r, b, g = r + counterR, b + counterB, g + counterG
  114.                         if r > 1 then r = 1 end
  115.                         if b > 1 then b = 1 end
  116.                         if g > 1 then g = 1 end
  117.                     end
  118.                     for ka, va in ipairs(terms) do
  119.                         if offSetTerms and OffSetFirst then
  120.                             counterR = counterR + offsetR/10
  121.                             counterG = counterG + offsetG/10
  122.                             counterB = counterB + offsetB/10
  123.                             r, b, g = (r or 1), (g or 0), (b or 0)
  124.                             r, b, g = r + counterR, b + counterB, g + counterG
  125.                             if r > 1 then r = 1 end
  126.                             if b > 1 then b = 1 end
  127.                             if g > 1 then g = 1 end
  128.                         end
  129.                         va.setPaletteColor(v, r, g, b)
  130.                         if offSetTerms and not OffSetFirst then
  131.                             counterR = counterR + offsetR/10
  132.                             counterG = counterG + offsetG/10
  133.                             counterB = counterB + offsetB/10
  134.                             r, b, g = (r or 1), (g or 0), (b or 0)
  135.                             r, b, g = r + counterR, b + counterB, g + counterG
  136.                             if r > 1 then r = 1 end
  137.                             if b > 1 then b = 1 end
  138.                             if g > 1 then g = 1 end
  139.                         end
  140.                     end
  141.                     if not OffSetFirst and not offSetTerms then
  142.                         counterR = counterR + offsetR
  143.                         counterG = counterG + offsetG
  144.                         counterB = counterB + offsetB
  145.                     end
  146.                     if not OffSetFirst and offSetTerms then
  147.                         counterR = counterR + offsetR/10
  148.                         counterG = counterG + offsetG/10
  149.                         counterB = counterB + offsetB/10
  150.                         r, b, g = (r or 1), (g or 0), (b or 0)
  151.                         r, b, g = r + counterR, b + counterB, g + counterG
  152.                         if r > 1 then r = 1 end
  153.                         if b > 1 then b = 1 end
  154.                         if g > 1 then g = 1 end
  155.                     end
  156.                 else
  157.                     for ka, va in ipairs(terms) do va.terms.setPaletteColor(v, (r or 1), (g or 0), (b or 0)) end
  158.                 end
  159.             end sleep(ColorSpeed / 5)
  160.         end
  161.     end
  162. end
  163. local sh = function()
  164.     local sShell
  165.     if term.isColour() and settings.get("bios.use_multishell") then sShell = "/rom/programs/advanced/multishell.lua"
  166.     else sShell = "/rom/programs/shell.lua" end
  167.     shell.run(sShell)
  168.     shell.run("/rom/programs/shutdown.lua")
  169. end
  170. do
  171.     pcall(parallel.waitForAll, rgbgen, sh, MAIN, startups)
  172.     term.setTextColor(colors.yellow) print("\nGoodbye")
  173.     sleep(.5) os.shutdown()
  174. end
  175.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement