Guest

Untitled 2007

May 17th, 2026
209
0
Never
Not a member of GistPad yet? Sign Up, it unlocks many cool features!
None 37.12 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local CoreGui = game:GetService("CoreGui")
  3.  
  4. local LocalPlayer = Players.LocalPlayer
  5. local LocalDrawingCanvas = nil
  6.  
  7. local BotConfig = {
  8. Enabled = false,
  9. ImageURL = "",
  10. InstantDraw = false -- False = Smooth (Top to Bottom), True = Instant
  11. }
  12.  
  13. -- Variables for libraries
  14. local Unfilter, BinaryReader, Deflate
  15. local chunks = {}
  16. local PNG = {}
  17. PNG.__index = PNG
  18.  
  19. ---------------------------------------------------------------------------------------------
  20. -- [1. GUI INTERFACE]
  21. ---------------------------------------------------------------------------------------------
  22. local ScreenGui = Instance.new("ScreenGui")
  23. ScreenGui.Name = "DrawAndDonateAutoDraw"
  24. ScreenGui.ResetOnSpawn = false
  25. pcall(function() ScreenGui.Parent = CoreGui end)
  26. if not ScreenGui.Parent then ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui") end
  27.  
  28. local MainFrame = Instance.new("Frame")
  29. MainFrame.Size = UDim2.new(0, 250, 0, 260) -- Increased height to fit the mode switcher
  30. MainFrame.Position = UDim2.new(0.05, 0, 0.3, 0)
  31. MainFrame.BackgroundColor3 = Color3.fromRGB(24, 24, 28)
  32. MainFrame.BorderSizePixel = 0
  33. MainFrame.Active = true
  34. MainFrame.Draggable = true
  35. MainFrame.Parent = ScreenGui
  36.  
  37. local UICorner = Instance.new("UICorner")
  38. UICorner.CornerRadius = UDim.new(0, 2)
  39. UICorner.Parent = MainFrame
  40.  
  41. local Title = Instance.new("TextLabel")
  42. Title.Size = UDim2.new(1, 0, 0, 40)
  43. Title.Text = "Draw & Donate Auto Draw"
  44. Title.TextColor3 = Color3.fromRGB(255, 255, 255)
  45. Title.BackgroundColor3 = Color3.fromRGB(34, 34, 40)
  46. Title.Font = Enum.Font.SourceSans
  47. Title.TextSize = 14
  48. Title.Parent = MainFrame
  49.  
  50. local UTCorner = Instance.new("UICorner")
  51. UTCorner.CornerRadius = UDim.new(0, 2)
  52. UTCorner.Parent = Title
  53.  
  54. local function CreateButton(text, yPos, callback)
  55. local Btn = Instance.new("TextButton")
  56. Btn.Size = UDim2.new(1, -20, 0, 32)
  57. Btn.Position = UDim2.new(0, 10, 0, yPos)
  58. Btn.Text = text
  59. Btn.TextColor3 = Color3.fromRGB(240, 240, 240)
  60. Btn.BackgroundColor3 = Color3.fromRGB(44, 44, 52)
  61. Btn.Font = Enum.Font.SourceSans
  62. Btn.TextSize = 14
  63. Btn.Parent = MainFrame
  64. local c = Instance.new("UICorner")
  65. c.CornerRadius = UDim.new(0, 2)
  66. c.Parent = Btn
  67. Btn.MouseButton1Click:Connect(callback)
  68. return Btn
  69. end
  70.  
  71. local ToggleBtn = CreateButton("Please wait...", 50, function() end)
  72. ToggleBtn.BackgroundColor3 = Color3.fromRGB(70, 70, 75)
  73. ToggleBtn.AutoButtonColor = false
  74.  
  75. -- New Mode Button (Smooth / Instant)
  76. local ModeBtn = CreateButton("Mode: Smooth", 87, function()
  77. BotConfig.InstantDraw = not BotConfig.InstantDraw
  78. if BotConfig.InstantDraw then
  79. ModeBtn.Text = "Mode: Instant"
  80. ModeBtn.TextColor3 = Color3.fromRGB(255, 215, 0) -- Gold accent for instant
  81. else
  82. ModeBtn.Text = "Mode: Smooth"
  83. ModeBtn.TextColor3 = Color3.fromRGB(240, 240, 240)
  84. end
  85. end)
  86.  
  87. local TextBox = Instance.new("TextBox")
  88. TextBox.Size = UDim2.new(1, -20, 0, 30)
  89. TextBox.Position = UDim2.new(0, 10, 0, 125)
  90. TextBox.Text = "Insert direct .png URL link"
  91. TextBox.TextColor3 = Color3.fromRGB(200, 200, 200)
  92. TextBox.BackgroundColor3 = Color3.fromRGB(30, 30, 36)
  93. TextBox.Font = Enum.Font.SourceSans
  94. TextBox.TextSize = 12
  95. TextBox.TextWrapped = true
  96. TextBox.ClearTextOnFocus = false
  97. TextBox.Parent = MainFrame
  98. local BoxCorner = Instance.new("UICorner")
  99. BoxCorner.CornerRadius = UDim.new(0, 2)
  100. BoxCorner.Parent = TextBox
  101. TextBox.FocusLost:Connect(function(ep) if ep then BotConfig.ImageURL = TextBox.Text end end)
  102.  
  103. local StatusLabel = Instance.new("TextLabel")
  104. StatusLabel.Size = UDim2.new(1, -20, 0, 40)
  105. StatusLabel.Position = UDim2.new(0, 10, 0, 160)
  106. StatusLabel.Text = "Status: Connecting..."
  107. StatusLabel.TextColor3 = Color3.fromRGB(255, 165, 0)
  108. StatusLabel.BackgroundTransparency = 1
  109. StatusLabel.Font = Enum.Font.SourceSans
  110. StatusLabel.TextSize = 13
  111. StatusLabel.TextWrapped = true
  112. StatusLabel.Parent = MainFrame
  113.  
  114. local AuthorLabel = Instance.new("TextLabel")
  115. AuthorLabel.Size = UDim2.new(1, -20, 0, 20)
  116. AuthorLabel.Position = UDim2.new(0, 10, 0, 205)
  117. AuthorLabel.Text = "Author: @RoogleCreator"
  118. AuthorLabel.TextColor3 = Color3.fromRGB(150, 150, 150)
  119. AuthorLabel.BackgroundTransparency = 1
  120. AuthorLabel.Font = Enum.Font.SourceSans
  121. AuthorLabel.TextSize = 12
  122. AuthorLabel.Parent = MainFrame
  123.  
  124. local ProgressBarBg = Instance.new("Frame")
  125. ProgressBarBg.Size = UDim2.new(1, -20, 0, 6)
  126. ProgressBarBg.Position = UDim2.new(0, 10, 0, 235)
  127. ProgressBarBg.BackgroundColor3 = Color3.fromRGB(45, 45, 55)
  128. ProgressBarBg.BorderSizePixel = 0
  129. ProgressBarBg.Parent = MainFrame
  130. local ProgressBarFill = Instance.new("Frame")
  131. ProgressBarFill.Size = UDim2.new(0, 0, 1, 0)
  132. ProgressBarFill.BackgroundColor3 = Color3.fromRGB(0, 255, 150)
  133. ProgressBarFill.BorderSizePixel = 0
  134. ProgressBarFill.Parent = ProgressBarBg
  135.  
  136. ---------------------------------------------------------------------------------------------
  137. -- [2. OPTIMIZED PNG PARSER FUNCTIONS]
  138. ---------------------------------------------------------------------------------------------
  139. local function getBytesPerPixel(colorType)
  140. if colorType == 0 or colorType == 3 then return 1
  141. elseif colorType == 4 then return 2
  142. elseif colorType == 2 then return 3
  143. elseif colorType == 6 then return 4
  144. else return 0 end
  145. end
  146.  
  147. local function clampInt(value, min, max)
  148. local num = tonumber(value) or 0
  149. num = math.floor(num + 0.5)
  150. return math.clamp(num, min, max)
  151. end
  152.  
  153. local function indexBitmap(file, x, y)
  154. local width = file.Width
  155. local height = file.Height
  156. x = clampInt(x, 1, width)
  157. y = clampInt(y, 1, height)
  158. local bitmap = file.Bitmap
  159. local bpp = file.BytesPerPixel
  160. local i0 = ((x - 1) * bpp) + 1
  161. local i1 = i0 + bpp
  162. return bitmap[y], i0, i1
  163. end
  164.  
  165. function PNG:GetPixel(x, y)
  166. local row, i0, i1 = indexBitmap(self, x, y)
  167. if not row then return Color3.new(1,1,1), 0 end
  168. local colorType = self.ColorType
  169. local color, alpha
  170.  
  171. if colorType == 0 then
  172. local gray = unpack(row, i0, i1)
  173. color = Color3.fromHSV(0, 0, gray or 0)
  174. alpha = 255
  175. elseif colorType == 2 then
  176. local r, g, b = unpack(row, i0, i1)
  177. color = Color3.fromRGB(r or 0, g or 0, b or 0)
  178. alpha = 255
  179. elseif colorType == 3 then
  180. local palette = self.Palette
  181. local alphaData = self.AlphaData
  182. local index = unpack(row, i0, i1)
  183. index = (index or 0) + 1
  184. if palette then color = palette[index] end
  185. if alphaData then alpha = alphaData[index] end
  186. elseif colorType == 4 then
  187. local gray, a = unpack(row, i0, i1)
  188. color = Color3.fromHSV(0, 0, gray or 0)
  189. alpha = a
  190. elseif colorType == 6 then
  191. local r, g, b, a = unpack(row, i0, i1)
  192. color = Color3.fromRGB(r or 0, g or 0, b or 0)
  193. alpha = a
  194. end
  195.  
  196. if not color then color = Color3.new(1, 1, 1) end
  197. if not alpha then alpha = 255 end
  198. return color, alpha
  199. end
  200.  
  201. function PNG.new(buffer)
  202. local reader = BinaryReader.new(buffer)
  203. local file = { Chunks = {}, Metadata = {}, Reading = true, ZlibStream = "" }
  204. local header = reader:ReadString(8)
  205. if header ~= "\137PNG\r\n\26\n" then error("PNG - Input data is not a PNG file.", 2) end
  206.  
  207. while file.Reading do
  208. local length = reader:ReadInt32()
  209. local chunkType = reader:ReadString(4)
  210. local data, crc
  211. if length > 0 then
  212. data = reader:ForkReader(length)
  213. crc = reader:ReadUInt32()
  214. end
  215. local chunk = { Length = length, Type = chunkType, Data = data, CRC = crc }
  216. local handler = chunks[chunkType]
  217. if handler then handler(file, chunk) end
  218. table.insert(file.Chunks, chunk)
  219. end
  220.  
  221. local success, response = pcall(function()
  222. local result = {}
  223. local index = 0
  224.  
  225. Deflate:InflateZlib({
  226. Input = BinaryReader.new(file.ZlibStream),
  227. Output = function(byte)
  228. index = index + 1
  229. result[index] = string.char(byte)
  230.  
  231. -- Only yield if smooth mode is selected to prevent freezing during decompression
  232. if not BotConfig.InstantDraw and index % 40000 == 0 then
  233. task.wait()
  234. end
  235. end
  236. })
  237. return table.concat(result)
  238. end)
  239.  
  240. if not success then error("PNG - Unable to unpack PNG data. " .. tostring(response), 2) end
  241.  
  242. local width = file.Width
  243. local height = file.Height
  244. local bitDepth = file.BitDepth
  245. local colorType = file.ColorType
  246. local buffer = BinaryReader.new(response)
  247. file.ZlibStream = nil
  248. local bitmap = {}
  249. file.Bitmap = bitmap
  250. local channels = getBytesPerPixel(colorType)
  251. file.NumChannels = channels
  252. local bpp = math.max(1, channels * (bitDepth / 8))
  253. file.BytesPerPixel = bpp
  254.  
  255. for row = 1, height do
  256. if not BotConfig.InstantDraw and row % 2 == 0 then task.wait() end
  257. local filterType = buffer:ReadByte()
  258. local scanline = buffer:ReadBytes(width * bpp, true)
  259. bitmap[row] = {}
  260.  
  261. if filterType == 0 then Unfilter:None(scanline, bitmap, bpp, row)
  262. elseif filterType == 1 then Unfilter:Sub(scanline, bitmap, bpp, row)
  263. elseif filterType == 2 then Unfilter:Up(scanline, bitmap, bpp, row)
  264. elseif filterType == 3 then Unfilter:Average(scanline, bitmap, bpp, row)
  265. elseif filterType == 4 then Unfilter:Paeth(scanline, bitmap, bpp, row) end
  266. end
  267. return setmetatable(file, PNG)
  268. end
  269.  
  270. ---------------------------------------------------------------------------------------------
  271. -- [3. ASYNCHRONOUS MODULE DOWNLOADING]
  272. ---------------------------------------------------------------------------------------------
  273. task.spawn(function()
  274. getfenv().bit32 = bit
  275.  
  276. local function secureGet(url)
  277. local s, r = pcall(function() return game:HttpGet(url) end)
  278. if s then return loadstring(r)() else return nil end
  279. end
  280.  
  281.  
  282.  
  283. if Unfilter and BinaryReader and Deflate and chunks.IDAT and chunks.IHDR then
  284. StatusLabel.Text = "Status: Ready to draw!"
  285. StatusLabel.TextColor3 = Color3.fromRGB(0, 200, 100)
  286. ToggleBtn.Text = "START"
  287. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  288. ToggleBtn.AutoButtonColor = true
  289. else
  290. StatusLabel.Text = "Status: Connection error!"
  291. StatusLabel.TextColor3 = Color3.fromRGB(255, 50, 50)
  292. ToggleBtn.Text = "ERROR"
  293. end
  294. end)
  295.  
  296. ---------------------------------------------------------------------------------------------
  297. -- [4. CANVAS SEARCH AND VALIDATION]
  298. ---------------------------------------------------------------------------------------------
  299. local function FindLocalDrawingCanvas()
  300. local playerGui = LocalPlayer:FindFirstChild("PlayerGui")
  301. if not playerGui then return nil end
  302. local canvasFrame = nil
  303. for _, v in ipairs(playerGui:GetDescendants()) do
  304. if v:IsA("Frame") and v:FindFirstChild("FastCanvas") then canvasFrame = v break end
  305. end
  306. if not canvasFrame then return nil end
  307.  
  308. local successGC, registry = pcall(getgc, true)
  309. if successGC then
  310. for i = 1, #registry do
  311. local obj = registry[i]
  312. if type(obj) == "table" and rawget(obj, "DrawLine") then
  313. if rawget(obj, "CurrentCanvasFrame") == canvasFrame or tostring(rawget(obj, "CurrentCanvasFrame")) == tostring(canvasFrame) then
  314. return obj
  315. end
  316. end
  317. end
  318. end
  319. return nil
  320. end
  321.  
  322. local drawingThread = nil
  323.  
  324. ToggleBtn.MouseButton1Click:Connect(function()
  325. if not Deflate then return end
  326.  
  327. if BotConfig.Enabled then
  328. BotConfig.Enabled = false
  329. ToggleBtn.Text = "START"
  330. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  331. if drawingThread then task.cancel(drawingThread) end
  332. StatusLabel.Text = "Status: Stopped."
  333. ProgressBarFill.Size = UDim2.new(0, 0, 1, 0)
  334. else
  335. LocalDrawingCanvas = FindLocalDrawingCanvas()
  336. if not LocalDrawingCanvas then StatusLabel.Text = "Status: Open the easel first!" return end
  337. if BotConfig.ImageURL == "" or not string.match(BotConfig.ImageURL, "http") then StatusLabel.Text = "Status: Invalid image URL!" return end
  338.  
  339. BotConfig.Enabled = true
  340. ToggleBtn.Text = "STOP"
  341. ToggleBtn.BackgroundColor3 = Color3.fromRGB(170, 40, 40)
  342.  
  343. drawingThread = task.spawn(function()
  344. StatusLabel.Text = "Status: Downloading..."
  345. local successFetch, resultBuffer = pcall(function() return game:HttpGet(BotConfig.ImageURL) end)
  346. if not successFetch then StatusLabel.Text = "Status: Download failed!" BotConfig.Enabled = false ToggleBtn.Text = "START" return end
  347.  
  348. StatusLabel.Text = "Status: Processing..."
  349. if not BotConfig.InstantDraw then task.wait() end
  350.  
  351. local successPng, pngImage = pcall(function() return PNG.new(resultBuffer) end)
  352. if not successPng or not pngImage then
  353. StatusLabel.Text = "Status: Bad image file!"
  354. BotConfig.Enabled = false ToggleBtn.Text = "START" return
  355. end
  356.  
  357. local resX = tonumber(LocalDrawingCanvas.CurrentResX or 150)
  358. local resY = tonumber(LocalDrawingCanvas.CurrentResY or 150)
  359.  
  360. StatusLabel.Text = "Status: Drawing..."
  361.  
  362. for y = 1, resY do
  363. if not BotConfig.Enabled then return end
  364.  
  365. for x = 1, resX do
  366. local srcX = math.clamp(math.floor((x / resX) * pngImage.Width), 1, pngImage.Width)
  367. local srcY = math.clamp(math.floor((y / resY) * pngImage.Height), 1, pngImage.Height)
  368.  
  369. local color, alpha = pngImage:GetPixel(srcX, srcY)
  370.  
  371. if alpha > 15 then
  372. local pPos = Vector2.new(x, y)
  373. LocalDrawingCanvas:DrawLine(pPos, pPos, color, 1)
  374. end
  375. end
  376.  
  377. -- Only yield and update visual progress bar if we are NOT in instant mode
  378. if not BotConfig.InstantDraw then
  379. ProgressBarFill.Size = UDim2.new(y / resY, 0, 1, 0)
  380. if y % 3 == 0 then
  381. if LocalDrawingCanvas.Render then LocalDrawingCanvas:Render() end
  382. task.wait()
  383. end
  384. end
  385. end
  386.  
  387. if LocalDrawingCanvas.Render then LocalDrawingCanvas:Render() end
  388. ProgressBarFill.Size = UDim2.new(1, 0, 1, 0)
  389. StatusLabel.Text = "Status: Done!"
  390. BotConfig.Enabled = false
  391. ToggleBtn.Text = "START"
  392. ToggleBtn.BackgroundColor3 = Color3.fromRGB(40, 150, 80)
  393. end)
  394. end
  395. end)
RAW Paste Data Copied