Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local os = require("os")
- local gpu = component.gpu
- local w,h = gpu.getResolution()
- local tick = 1/(h/2)
- local white = true
- local black = true
- local whiteCol = 16777215
- local blackCol = 0
- function setup()
- gpu.setBackground(0x000000)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(1,1,w,h," ")
- end
- function fromWhite()
- if white then
- whiteCol = whiteCol-1
- else
- whiteCol = whiteCol+1
- end
- if whiteCol == 0 then
- white = false
- elseif whiteCol == 16777215 then
- white = true
- end
- --print(whiteCol)
- return whiteCol
- end
- function fromBlack()
- if black then
- blackCol = blackCol+1
- else
- blackCol = blackCol-1
- end
- if blackCol == 16777215 then
- black = false
- elseif blackCol == 0 then
- black = true
- end
- --print(blackCol)
- return blackCol
- end
- function aniIn()
- for i=1, h/2 do
- setup()
- gpu.setBackground(fromWhite())
- gpu.fill(i,i,w-(i*2)+2,h-(i*2)+2," ")-- this line
- gpu.setBackground(fromBlack())
- gpu.fill(i+1,i+1,w-(i*2),h-(i*2)," ")
- os.sleep(tick)
- end
- end
- function aniOut()
- for i=h/2, 1, -1 do
- setup()
- gpu.setBackground(fromWhite())
- gpu.fill(i,i,w-(i*2)+2,h-(i*2)+2," ")
- gpu.setBackground(fromBlack())
- gpu.fill(i+1,i+1,w-(i*2),h-(i*2)," ")
- os.sleep(tick)
- end
- end
- function main()
- aniIn()
- aniOut()
- end
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement