Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Module
- local PNG_Module = {}
- PNG_Module.__index = PNG_Module
- -- Services
- local Players = game:GetService("Players")
- local HttpService = game:GetService("HttpService")
- -- Resources Folder
- local Resources = script:WaitForChild("Resources", math.huge)
- -- Assets
- local Assets = Resources:WaitForChild("Assets", math.huge)
- local Cleaner = Assets:WaitForChild("Cleaner", math.huge)
- local Frame = Assets:WaitForChild("Drawing_Frame", math.huge)
- local Holder = Frame:WaitForChild("Pixels", math.huge)
- local Pixel = Assets:WaitForChild("Pixel", math.huge)
- local Row = Assets:WaitForChild("Row", math.huge)
- -- Modules
- local Modules = Resources:WaitForChild("Modules", math.huge)
- local Drawing = require(Modules:WaitForChild("Drawing", math.huge))
- -- Function
- function PNG_Module:drawImage(Image_Url, Size, Color, Anchor, Position)
- -- Failsafes
- assert(pcall(HttpService.GetAsync, HttpService, "https://www.google.com/"), "Http isn't enabled on this game.")
- assert(Image_Url ~= nil, "Image Url wasn't provided.")
- -- Config
- local Image = HttpService:GetAsync(Image_Url)
- local Pixel_Size = (rawequal(type(Size), "number")) and (Size) or 1
- local Transparent_Color = (rawequal(typeof(Color), "Color3")) and (Color) or Color3.fromRGB(255, 255, 255)
- local Anchor_Point = (rawequal(typeof(Anchor), "Vector2")) and (Anchor) or Vector2.new(.5, .5)
- local Image_Position = (rawequal(typeof(Position), "UDim2")) and (Position) or UDim2.new(.5, 0, .5, 0)
- -- Settings
- Holder.AnchorPoint = Anchor_Point
- Holder.Position = Image_Position
- Pixel.Size = UDim2.new(0, Pixel_Size, 0, Pixel_Size)
- Row.Size = UDim2.new(0, Pixel_Size, 1, 0)
- -- Image Processing
- local Result = Drawing.new(Image)
- local Pixels = {}
- for X = 1, Result.Width do
- local Table = {}
- for Y = 1, Result.Height do
- local Color, Alpha = Drawing:GetPixel(Result, X, Y)
- table.insert(Table, Color)
- end
- local New_Row = Row:Clone()
- New_Row.Parent = Holder
- for _, Color in next, Table do
- local New_Pixel = Pixel:Clone()
- New_Pixel.Parent = New_Row
- New_Pixel.BackgroundColor3 = Color
- if (Color == Transparent_Color) then
- New_Pixel.BackgroundTransparency = 1
- end
- end
- end
- -- Image Display
- local Display_Image = function(Index, Object)
- local Player = (type(Index ~= "userdata")) and (Object) or (Index)
- local PlayerGui = Player:FindFirstChildOfClass("PlayerGui")
- Frame:Clone().Parent = PlayerGui
- end
- local Clean_Image = function(Index, Object)
- local Player = (type(Index ~= "userdata")) and (Object) or (Index)
- local Backpack = Player:FindFirstChildOfClass("Backpack")
- local Script = Cleaner:Clone()
- Script.Parent = Backpack
- Script.Disabled = false
- end
- -- Display Connection
- if (_G.Drawing_Connection) then
- _G.Drawing_Connection:Disconnect()
- table.foreach(Players:GetPlayers(), Clean_Image)
- end
- table.foreach(Players:GetPlayers(), Display_Image)
- _G.Drawing_Connection = Players.PlayerAdded:Connect(Display_Image)
- end
- return setmetatable({}, PNG_Module)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement