Advertisement
serafim7

скринсейвер Matrix [OpenComputers]

Nov 8th, 2020 (edited)
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.62 KB | None | 0 0
  1. --https://pastebin.com/ZZrr7TM8    IGOR_TIMOFEEV
  2.  
  3. local event = require("event")
  4. local gpu = require("component").gpu
  5.  
  6. --------------------------------------------------------------------------------------------------------------------
  7.  
  8. local maximumLines = 60
  9. local minimumLineLength = 5
  10. local maximumLineLength = 55
  11. local backgroundColor = 0x000000
  12. local speed = 0.00
  13.  
  14. local chars = { "ァ", "ア", "ィ", "イ", "ゥ", "ウ", "ェ", "エ", "ォ", "オ", "カ", "ガ", "キ", "ギ", "ク", "グ", "ケ", "ゲ", "コ", "ゴ", "サ", "ザ", "シ", "ジ", "ス", "ズ", "セ", "ゼ", "ソ", "ゾ", "タ", "ダ", "チ", "ヂ", "ッ", "ツ", "ヅ", "テ", "デ", "ト", "ド", "ナ", "ニ", "ヌ", "ネ", "ノ", "ハ", "バ", "パ", "ヒ", "ビ", "ピ", "フ", "ブ", "プ", "ヘ", "ベ", "ペ", "ホ", "ボ", "ポ", "マ", "ミ", "ム", "メ", "モ", "ャ", "ヤ", "ュ", "ユ", "ョ", "ヨ", "ラ", "リ", "ル", "レ", "ロ", "ヮ", "ワ", "ヰ", "ヱ", "ヲ", "ン", "ヴ", "ヵ", "ヶ", "ヷ", "ヸ", "ヹ", "ヺ", "・", "ー", "ヽ", "ヾ", "ヿ"}
  15. local lineColorsForeground = { 0xFFFFFF, 0xBBFFBB, 0x88FF88, 0x33FF33, 0x00FF00, 0x00EE00, 0x00DD00, 0x00CC00, 0x00BB00, 0x00AA00, 0x009900, 0x008800, 0x007700, 0x006600, 0x005500, 0x004400, 0x003300, 0x002200, 0x001100 }
  16. local lineColorsBackground = { 0x004400, 0x004400, 0x003300, 0x003300, 0x002200, 0x001100 }
  17.  
  18. --------------------------------------------------------------------------------------------------------------------
  19.  
  20. local lines = {}
  21. local lineColorsForegroundCount = #lineColorsForeground
  22. local charsCount = #chars
  23. local screenWidth, screenHeight = gpu.getResolution()
  24. local currentBackground, currentForeground
  25.  
  26. local function setBackground(color)
  27.   if currentBackground ~= color then
  28.     gpu.setBackground(color)
  29.     currentBackground = color
  30.   end
  31. end
  32.  
  33. local function setForeground(color)
  34.   if currentForeground ~= color then
  35.     gpu.setForeground(color)
  36.     currentForeground = color
  37.   end
  38. end
  39.  
  40. --------------------------------------------------------------------------------------------------------------------
  41.  
  42. setBackground(backgroundColor)
  43. gpu.fill(1, 1, screenWidth, screenHeight, " ")
  44. local i, colors, background, part, eventType
  45.  
  46. while true do
  47.   while #lines < maximumLines do
  48.     table.insert(lines, {
  49.     x = math.random(1, screenWidth),
  50.     y = 1,
  51.     length = math.random(minimumLineLength, maximumLineLength)
  52.     })
  53.   end
  54.   gpu.copy(1, 1, screenWidth, screenHeight, 0, 1)
  55.   setBackground(backgroundColor)
  56.   gpu.fill(1, 1, screenWidth, 1, " ")
  57.   i, colors = 1, {}
  58.   while i <= #lines do
  59.     lines[i].y = lines[i].y + 1
  60.     if lines[i].y - lines[i].length > 0 then
  61.       table.remove(lines, i)
  62.     else
  63.       part = math.ceil(lineColorsForegroundCount * lines[i].y / lines[i].length)
  64.       background = lineColorsBackground[part] or 0x000000
  65.       colors[background] = colors[background] or {}
  66.       colors[background][lineColorsForeground[part]] = colors[background][lineColorsForeground[part]] or {}
  67.       table.insert(colors[background][lineColorsForeground[part]], i)
  68.       i = i + 1
  69.     end
  70.   end
  71.   for background in pairs(colors) do
  72.     setBackground(background)
  73.     for foreground in pairs(colors[background]) do
  74.       setForeground(foreground)
  75.       for i = 1, #colors[background][foreground] do
  76.         gpu.set(lines[colors[background][foreground][i]].x, 1, chars[math.random(1, charsCount)])
  77.       end
  78.     end
  79.   end
  80.   eventType = event.pull(speed)
  81.   if eventType == "key_down" or eventType == "touch" then
  82.     setBackground(0x000000)
  83.     setForeground(0xFFFFFF)
  84.     gpu.fill(1, 1, screenWidth, screenHeight, " ")
  85.     break
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement