-- By LeakD - discord.gg/qteAQmfJmP
local p1, p2
local mode = 0
local url, res, zoom = "", 100, 1
local function notify(txt)
pcall(function() game.StarterGui:SetCore("SendNotification", {Title="AutoDraw", Text=txt, Duration=3}) end)
end
game:GetService("UserInputService").InputBegan:Connect(function(inp, gp)
if mode == 0 or gp then return end
if inp.UserInputType == Enum.UserInputType.MouseButton1 or inp.UserInputType == Enum.UserInputType.Touch then
local cp = workspace.Map.Important.Canvas
local m = game.Players.LocalPlayer:GetMouse()
local os = cp.CFrame:PointToObjectSpace(m.Hit.Position)
local cx, cy = 512, 512
pcall(function()
local cv = require(game.Players.LocalPlayer.PlayerScripts.Libraries.DrawingHandler.Layers):GetCurrentCanvas("cnv_z8k")
cx, cy = cv.CurrentResX or 512, cv.CurrentResY or 512
end)
local px = math.clamp((os.X + cp.Size.X / 2) / cp.Size.X * cx, 1, cx)
local py = math.clamp(((os.Z + cp.Size.Z / 2) / cp.Size.Z) * cy, 1, cy)
if mode == 1 then
p1 = Vector2.new(math.round(px), math.round(py))
mode = 2
notify("now click bottom-right")
elseif mode == 2 then
p2 = Vector2.new(math.round(px), math.round(py))
mode = 0
notify("box set")
end
end
end)
local rf = loadstring(game:HttpGet('https://sirius.menu/rayfield'))()
local win = rf:CreateWindow({Name="Auto Draw - Open source", LoadingTitle="Auto Draw - Open source", LoadingSubtitle="By LeakD - discord.gg/qteAQmfJmP", Theme="Ocean", DisableRayfieldPrompts=true, DisableBuildWarnings=true})
local tab = win:CreateTab("Auto Draw", "pencil")
tab:CreateInput({Name="Image URL", PlaceholderText="URL here", RemoveTextAfterFocusLost=false, Callback=function(t) url=t end})
tab:CreateSlider({Name="Quality %", Range={1,100}, Increment=1, Suffix="%", CurrentValue=100, Flag="res", Callback=function(v) res=v end})
tab:CreateSlider({Name="Zoom", Range={1,10}, Increment=0.5, Suffix="x", CurrentValue=1, Flag="zoom", Callback=function(v) zoom=v end})
tab:CreateButton({Name="Set Box (2 Clicks)", Callback=function() mode=1; notify("click top-left corner") end})
tab:CreateButton({Name="Set Box (Full Screen)", Callback=function()
pcall(function()
local cv = require(game.Players.LocalPlayer.PlayerScripts.Libraries.DrawingHandler.Layers):GetCurrentCanvas("cnv_z8k")
local cx, cy = cv.CurrentResX or 512, cv.CurrentResY or 512
p1 = Vector2.new(1, 1)
p2 = Vector2.new(cx, cy)
notify("box set to full canvas")
end)
end})
tab:CreateButton({Name="Start", Callback=function()
task.spawn(function()
if url=="" then notify("no url bro") return end
if not p1 or not p2 then notify("set box first") return end
local dh = game.Players.LocalPlayer.PlayerScripts.Libraries.DrawingHandler
local dhm, layers = require(dh), require(dh.Layers)
pcall(function() if dhm.ActivateTool then dhm:ActivateTool("Brush") end end)
notify("downloading...")
local r = request({Url=url, Method="GET"})
if r.StatusCode ~= 200 then notify("download failed") return end
local ext = url:match("%.([%w]+)$") or "png"
if ext:lower() == "jpeg" then ext = "jpg" end
local fn = "ad_tmp." .. ext:lower()
writefile(fn, r.Body)
local img
local s, e = pcall(function() img = game:GetService("AssetService"):CreateEditableImageAsync(getcustomasset(fn)) end)
if not s or not img then
notify("bad image format")
if isfile(fn) then delfile(fn) end
return
end
local cv = layers:GetCurrentCanvas("cnv_z8k")
local ic = cv.InternalCanvas
local sx, sy, ex, ey = p1.X, p1.Y, p2.X, p2.Y
local w, h = math.abs(ex-sx), math.abs(ey-sy)
local dx, dy = ex>sx and 1 or -1, ey>sy and 1 or -1
local stp = math.max(1, math.floor(100/res))
local bsz = math.max(1, math.floor(zoom * stp))
local rawSz = img.Size
local imgRatio = rawSz.X / rawSz.Y
local drawW, drawH = w, h
if imgRatio > w / h then
drawH = w / imgRatio
else
drawW = h * imgRatio
end
drawW, drawH = math.round(drawW), math.round(drawH)
pcall(function()
img:Resize(Vector2.new(drawW, drawH))
end)
local sz = img.Size
local px = img:ReadPixelsBuffer(Vector2.zero, sz)
local offX = (w - drawW) / 2
local offY = (h - drawH) / 2
notify("drawing...")
local cw, ch = cv.CurrentResX or 512, cv.CurrentResY or 512
local d = 0
for y=0, drawH, stp do
for x=0, drawW, stp do
local ix, iy = math.floor((x/drawW)*sz.X), math.floor((y/drawH)*sz.Y)
ix = math.clamp(ix, 0, sz.X-1)
iy = math.clamp(iy, 0, sz.Y-1)
local i = (iy*sz.X + ix)*4
local a = buffer.readu8(px, i+3)/255
if a>0 then
local tx = math.floor(sx+((x+offX)*zoom*dx))
local ty = math.floor(sy+((y+offY)*zoom*dy))
local r, g, b = buffer.readu8(px, i)/255, buffer.readu8(px, i+1)/255, buffer.readu8(px, i+2)/255
if ic.SetRGBA then
for by=0, bsz-1 do
for bx=0, bsz-1 do
local nx, ny = tx + (bx*dx), ty + (by*dy)
if nx>=1 and nx<=cw and ny>=1 and ny<=ch then
ic:SetRGBA(nx, ny, r, g, b, 1)
end
end
end
else
local col = Color3.new(r, g, b)
for by=0, bsz-1 do
for bx=0, bsz-1 do
local nx, ny = tx + (bx*dx), ty + (by*dy)
if nx>=1 and nx<=cw and ny>=1 and ny<=ch then
ic:SetColor3(nx, ny, col)
end
end
end
end
end
d = d+1
if d%15000==0 then
if cv.Render then cv:Render() elseif ic.Render then ic:Render() end
task.wait()
end
end
end
if cv.Render then cv:Render() elseif ic.Render then ic:Render() end
if isfile and isfile(fn) then delfile(fn) end
notify("done!")
end)
end})
rf:LoadConfiguration()
Comments
Join the discussion about this script.
No comments yet
Be the first to share your thoughts!