Advertisement
BigSHinyToys

screen saver kinda

Apr 7th, 2013
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.34 KB | None | 0 0
  1. --[[
  2.         Cool looking login system.
  3.         http://i46.tinypic.com/2yyoa3b.png
  4. ]]--
  5. local logoB = {
  6.     "ffffff000000000ffffff",
  7.     "fff000bbbbbbbbb000fff",
  8.     "ff0bbbbbbb0000bbbb0ff",
  9.     "ff0bbb11110f00bbbb0ff",
  10.     "f0bbbb1bbb0000bbbbb0f",
  11.     "f0bbbbbb000000bbbbb0f",
  12.     "0bbbbbbbc1c11cbbbbbb0",
  13.     "0bbbbb000000000bbbbb0",
  14.     "0bbbbb0000c0000bbbbb0",
  15.     "0bbbbb000cec000bbbbb0",
  16.     "0bbbbb00ceeec00bbbbb0",
  17.     "f0bbbb000cec000bbbb0f",
  18.     "f0bbbb0000c0000bbbb0f",
  19.     "ff0bbbb0000000bbbb0ff",
  20.     "ff0bbbbbbb0bbbbbbb0ff",
  21.     "fff000bbbbbbbbb000fff",
  22.     "ffffff000000000ffffff",
  23. }
  24. local logo = {
  25.     "      000000000      ",
  26.     "   000bbbbbbbbb000   ",
  27.     "  0bbbbbbb0000bbbb0  ",
  28.     "  0bbb11110f00bbbb0  ",
  29.     " 0bbbb1bbb0000bbbbb0 ",
  30.     " 0bbbbbb000000bbbbb0 ",
  31.     "0bbbbbbbc1c11cbbbbbb0",
  32.     "0bbbbb000000000bbbbb0",
  33.     "0bbbbb0000c0000bbbbb0",
  34.     "0bbbbb000cec000bbbbb0",
  35.     "0bbbbb00ceeec00bbbbb0",
  36.     " 0bbbb000cec000bbbb0 ",
  37.     " 0bbbb0000c0000bbbb0 ",
  38.     "  0bbbb0000000bbbb0  ",
  39.     "  0bbbbbbb0bbbbbbb0  ",
  40.     "   000000000000000   ", -- "   000bbbbbbbbb000   ",
  41.     "      000000000      ",
  42. }
  43. local off = 5 -- + off
  44. local words = {
  45.     [8] = {[9] = "C",[11] = "I",[13] = "A"},
  46.     [14] = {[8] = "C",[9] = "e",[10] = "n",[11] = "t",[12] = "r",[13] = "a",[14] = "l"},
  47.     [16] = {[1 + off] = "I",[2+ off] = "n",[3+ off] = "t",[4+ off] = "e",[5+ off] = "l",[6+ off] = "l",[7+ off] = "i",[8+ off] = "g",[9+ off] = "e",[10+ off] = "n",[11+ off] = "c",[12+ off] = "e"}
  48. }
  49.  
  50. local test = {"0123456789abcdef"}
  51.  
  52. local col = {
  53.     ["0"] = 1,
  54.     ["1"] = 2,
  55.     ["2"] = 4,
  56.     ["3"] = 8,
  57.     ["4"] = 16,
  58.     ["5"] = 32,
  59.     ["6"] = 64,
  60.     ["7"] = 128,
  61.     ["8"] = 256,
  62.     ["9"] = 512,
  63.     ["a"] = 1024,
  64.     ["b"] = 2048,
  65.     ["c"] = 4096,
  66.     ["d"] = 8192,
  67.     ["e"] = 16384,
  68.     ["f"] = 32768,
  69. }
  70.  
  71. --[[
  72. term.setBackgroundColor(colors.black)
  73. term.clear()
  74. ]]--
  75.  
  76. local backGround = colors.lightBlue
  77.  
  78. local function draw(image,centerX,centerY,scale,invt)
  79.    
  80.     local img = image
  81.     local offX = centerX - math.floor(#img[1]/2)*scale
  82.     local offY = centerY - math.floor(#img/2) - 1
  83.     local wdth = math.ceil(#img[1]*scale)
  84.    
  85.     for i = 1, #img do
  86.         local line = img[i]
  87.         if invt then
  88.             line = string.reverse(line)
  89.         end
  90.         term.setCursorPos(offX,offY + i)
  91.         for a = 1,wdth do
  92.             local char = math.modf((a/scale)+0.5)
  93.             local color = col[string.sub(line,char,char)]
  94.             --if color then
  95.                 term.setBackgroundColor(color or backGround)
  96.                 term.write(words[i] and words[i][char] or " ")
  97.             --end
  98.         end
  99.     end
  100.    
  101. end
  102.  
  103. -- test
  104.  
  105. local function clear()
  106.     term.setBackgroundColor(backGround)
  107.     term.setTextColor(colors.black)
  108.     term.clear()
  109. end
  110.  
  111. local invt = false
  112. local rate = 0.1
  113.  
  114. while true do
  115.     for i = 0,1,0.1 do
  116.         clear()
  117.         draw(logo,25,10,i,not invt)
  118.         sleep(rate)
  119.     end
  120.     if invt then
  121.         sleep(10)
  122.     end
  123.     for i = 1,0,-0.1 do
  124.         clear()
  125.         draw(logo,25,10,i,not invt)
  126.         sleep(rate)
  127.     end
  128.     invt = not invt
  129.     sleep(rate)
  130. end
  131.  
  132. --[[
  133. -- test example
  134.  
  135.  
  136. local scale = 1
  137. local inc = 0.1
  138.  
  139. while true do
  140.    
  141.     term.setBackgroundColor(colors.black)
  142.     term.clear()
  143.     draw(logo,25,10,scale,true)
  144.     term.setBackgroundColor(colors.black)
  145.     term.setCursorPos(1,1)
  146.     term.write(tostring(scale).." "..tostring(inc))
  147.     local event = {os.pullEvent()}
  148.    
  149.     if event[1] == "key" then
  150.         if event[2] == 203 then -- left
  151.             scale = scale - inc
  152.         elseif event[2] == 205 then -- right
  153.             scale = scale + inc
  154.         elseif event[2] == 14 then
  155.             return
  156.         end
  157.     end
  158.    
  159. end
  160. ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement