Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local termOS = require(script.Parent.Parent.Parent)
- local nsUIBuffer = {}
- -- res: 20x20 (sq)
- local resolution = 20
- local display = script.Parent.Parent.Parent.Parent.Frame
- function nsUIBuffer:createRenderMap()
- termOS.eol()
- termOS.wl("Creating a nsUIImageBuffer")
- termOS.eol()
- termOS.wl("Progress:")
- termOS.eol()
- -- create uiBuffer
- local uiBuffer = Instance.new("Frame")
- uiBuffer.Parent = display
- uiBuffer.Size = UDim2.new(1,0,1,0)
- uiBuffer.BackgroundColor3 = Color3.fromRGB(0,0,0)
- uiBuffer.Visible = false
- --create uiDisplayMatrix
- local matrix = {}
- local bmp = {x=0,y=0}
- for x=0, resolution, display.Size.X.Scale/resolution do
- bmp.x = bmp.x + 1
- matrix[tostring(bmp.x)] = {}
- for y=0, resolution, display.Size.Y.Scale/resolution do
- bmp.y = bmp.y + 1
- local pixel = Instance.new("Frame")
- pixel.Size = UDim2.new(display.Size.X.Scale/resolution, display.Size.Y.Scale/resolution)
- pixel.Position = UDim2.new(x,0,y,0)
- pixel.BackgroundColor3 = Color3.fromRGB(0,0,0)
- pixel.BorderSizePixel = 0
- pixel.Parent = uiBuffer
- matrix[tostring(bmp.x)][tostring(bmp.x)] = {r=0,g=0,b=0,a=1, o=pixel} -- R G B Alpha (1=Opaque, 0=Transparent) Object
- end
- local bfr = ""
- -- a * d / c = b
- for j=0, math.floor( ( x * 100 / resolution ) ) do
- bfr = bfr .. "#"
- end
- for j=0, 100-#bfr do
- bfr = bfr .. " "
- end
- termOS.wl("[ " .. bfr .. " ]")
- wait()
- end
- termOS.eol()
- termOS.wl("Done; clearing TerminalUIBuffer")
- display.buffer:ClearAllChildren()
- display.buffer.Visible = false
- rawset(self, "buffer", uiBuffer)
- rawset(self, "matrix", matrix)
- return self
- end
- function nsUIBuffer:render(displayMatrix)
- for a,x in pairs(displayMatrix) do
- if (x=={}) then
- else
- for c,y in pairs(x) do
- if (y=={}) then
- else
- for d,pixel in pairs(y) do
- if (pixel=={}) then
- else
- local pixel = rawget(self, "matrix")
- print(unpack(pixel))
- pixel = pixel[tostring(x)][tostring(y)]["o"]
- pixel.BackgroundColor3 = Color3.fromRGB(pixel.r,pixel.g,pixel.b)
- end
- wait()
- end
- end
- wait()
- end
- end
- wait()
- end
- end
- return function(args)
- if #args==1 then
- termOS.eol()
- termOS.wl("This is an API, not an app!")
- else
- return setmetatable(nsUIBuffer,{})
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement