Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- resx = 25
- resy = 50
- file = [[THIS IS WHERE THE IMAGE GOES]]
- currentpixel = {1, 0}
- pixelsize = 4
- pxnumwait = 1
- --takes the lines out of the string 'file'
- newfile = ""
- enter = "\n"
- for i = 1, #file do
- if string.sub(file, i, i) ~= enter then
- newfile = newfile..string.sub(file, i, i)
- end end
- file = newfile
- function render(a,r,g,b) --makes a pixel
- pixel = Instance.new("TextLabel", script.Parent)
- pixel.Name = table.concat(currentpixel, ",")
- pixel.BorderSizePixel = 0
- pixel.BackgroundColor3 = Color3.new(r/255, g/255, b/255)
- pixel.BackgroundTransparency = a/255
- pixel.Position = UDim2.new(0, 20 + (currentpixel[1]-1) * pixelsize, 0, 60 + currentpixel[2] * pixelsize)
- pixel.Size = UDim2.new(0, pixelsize, 0, pixelsize)
- pixel.Text = ""
- currentpixel[1] = currentpixel[1] + 1
- if currentpixel[1] == resx + 1 then
- currentpixel[1] = 1
- currentpixel[2] = currentpixel[2] + 1
- end end
- function getpicture() --interprets the picture and renders it with function 'render'
- pixels = {}
- for i = 1, #file, 12 do
- table.insert(pixels, string.sub(file, i, i+11))
- end
- for i = 1, #pixels do
- if math.floor(i/pxnumwait) == i/pxnumwait then
- wait()
- end
- render(string.sub(pixels[i], 10, 12), string.sub(pixels[i], 1, 3), string.sub(pixels[i], 4, 6), string.sub(pixels[i], 7, 9))
- end end
- script.Parent.Render.MouseButton1Down:connect(function ()
- if script.Parent.Render.Text == "Render image" then
- if tonumber(script.Parent.PixelSize.Text) then
- pixelsize = script.Parent.PixelSize.Text
- end
- currentpixel = {1, 0}
- for _, a in pairs(script.Parent:GetChildren()) do
- if a.className == "TextLabel" then
- a:Remove()
- end end
- script.Parent.Render.Text = "Time to completion: "..math.ceil(resx * resy * 0.04 / pxnumwait)
- getpicture()
- script.Parent.Render.Text = "Render image"
- end end)
Advertisement
Add Comment
Please, Sign In to add comment