Advertisement
Guest User

spray paint

a guest
Mar 24th, 2022
1,607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.22 KB | None | 0 0
  1. --You hold IMMENSE power
  2.  
  3. --[[-------------------------Info--------------------------------
  4.  
  5. -Simply press execute to open the gui
  6.  
  7. -To use, you need a link to a png image, preferrably neither dimensions are much larger than 256,
  8. but it works best (faster) under 128 (if a dimension is too large, it won't work)
  9.  
  10. -I personally use paint.net to resize the image, then paste it into a private discord to get the link
  11.  
  12. -Once you have the link, you can paste it into the link field
  13. -The size field is optional and defaults to 0.2, and its max value is 1.2 (if you don't have the gamepass)
  14. -If you have the gamepass (not reccomended cuz they ban for exploits and its too large to fit anyways)
  15. you would need to change MAX_PIXEL_SIZE below
  16. -Once you have the link and desired size, click "Go" and your next left click will attempt to draw the image (centered) on the surface
  17. -If it gets stuck, you can simply close it with no consequences (I think) and execute it again
  18.  
  19. -Freecam (shift+p) helps a lot
  20.  
  21. -------------------------------------------------------------]]--
  22.  
  23. --------THIS SCRIPT WAS MADE WITH SYNAPSE X IN MIND----------
  24.  
  25. --IF YOU ARE NOT USING SYNAPSE X:
  26.  
  27. --Replace this with your executor's http request function
  28. local REQUEST_FUNC = syn.request
  29.  
  30. --Replace this with your executor's gui protection function
  31. --(This can be set to nil and the script will run fine, not very necessary tbh)
  32. local PROTECT_FUNC = syn.protect
  33.  
  34. -------------------------------------------------------------
  35.  
  36. --Constants
  37. local MAX_PIXEL_SIZE = 1.2 --change this if you own the gamepass
  38. local RAY_LENGTH = 1000 --how far the ray will try to go
  39. local SURFACE_OFFSET = 0.2 --distance from the surface you place it on
  40. local PIXEL_DEPTH = 0.001 --idk if this matters, but it's the Y size of the pixel (supposedly)
  41.  
  42. -------------------------------------------------------------
  43.  
  44. --pcall cuz im dumb and also for error messages in console
  45. local succ,err = pcall(function()
  46.  
  47.  
  48. -- PNG parsing module (very helpful and not mine)
  49. -- My code starts around line 1084 or something if you are interested in it
  50.  
  51. -- Drawing Library [edited by spooky hack man on v3rmillion]
  52.  
  53. local PNG = {}
  54. PNG.__index = PNG
  55.  
  56. local chunks = {};
  57. local function IDAT(file, chunk)
  58. local crc = chunk.CRC
  59. local hash = file.Hash or 0
  60.  
  61. local data = chunk.Data
  62. local buffer = data.Buffer
  63.  
  64. file.Hash = bit32.bxor(hash, crc)
  65. file.ZlibStream = file.ZlibStream .. buffer
  66. end
  67.  
  68. chunks['IDAT'] = IDAT;
  69.  
  70. local function IEND(file)
  71. file.Reading = nil
  72. end
  73. chunks['IEND'] = IEND;
  74.  
  75. local function IHDR(file, chunk)
  76. local data = chunk.Data
  77.  
  78. file.Width = data:ReadInt32();
  79. file.Height = data:ReadInt32();
  80.  
  81. file.BitDepth = data:ReadByte();
  82. file.ColorType = data:ReadByte();
  83.  
  84. file.Methods =
  85. {
  86. Compression = data:ReadByte();
  87. Filtering = data:ReadByte();
  88. Interlace = data:ReadByte();
  89. }
  90. end
  91.  
  92.  
  93. chunks['IHDR'] = IHDR;
  94.  
  95. local function PLTE(file, chunk)
  96. if not file.Palette then
  97. file.Palette = {}
  98. end
  99.  
  100. local data = chunk.Data
  101. local palette = data:ReadAllBytes()
  102.  
  103. if #palette % 3 ~= 0 then
  104. error("[ERROR]: Invalid PLTE chunk.")
  105. end
  106.  
  107. for i = 1, #palette, 3 do
  108. local r = palette[i]
  109. local g = palette[i + 1]
  110. local b = palette[i + 2]
  111.  
  112. local color = Color3.fromRGB(r, g, b)
  113. local index = #file.Palette + 1
  114.  
  115. file.Palette[index] = color
  116. end
  117. end
  118.  
  119.  
  120. chunks['PLTE'] = PLTE;
  121.  
  122. local function bKGD(file, chunk)
  123. local data = chunk.Data
  124.  
  125. local bitDepth = file.BitDepth
  126. local colorType = file.ColorType
  127.  
  128. bitDepth = (2 ^ bitDepth) - 1
  129.  
  130. if colorType == 3 then
  131. local index = data:ReadByte()
  132. file.BackgroundColor = file.Palette[index]
  133. elseif colorType == 0 or colorType == 4 then
  134. local gray = data:ReadUInt16() / bitDepth
  135. file.BackgroundColor = Color3.fromHSV(0, 0, gray)
  136. elseif colorType == 2 or colorType == 6 then
  137. local r = data:ReadUInt16() / bitDepth
  138. local g = data:ReadUInt16() / bitDepth
  139. local b = data:ReadUInt16() / bitDepth
  140. file.BackgroundColor = Color3.new(r, g, b)
  141. end
  142. end
  143.  
  144. chunks['bKGD'] = bKGD;
  145.  
  146. local colors = {"White", "Red", "Green", "Blue"}
  147.  
  148. local function cHRM(file, chunk)
  149. local chrome = {}
  150. local data = chunk.Data
  151.  
  152. for i = 1, 4 do
  153. local color = colors[i]
  154.  
  155. chrome[color] =
  156. {
  157. [1] = data:ReadUInt32() / 10e4;
  158. [2] = data:ReadUInt32() / 10e4;
  159. }
  160. end
  161.  
  162. file.Chromaticity = chrome
  163. end
  164.  
  165. chunks['cHRM'] = cHRM;
  166.  
  167. local function gAMA(file, chunk)
  168. local data = chunk.Data
  169. local value = data:ReadUInt32()
  170. file.Gamma = value / 10e4
  171. end
  172.  
  173. chunks['gAMA'] = gAMA;
  174.  
  175. local function sRGB(file, chunk)
  176. local data = chunk.Data
  177. file.RenderIntent = data:ReadByte()
  178. end
  179.  
  180. chunks['sRGB'] = sRGB;
  181.  
  182. local function tEXt(file, chunk)
  183. local data = chunk.Data
  184. local key, value = "", ""
  185.  
  186. for byte in data:IterateBytes() do
  187. local char = string.char(byte)
  188.  
  189. if char == '\0' then
  190. key = value
  191. value = ""
  192. else
  193. value = value .. char
  194. end
  195. end
  196.  
  197. file.Metadata[key] = value
  198. end
  199.  
  200. chunks['tEXt'] = tEXt;
  201.  
  202. local function tIME(file, chunk)
  203. local data = chunk.Data
  204.  
  205. local timeStamp =
  206. {
  207. Year = data:ReadUInt16();
  208. Month = data:ReadByte();
  209. Day = data:ReadByte();
  210.  
  211. Hour = data:ReadByte();
  212. Minute = data:ReadByte();
  213. Second = data:ReadByte();
  214. }
  215.  
  216. file.TimeStamp = timeStamp
  217. end
  218.  
  219. chunks['tIME'] = tIME;
  220.  
  221. local function tRNS(file, chunk)
  222. local data = chunk.Data
  223.  
  224. local bitDepth = file.BitDepth
  225. local colorType = file.ColorType
  226.  
  227. bitDepth = (2 ^ bitDepth) - 1
  228.  
  229. if colorType == 3 then
  230. local palette = file.Palette
  231. local alphaMap = {}
  232.  
  233. for i = 1, #palette do
  234. local alpha = data:ReadByte()
  235.  
  236. if not alpha then
  237. alpha = 255
  238. end
  239.  
  240. alphaMap[i] = alpha
  241. end
  242.  
  243. file.AlphaData = alphaMap
  244. elseif colorType == 0 then
  245. local grayAlpha = data:ReadUInt16()
  246. file.Alpha = grayAlpha / bitDepth
  247. elseif colorType == 2 then
  248. -- TODO: This seems incorrect...
  249. local r = data:ReadUInt16() / bitDepth
  250. local g = data:ReadUInt16() / bitDepth
  251. local b = data:ReadUInt16() / bitDepth
  252. file.Alpha = Color3.new(r, g, b)
  253. else
  254. error("[ERROR]: Invalid tRNS chunk.")
  255. end
  256. end
  257.  
  258.  
  259. chunks['tRNS'] = tRNS;
  260.  
  261. local Deflate = {}
  262.  
  263. local band = bit32.band
  264. local lshift = bit32.lshift
  265. local rshift = bit32.rshift
  266.  
  267. local BTYPE_NO_COMPRESSION = 0
  268. local BTYPE_FIXED_HUFFMAN = 1
  269. local BTYPE_DYNAMIC_HUFFMAN = 2
  270.  
  271. local lens = -- Size base for length codes 257..285
  272. {
  273. [0] = 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
  274. 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
  275. }
  276.  
  277. local lext = -- Extra bits for length codes 257..285
  278. {
  279. [0] = 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
  280. 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
  281. }
  282.  
  283. local dists = -- Offset base for distance codes 0..29
  284. {
  285. [0] = 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
  286. 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  287. 8193, 12289, 16385, 24577
  288. }
  289.  
  290. local dext = -- Extra bits for distance codes 0..29
  291. {
  292. [0] = 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
  293. 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
  294. 12, 12, 13, 13
  295. }
  296.  
  297. local order = -- Permutation of code length codes
  298. {
  299. 16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
  300. 11, 4, 12, 3, 13, 2, 14, 1, 15
  301. }
  302.  
  303. -- Fixed literal table for BTYPE_FIXED_HUFFMAN
  304. local fixedLit = {0, 8, 144, 9, 256, 7, 280, 8, 288}
  305.  
  306. -- Fixed distance table for BTYPE_FIXED_HUFFMAN
  307. local fixedDist = {0, 5, 32}
  308.  
  309. local function createState(bitStream)
  310. local state =
  311. {
  312. Output = bitStream;
  313. Window = {};
  314. Pos = 1;
  315. }
  316.  
  317. return state
  318. end
  319.  
  320. local function write(state, byte)
  321. local pos = state.Pos
  322. state.Output(byte)
  323. state.Window[pos] = byte
  324. state.Pos = pos % 32768 + 1 -- 32K
  325. end
  326.  
  327. local function memoize(fn)
  328. local meta = {}
  329. local memoizer = setmetatable({}, meta)
  330.  
  331. function meta:__index(k)
  332. local v = fn(k)
  333. memoizer[k] = v
  334.  
  335. return v
  336. end
  337.  
  338. return memoizer
  339. end
  340.  
  341. -- small optimization (lookup table for powers of 2)
  342. local pow2 = memoize(function (n)
  343. return 2 ^ n
  344. end)
  345.  
  346. -- weak metatable marking objects as bitstream type
  347. local isBitStream = setmetatable({}, { __mode = 'k' })
  348.  
  349. local function createBitStream(reader)
  350. local buffer = 0
  351. local bitsLeft = 0
  352.  
  353. local stream = {}
  354. isBitStream[stream] = true
  355.  
  356. function stream:GetBitsLeft()
  357. return bitsLeft
  358. end
  359.  
  360. function stream:Read(count)
  361. count = count or 1
  362.  
  363. while bitsLeft < count do
  364. local byte = reader:ReadByte()
  365.  
  366. if not byte then
  367. return
  368. end
  369.  
  370. buffer = buffer + lshift(byte, bitsLeft)
  371. bitsLeft = bitsLeft + 8
  372. end
  373.  
  374. local bits
  375.  
  376. if count == 0 then
  377. bits = 0
  378. elseif count == 32 then
  379. bits = buffer
  380. buffer = 0
  381. else
  382. bits = band(buffer, rshift(2^32 - 1, 32 - count))
  383. buffer = rshift(buffer, count)
  384. end
  385.  
  386. bitsLeft = bitsLeft - count
  387. return bits
  388. end
  389.  
  390. return stream
  391. end
  392.  
  393. local function getBitStream(obj)
  394. if isBitStream[obj] then
  395. return obj
  396. end
  397.  
  398. return createBitStream(obj)
  399. end
  400.  
  401. local function sortHuffman(a, b)
  402. return a.NumBits == b.NumBits and a.Value < b.Value or a.NumBits < b.NumBits
  403. end
  404.  
  405. local function msb(bits, numBits)
  406. local res = 0
  407.  
  408. for i = 1, numBits do
  409. res = lshift(res, 1) + band(bits, 1)
  410. bits = rshift(bits, 1)
  411. end
  412.  
  413. return res
  414. end
  415.  
  416. local function createHuffmanTable(init, isFull)
  417. local hTable = {}
  418.  
  419. if isFull then
  420. for val, numBits in pairs(init) do
  421. if numBits ~= 0 then
  422. hTable[#hTable + 1] =
  423. {
  424. Value = val;
  425. NumBits = numBits;
  426. }
  427. end
  428. end
  429. else
  430. for i = 1, #init - 2, 2 do
  431. local firstVal = init[i]
  432.  
  433. local numBits = init[i + 1]
  434. local nextVal = init[i + 2]
  435.  
  436. if numBits ~= 0 then
  437. for val = firstVal, nextVal - 1 do
  438. hTable[#hTable + 1] =
  439. {
  440. Value = val;
  441. NumBits = numBits;
  442. }
  443. end
  444. end
  445. end
  446. end
  447.  
  448. table.sort(hTable, sortHuffman)
  449.  
  450. local code = 1
  451. local numBits = 0
  452.  
  453. for i, slide in ipairs(hTable) do
  454. if slide.NumBits ~= numBits then
  455. code = code * pow2[slide.NumBits - numBits]
  456. numBits = slide.NumBits
  457. end
  458.  
  459. slide.Code = code
  460. code = code + 1
  461. end
  462.  
  463. local minBits = math.huge
  464. local look = {}
  465.  
  466. for i, slide in ipairs(hTable) do
  467. minBits = math.min(minBits, slide.NumBits)
  468. look[slide.Code] = slide.Value
  469. end
  470.  
  471. local firstCode = memoize(function (bits)
  472. return pow2[minBits] + msb(bits, minBits)
  473. end)
  474.  
  475. function hTable:Read(bitStream)
  476. local code = 1 -- leading 1 marker
  477. local numBits = 0
  478.  
  479. while true do
  480. if numBits == 0 then -- small optimization (optional)
  481. local index = bitStream:Read(minBits)
  482. numBits = numBits + minBits
  483. code = firstCode[index]
  484. else
  485. local bit = bitStream:Read()
  486. numBits = numBits + 1
  487. code = code * 2 + bit -- MSB first
  488. end
  489.  
  490. local val = look[code]
  491.  
  492. if val then
  493. return val
  494. end
  495. end
  496. end
  497.  
  498. return hTable
  499. end
  500.  
  501. local function parseZlibHeader(bitStream)
  502. -- Compression Method
  503. local cm = bitStream:Read(4)
  504.  
  505. -- Compression info
  506. local cinfo = bitStream:Read(4)
  507.  
  508. -- FLaGs: FCHECK (check bits for CMF and FLG)
  509. local fcheck = bitStream:Read(5)
  510.  
  511. -- FLaGs: FDICT (present dictionary)
  512. local fdict = bitStream:Read(1)
  513.  
  514. -- FLaGs: FLEVEL (compression level)
  515. local flevel = bitStream:Read(2)
  516.  
  517. -- CMF (Compresion Method and flags)
  518. local cmf = cinfo * 16 + cm
  519.  
  520. -- FLaGs
  521. local flg = fcheck + fdict * 32 + flevel * 64
  522.  
  523. if cm ~= 8 then -- not "deflate"
  524. error("[ERROR]: Unrecognized image Compression Method: " .. tostring(cm))
  525. end
  526.  
  527. if cinfo > 7 then
  528. error("[ERROR]: Invalid image Window Size: cinfo -> " .. tostring(cinfo))
  529. end
  530.  
  531. local windowSize = 2 ^ (cinfo + 8)
  532.  
  533. if (cmf * 256 + flg) % 31 ~= 0 then
  534. error("[ERROR]: Invalid image header (bad fcheck sum)")
  535. end
  536.  
  537. if fdict == 1 then
  538. error("[TODO]: - FDICT not currently implemented")
  539. end
  540.  
  541. return windowSize
  542. end
  543.  
  544. local function parseHuffmanTables(bitStream)
  545. local numLits = bitStream:Read(5) -- # of literal/length codes - 257
  546. local numDists = bitStream:Read(5) -- # of distance codes - 1
  547. local numCodes = bitStream:Read(4) -- # of code length codes - 4
  548.  
  549. local codeLens = {}
  550.  
  551. for i = 1, numCodes + 4 do
  552. local index = order[i]
  553. codeLens[index] = bitStream:Read(3)
  554. end
  555.  
  556. codeLens = createHuffmanTable(codeLens, true)
  557.  
  558. local function decode(numCodes)
  559. local init = {}
  560. local numBits
  561. local val = 0
  562.  
  563. while val < numCodes do
  564. local codeLen = codeLens:Read(bitStream)
  565. local numRepeats
  566.  
  567. if codeLen <= 15 then
  568. numRepeats = 1
  569. numBits = codeLen
  570. elseif codeLen == 16 then
  571. numRepeats = 3 + bitStream:Read(2)
  572. elseif codeLen == 17 then
  573. numRepeats = 3 + bitStream:Read(3)
  574. numBits = 0
  575. elseif codeLen == 18 then
  576. numRepeats = 11 + bitStream:Read(7)
  577. numBits = 0
  578. end
  579.  
  580. for i = 1, numRepeats do
  581. init[val] = numBits
  582. val = val + 1
  583. end
  584. end
  585.  
  586. return createHuffmanTable(init, true)
  587. end
  588.  
  589. local numLitCodes = numLits + 257
  590. local numDistCodes = numDists + 1
  591.  
  592. local litTable = decode(numLitCodes)
  593. local distTable = decode(numDistCodes)
  594.  
  595. return litTable, distTable
  596. end
  597.  
  598. local function parseCompressedItem(bitStream, state, litTable, distTable)
  599. local val = litTable:Read(bitStream)
  600.  
  601. if val < 256 then -- literal
  602. write(state, val)
  603. elseif val == 256 then -- end of block
  604. return true
  605. else
  606. local lenBase = lens[val - 257]
  607. local numExtraBits = lext[val - 257]
  608.  
  609. local extraBits = bitStream:Read(numExtraBits)
  610. local len = lenBase + extraBits
  611.  
  612. local distVal = distTable:Read(bitStream)
  613. local distBase = dists[distVal]
  614.  
  615. local distNumExtraBits = dext[distVal]
  616. local distExtraBits = bitStream:Read(distNumExtraBits)
  617.  
  618. local dist = distBase + distExtraBits
  619.  
  620. for i = 1, len do
  621. local pos = (state.Pos - 1 - dist) % 32768 + 1
  622. local byte = assert(state.Window[pos], "invalid distance")
  623. write(state, byte)
  624. end
  625. end
  626.  
  627. return false
  628. end
  629.  
  630. local function parseBlock(bitStream, state)
  631. local bFinal = bitStream:Read(1)
  632. local bType = bitStream:Read(2)
  633.  
  634. if bType == BTYPE_NO_COMPRESSION then
  635. local left = bitStream:GetBitsLeft()
  636. bitStream:Read(left)
  637.  
  638. local len = bitStream:Read(16)
  639. local nlen = bitStream:Read(16)
  640.  
  641. for i = 1, len do
  642. local byte = bitStream:Read(8)
  643. write(state, byte)
  644. end
  645. elseif bType == BTYPE_FIXED_HUFFMAN or bType == BTYPE_DYNAMIC_HUFFMAN then
  646. local litTable, distTable
  647.  
  648. if bType == BTYPE_DYNAMIC_HUFFMAN then
  649. litTable, distTable = parseHuffmanTables(bitStream)
  650. else
  651. litTable = createHuffmanTable(fixedLit)
  652. distTable = createHuffmanTable(fixedDist)
  653. end
  654.  
  655. repeat until parseCompressedItem(bitStream, state, litTable, distTable)
  656. else
  657. error("[ERROR]: Unrecognized compression type.")
  658. end
  659.  
  660. return bFinal ~= 0
  661. end
  662.  
  663. function Deflate:Inflate(io)
  664. local state = createState(io.Output)
  665. local bitStream = getBitStream(io.Input)
  666.  
  667. repeat until parseBlock(bitStream, state)
  668. end
  669.  
  670. function Deflate:InflateZlib(io)
  671. local bitStream = getBitStream(io.Input)
  672. local windowSize = parseZlibHeader(bitStream)
  673.  
  674. self:Inflate
  675. {
  676. Input = bitStream;
  677. Output = io.Output;
  678. }
  679.  
  680. local bitsLeft = bitStream:GetBitsLeft()
  681. bitStream:Read(bitsLeft)
  682. end
  683.  
  684. local Unfilter = {}
  685.  
  686. function Unfilter:None(scanline, pixels, bpp, row)
  687. for i = 1, #scanline do
  688. pixels[row][i] = scanline[i]
  689. end
  690. end
  691.  
  692. function Unfilter:Sub(scanline, pixels, bpp, row)
  693. for i = 1, bpp do
  694. pixels[row][i] = scanline[i]
  695. end
  696.  
  697. for i = bpp + 1, #scanline do
  698. local x = scanline[i]
  699. local a = pixels[row][i - bpp]
  700. pixels[row][i] = bit32.band(x + a, 0xFF)
  701. end
  702. end
  703.  
  704. function Unfilter:Up(scanline, pixels, bpp, row)
  705. if row > 1 then
  706. local upperRow = pixels[row - 1]
  707.  
  708. for i = 1, #scanline do
  709. local x = scanline[i]
  710. local b = upperRow[i]
  711. pixels[row][i] = bit32.band(x + b, 0xFF)
  712. end
  713. else
  714. self:None(scanline, pixels, bpp, row)
  715. end
  716. end
  717.  
  718. function Unfilter:Average(scanline, pixels, bpp, row)
  719. if row > 1 then
  720. for i = 1, bpp do
  721. local x = scanline[i]
  722. local b = pixels[row - 1][i]
  723.  
  724. b = bit32.rshift(b, 1)
  725. pixels[row][i] = bit32.band(x + b, 0xFF)
  726. end
  727.  
  728. for i = bpp + 1, #scanline do
  729. local x = scanline[i]
  730. local b = pixels[row - 1][i]
  731.  
  732. local a = pixels[row][i - bpp]
  733. local ab = bit32.rshift(a + b, 1)
  734.  
  735. pixels[row][i] = bit32.band(x + ab, 0xFF)
  736. end
  737. else
  738. for i = 1, bpp do
  739. pixels[row][i] = scanline[i]
  740. end
  741.  
  742. for i = bpp + 1, #scanline do
  743. local x = scanline[i]
  744. local b = pixels[row - 1][i]
  745.  
  746. b = bit32.rshift(b, 1)
  747. pixels[row][i] = bit32.band(x + b, 0xFF)
  748. end
  749. end
  750. end
  751.  
  752. function Unfilter:Paeth(scanline, pixels, bpp, row)
  753. if row > 1 then
  754. local pr
  755.  
  756. for i = 1, bpp do
  757. local x = scanline[i]
  758. local b = pixels[row - 1][i]
  759. pixels[row][i] = bit32.band(x + b, 0xFF)
  760. end
  761.  
  762. for i = bpp + 1, #scanline do
  763. local a = pixels[row][i - bpp]
  764. local b = pixels[row - 1][i]
  765. local c = pixels[row - 1][i - bpp]
  766.  
  767. local x = scanline[i]
  768. local p = a + b - c
  769.  
  770. local pa = math.abs(p - a)
  771. local pb = math.abs(p - b)
  772. local pc = math.abs(p - c)
  773.  
  774. if pa <= pb and pa <= pc then
  775. pr = a
  776. elseif pb <= pc then
  777. pr = b
  778. else
  779. pr = c
  780. end
  781.  
  782. pixels[row][i] = bit32.band(x + pr, 0xFF)
  783. end
  784. else
  785. self:Sub(scanline, pixels, bpp, row)
  786. end
  787. end
  788.  
  789.  
  790. local BinaryReader = {}
  791. BinaryReader.__index = BinaryReader
  792.  
  793. function BinaryReader.new(buffer)
  794. local reader =
  795. {
  796. Position = 1;
  797. Buffer = buffer;
  798. Length = #buffer;
  799. }
  800.  
  801. return setmetatable(reader, BinaryReader)
  802. end
  803.  
  804. function BinaryReader:ReadByte()
  805. local buffer = self.Buffer
  806. local pos = self.Position
  807.  
  808. if pos <= self.Length then
  809. local result = buffer:sub(pos, pos)
  810. self.Position = pos + 1
  811.  
  812. return result:byte()
  813. end
  814. end
  815.  
  816. function BinaryReader:ReadBytes(count, asArray)
  817. local values = {}
  818.  
  819. for i = 1, count do
  820. values[i] = self:ReadByte()
  821. end
  822.  
  823. if asArray then
  824. return values
  825. end
  826.  
  827. return unpack(values)
  828. end
  829.  
  830. function BinaryReader:ReadAllBytes()
  831. return self:ReadBytes(self.Length, true)
  832. end
  833.  
  834. function BinaryReader:IterateBytes()
  835. return function ()
  836. return self:ReadByte()
  837. end
  838. end
  839.  
  840. function BinaryReader:TwosComplementOf(value, numBits)
  841. if value >= (2 ^ (numBits - 1)) then
  842. value = value - (2 ^ numBits)
  843. end
  844.  
  845. return value
  846. end
  847.  
  848. function BinaryReader:ReadUInt16()
  849. local upper, lower = self:ReadBytes(2)
  850. return (upper * 256) + lower
  851. end
  852.  
  853. function BinaryReader:ReadInt16()
  854. local unsigned = self:ReadUInt16()
  855. return self:TwosComplementOf(unsigned, 16)
  856. end
  857.  
  858. function BinaryReader:ReadUInt32()
  859. local upper = self:ReadUInt16()
  860. local lower = self:ReadUInt16()
  861.  
  862. return (upper * 65536) + lower
  863. end
  864.  
  865. function BinaryReader:ReadInt32()
  866. local unsigned = self:ReadUInt32()
  867. return self:TwosComplementOf(unsigned, 32)
  868. end
  869.  
  870. function BinaryReader:ReadString(length)
  871. if length == nil then
  872. length = self:ReadByte()
  873. end
  874.  
  875. local pos = self.Position
  876. local nextPos = math.min(self.Length, pos + length)
  877.  
  878. local result = self.Buffer:sub(pos, nextPos - 1)
  879. self.Position = nextPos
  880.  
  881. return result
  882. end
  883.  
  884. function BinaryReader:ForkReader(length)
  885. local chunk = self:ReadString(length)
  886. return BinaryReader.new(chunk)
  887. end
  888.  
  889.  
  890. local function getBytesPerPixel(colorType)
  891. if colorType == 0 or colorType == 3 then
  892. return 1
  893. elseif colorType == 4 then
  894. return 2
  895. elseif colorType == 2 then
  896. return 3
  897. elseif colorType == 6 then
  898. return 4
  899. else
  900. return 0
  901. end
  902. end
  903.  
  904. local function clampInt(value, min, max)
  905. local num = tonumber(value) or 0
  906. num = math.floor(num + .5)
  907.  
  908. return math.clamp(num, min, max)
  909. end
  910.  
  911. local function indexBitmap(file, x, y)
  912. local width = file.Width
  913. local height = file.Height
  914.  
  915. local x = clampInt(x, 1, width)
  916. local y = clampInt(y, 1, height)
  917.  
  918. local bitmap = file.Bitmap
  919. local bpp = file.BytesPerPixel
  920.  
  921. local i0 = ((x - 1) * bpp) + 1
  922. local i1 = i0 + bpp
  923.  
  924. return bitmap[y], i0, i1
  925. end
  926.  
  927. function PNG:GetPixel(t,x, y)
  928. local row, i0, i1 = indexBitmap(t, x, y)
  929. local colorType = t.ColorType
  930. self = t;
  931.  
  932. local color, alpha do
  933. if colorType == 0 then
  934. local gray = unpack(row, i0, i1)
  935. color = Color3.fromHSV(0, 0, gray)
  936. alpha = 255
  937. elseif colorType == 2 then
  938. local r, g, b = unpack(row, i0, i1)
  939. color = Color3.fromRGB(r, g, b)
  940. alpha = 255
  941. elseif colorType == 3 then
  942. local palette = self.Palette
  943. local alphaData = self.AlphaData
  944.  
  945. local index = unpack(row, i0, i1)
  946. index = index + 1
  947.  
  948. if palette then
  949. color = palette[index]
  950. end
  951.  
  952. if alphaData then
  953. alpha = alphaData[index]
  954. end
  955. elseif colorType == 4 then
  956. local gray, a = unpack(row, i0, i1)
  957. color = Color3.fromHSV(0, 0, gray)
  958. alpha = a
  959. elseif colorType == 6 then
  960. local r, g, b, a = unpack(row, i0, i1)
  961. color = Color3.fromRGB(r, g, b, a)
  962. alpha = a
  963. end
  964. end
  965.  
  966. if not color then
  967. color = Color3.new()
  968. end
  969.  
  970. if not alpha then
  971. alpha = 255
  972. end
  973.  
  974. return color, alpha
  975. end
  976.  
  977. function PNG.new(buffer)
  978. -- Create the reader.
  979. local reader = BinaryReader.new(buffer)
  980.  
  981. -- Create the file object.
  982. local file =
  983. {
  984. Chunks = {};
  985. Metadata = {};
  986.  
  987. Reading = true;
  988. ZlibStream = "";
  989. }
  990.  
  991. -- Verify the file header.
  992. local header = reader:ReadString(8)
  993.  
  994. if header ~= "\137PNG\r\n\26\n" then
  995. error("[ERROR]: Input data is not a PNG file.")
  996. end
  997.  
  998. while file.Reading do
  999. local length = reader:ReadInt32()
  1000. local chunkType = reader:ReadString(4)
  1001.  
  1002. local data, crc
  1003.  
  1004. if length > 0 then
  1005. data = reader:ForkReader(length)
  1006. crc = reader:ReadUInt32()
  1007. end
  1008.  
  1009. local chunk =
  1010. {
  1011. Length = length;
  1012. Type = chunkType;
  1013.  
  1014. Data = data;
  1015. CRC = crc;
  1016. }
  1017.  
  1018. local handler = chunks[chunkType];
  1019.  
  1020. if handler then
  1021. handler(file, chunk)
  1022. end
  1023.  
  1024. table.insert(file.Chunks, chunk)
  1025. end
  1026.  
  1027. -- Decompress the zlib stream.
  1028. local success, response = pcall(function ()
  1029. local result = {}
  1030. local index = 0
  1031.  
  1032. Deflate:InflateZlib
  1033. {
  1034. Input = BinaryReader.new(file.ZlibStream);
  1035.  
  1036. Output = function (byte)
  1037. index = index + 1
  1038. result[index] = string.char(byte)
  1039. end
  1040. }
  1041.  
  1042. return table.concat(result)
  1043. end)
  1044.  
  1045. if not success then
  1046. error("[ERROR]: Unable to unpack PNG data. Response: " .. tostring(response))
  1047. end
  1048.  
  1049. -- Grab expected info from the file.
  1050.  
  1051. local width = file.Width
  1052. local height = file.Height
  1053.  
  1054. local bitDepth = file.BitDepth
  1055. local colorType = file.ColorType
  1056.  
  1057. local buffer = BinaryReader.new(response)
  1058. file.ZlibStream = nil
  1059.  
  1060. local bitmap = {}
  1061. file.Bitmap = bitmap
  1062.  
  1063. local channels = getBytesPerPixel(colorType)
  1064. file.NumChannels = channels
  1065.  
  1066. local bpp = math.max(1, channels * (bitDepth / 8))
  1067. file.BytesPerPixel = bpp
  1068.  
  1069. -- Unfilter the buffer and
  1070. -- load it into the bitmap.
  1071.  
  1072. for row = 1, height do
  1073. local filterType = buffer:ReadByte()
  1074. local scanline = buffer:ReadBytes(width * bpp, true)
  1075.  
  1076. bitmap[row] = {}
  1077.  
  1078. if filterType == 0 then
  1079. -- None
  1080. Unfilter:None(scanline, bitmap, bpp, row)
  1081. elseif filterType == 1 then
  1082. -- Sub
  1083. Unfilter:Sub(scanline, bitmap, bpp, row)
  1084. elseif filterType == 2 then
  1085. -- Up
  1086. Unfilter:Up(scanline, bitmap, bpp, row)
  1087. elseif filterType == 3 then
  1088. -- Average
  1089. Unfilter:Average(scanline, bitmap, bpp, row)
  1090. elseif filterType == 4 then
  1091. -- Paeth
  1092. Unfilter:Paeth(scanline, bitmap, bpp, row)
  1093. end
  1094. end
  1095.  
  1096. return setmetatable(file, PNG)
  1097. end
  1098.  
  1099. -------------------------------------------------------------
  1100.  
  1101.  
  1102. --for debugging, lags the game lol
  1103. --it creates a part where it attempts to put pixels so I could tell how bad I am at CFrames lmao
  1104. local visualBrush = false
  1105.  
  1106. --debug part folder
  1107. local stuffFolder = workspace:FindFirstChild("__CLIENTHAX")
  1108. if stuffFolder ~= nil then
  1109. stuffFolder:Destroy()
  1110. end
  1111. if visualBrush then
  1112. stuffFolder = Instance.new("Folder")
  1113. stuffFolder.Name = "__CLIENTHAX" --stupid name xd
  1114. stuffFolder.Parent = workspace
  1115. end
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122. --ok here we go
  1123.  
  1124. local HttpService = game:GetService("HttpService")
  1125. local plr = game:GetService("Players").LocalPlayer
  1126. while plr == nil do
  1127. wait()
  1128. plr = game:GetService("Players").LocalPlayer
  1129. end
  1130.  
  1131.  
  1132. -- function that does thing yes haha
  1133. local function DRAWIMAGE(unitRay, Image_Url, pixelSize, anchor, raycastMode)
  1134. local character = plr.Character
  1135. if character == nil then
  1136. warn("Character not found")
  1137. return
  1138. end
  1139. local paint = character:FindFirstChild("SprayPaint")
  1140. if paint == nil then
  1141. paint = plr.Backpack:FindFirstChild("SprayPaint")
  1142. end
  1143. if paint == nil then
  1144. warn("Unable to find paint can")
  1145. return
  1146. end
  1147. local response = nil
  1148. local succ,err = pcall(function()
  1149. response = REQUEST_FUNC(
  1150. {
  1151. Url = Image_Url
  1152. }
  1153. )
  1154. end) if not succ or not response then warn(err) return end
  1155.  
  1156. local IMAG = PNG.new(response.Body)
  1157.  
  1158. local offsetFrame = CFrame.new((0), (SURFACE_OFFSET), (0))
  1159. if anchor == 0 then
  1160. --Middle
  1161. offsetFrame = CFrame.new((0.7 * pixelSize * IMAG.Width / -2), (SURFACE_OFFSET), (0.7 * pixelSize * IMAG.Height / -2))
  1162. elseif anchor == 1 then
  1163. --Top Left
  1164. offsetFrame = CFrame.new((0), (SURFACE_OFFSET), (0))
  1165. elseif anchor == 2 then
  1166. --Top Right
  1167. offsetFrame = CFrame.new((0.7 * pixelSize * IMAG.Width * -1), (SURFACE_OFFSET), (0))
  1168. elseif anchor == 3 then
  1169. --Bottom Left
  1170. offsetFrame = CFrame.new((0), (SURFACE_OFFSET), (0.7 * pixelSize * IMAG.Height * -1))
  1171. elseif anchor == 4 then
  1172. --Bottom Right
  1173. offsetFrame = CFrame.new((0.7 * pixelSize * IMAG.Width * -1), (SURFACE_OFFSET), (0.7 * pixelSize * IMAG.Height * -1))
  1174. end
  1175.  
  1176. --Main ray to the target surface (only used in normal mode)
  1177. local raycastParams = RaycastParams.new()
  1178. raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
  1179. raycastParams.FilterDescendantsInstances = {workspace.Map}
  1180. local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * RAY_LENGTH, raycastParams)
  1181.  
  1182. local targ = CFrame.new(ray.Position, ray.Position + ray.Normal) * CFrame.Angles(math.rad(-90),math.rad(180),0) * offsetFrame --used in normal mode
  1183. local topLeftCFrame = CFrame.new(unitRay.Origin, unitRay.Origin + unitRay.Direction) * offsetFrame --used in raycast mode
  1184.  
  1185. local index = 0
  1186. local dumpCount = 1
  1187. local lastDump = 0 --keeps track of when you last sent a request mid-column
  1188. local table = {}
  1189. --Loop diagonally
  1190. for line=1, IMAG.Width+IMAG.Height-1 do
  1191. local TABLE_MAX = ((math.min(30000, IMAG.Width*IMAG.Height))/((IMAG.Width+IMAG.Height-1) * 2)) * dumpCount
  1192. --print(TABLE_MAX)
  1193. start_col = math.max(0, line-IMAG.Width)
  1194. count = math.min(line, (IMAG.Height-start_col), IMAG.Width)
  1195. for j=0, count-1 do
  1196. local X = math.min(IMAG.Width, line) - j
  1197. local Y = start_col + j + 1
  1198.  
  1199.  
  1200.  
  1201. ----[[ sends a request mid-column
  1202. if index-lastDump > TABLE_MAX then
  1203. lastDump = index
  1204. dumpCount = dumpCount + 1
  1205. paint.SendPaintInfo:InvokeServer(table,10)
  1206. table = {}
  1207. wait(0.25)
  1208. end
  1209. --]]
  1210.  
  1211. local Color, Alpha = PNG:GetPixel(IMAG, X, Y)
  1212. --print(typeof(Color).." "..tostring(Color).." and "..typeof(Alpha).." "..tostring(Alpha))
  1213.  
  1214. if Alpha ~= 0 then
  1215. index = index+1
  1216.  
  1217. if not raycastMode then
  1218. table[index] = {
  1219. cframe = targ *CFrame.new(X * 0.7 * pixelSize,0,Y * 0.7 * pixelSize),
  1220. size = Vector3.new(pixelSize, PIXEL_DEPTH, pixelSize),
  1221. color = Color
  1222. }
  1223. else
  1224.  
  1225. local targ = topLeftCFrame * CFrame.new(X * 0.7 * pixelSize,Y * -0.7 * pixelSize,0)
  1226. local raycastParams = RaycastParams.new()
  1227. raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
  1228. raycastParams.FilterDescendantsInstances = {workspace.Map}
  1229. local ray = workspace:Raycast(targ.Position, unitRay.Direction * RAY_LENGTH, raycastParams)
  1230. if ray then
  1231.  
  1232. --[[ debugging, visualizes rays
  1233. local result = ray
  1234. local distance = (targ.Position - result.Position).Magnitude
  1235. local p = Instance.new("Part")
  1236. p.Anchored = true
  1237. p.CanCollide = false
  1238. p.Size = Vector3.new(0.1, 0.1, distance)
  1239. p.Transparency = 0.8
  1240. p.CFrame = CFrame.lookAt(targ.Position, result.Position)*CFrame.new(0, 0, -distance/2)
  1241. p.Parent = stuffFolder
  1242. ]]
  1243.  
  1244. targ = CFrame.new(ray.Position, ray.Position - ray.Normal) --I have no clue what I am doing, but it kinda works
  1245. end
  1246.  
  1247. table[index] = {
  1248. cframe = targ * CFrame.new(0,0,SURFACE_OFFSET) * CFrame.Angles(math.rad(90),0,0),
  1249. size = Vector3.new(pixelSize, PIXEL_DEPTH, pixelSize),
  1250. color = Color
  1251. }
  1252.  
  1253. end
  1254.  
  1255. --Folder for debugging
  1256. if stuffFolder ~= nil then
  1257. local pixelPart = Instance.new("Part")
  1258. pixelPart.Transparency = 0.7
  1259. pixelPart.Anchored = true
  1260. pixelPart.CanCollide = false
  1261. pixelPart.CFrame = table[index].cframe
  1262. pixelPart.Size = table[index].size * Vector3.new(1,0,1)
  1263. pixelPart.Color = table[index].color
  1264. pixelPart.Parent = stuffFolder
  1265. end
  1266.  
  1267. end
  1268. end
  1269.  
  1270. end
  1271. --dump table at end of it
  1272. wait(0.25)
  1273. paint.SendPaintInfo:InvokeServer(table,10) --due to the nature of this, it will yield until server responds, if it does not yield, the drawing breaks
  1274. table = {}
  1275. end
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288. -- GUI STUFF
  1289. local DEFAULT_SIZE = 0.2
  1290.  
  1291.  
  1292. local ScreenGui = Instance.new("ScreenGui")
  1293. local TheNameLol = game:GetService("HttpService"):GenerateGUID()
  1294. ScreenGui.Name = TheNameLol
  1295. if PROTECT_FUNC ~= nil then PROTECT_FUNC(ScreenGui) end
  1296. ScreenGui.Parent = game:GetService("CoreGui")
  1297.  
  1298. local frame = Instance.new("Frame")
  1299. frame.ZIndex = -10
  1300. frame.AnchorPoint = Vector2.new(1,1)
  1301. frame.Position = UDim2.new(0.88,0,1,-5)
  1302. frame.Size = UDim2.new(0.25,0,0.15,0)
  1303. frame.BackgroundTransparency = 0.5
  1304. frame.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1305. frame.Parent = ScreenGui
  1306.  
  1307. local inputBox = Instance.new("TextBox")
  1308. inputBox.Position = UDim2.new(0,8,0,5)
  1309. inputBox.Size = UDim2.new(0.6,-4,0.5, -8)
  1310. inputBox.BackgroundColor3 = Color3.new(0.2,0.2,0.2)
  1311. inputBox.BackgroundTransparency = 0.4
  1312. inputBox.Text = ""
  1313. inputBox.PlaceholderText = "PNG URL"
  1314. inputBox.TextColor3 = Color3.new(1,1,1)
  1315. inputBox.TextScaled = true
  1316. inputBox.Parent = frame
  1317.  
  1318. local activateButton = Instance.new("TextButton")
  1319. activateButton.Position = UDim2.new(1,5,0,0)
  1320. activateButton.Size = UDim2.new(1.5,0,1,0)
  1321. activateButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
  1322. activateButton.Text = "<b>Go</b>"
  1323. activateButton.TextColor3 = Color3.new(1,1,1)
  1324. activateButton.RichText = true
  1325. activateButton.TextScaled = true
  1326. activateButton.BackgroundColor3 = Color3.new(0,1,0)
  1327. activateButton.BackgroundTransparency = 0.4
  1328. activateButton.Parent = inputBox
  1329.  
  1330. local cursorOverlay = Instance.new("Frame")
  1331. cursorOverlay.Name = "cursor"
  1332. cursorOverlay.AnchorPoint = Vector2.new(0.5,0.5)
  1333. cursorOverlay.Visible = false
  1334. cursorOverlay.Size = UDim2.new(0,5,0,5)
  1335. cursorOverlay.BackgroundColor3 = Color3.new(0,1,0)
  1336. cursorOverlay.Parent = ScreenGui
  1337. local mouse = game.Players.LocalPlayer:GetMouse()
  1338. local cnMouse = mouse.Move:Connect(function()
  1339. cursorOverlay.Position = UDim2.new(0,mouse.X,0,mouse.Y)
  1340. end)
  1341.  
  1342. local raycastToggler = Instance.new("TextButton")
  1343. raycastToggler.Position = UDim2.new(0,0,1,0)
  1344. raycastToggler.Size = UDim2.new(1,0,0.5,0)
  1345. raycastToggler.Text = "<b>Raycast Mode (buggy)</b>"
  1346. raycastToggler.TextColor3 = Color3.new(0,0,0)
  1347. raycastToggler.RichText = true
  1348. raycastToggler.TextScaled = true
  1349. raycastToggler.BackgroundColor3 = Color3.new(1,0,0)
  1350. raycastToggler.BackgroundTransparency = 0.4
  1351. raycastToggler.Parent = activateButton
  1352.  
  1353. local raycastModeVal = Instance.new("BoolValue")
  1354. raycastModeVal.Value = false
  1355.  
  1356. raycastToggler.Activated:Connect(function()
  1357. raycastModeVal.Value = not raycastModeVal.Value
  1358. end)
  1359.  
  1360. raycastModeVal.Changed:Connect(function()
  1361. if raycastModeVal.Value then
  1362. raycastToggler.BackgroundColor3 = Color3.new(0,1,0)
  1363. else
  1364. raycastToggler.BackgroundColor3 = Color3.new(1,0,0)
  1365. end
  1366. end)
  1367.  
  1368. local anchorVal = Instance.new("IntValue")
  1369. anchorVal.Value = 0
  1370.  
  1371. local anchorSelectors = Instance.new("Frame")
  1372. anchorSelectors.AnchorPoint = Vector2.new(1,1)
  1373. anchorSelectors.Position = UDim2.new(0,-5,1,0)
  1374. anchorSelectors.Size = UDim2.new(0.6,0,0.6,0)
  1375. anchorSelectors.SizeConstraint = Enum.SizeConstraint.RelativeYY
  1376. anchorSelectors.BackgroundTransparency = 1
  1377. anchorSelectors.Parent = frame
  1378.  
  1379. local anchorTitle = Instance.new("TextLabel")
  1380. anchorTitle.AnchorPoint = Vector2.new(0,1)
  1381. anchorTitle.Position = UDim2.new(0,0,0,0)
  1382. anchorTitle.Size = UDim2.new(1,0,0.2,0)
  1383. anchorTitle.Text = "<b>Anchor Point</b>"
  1384. anchorTitle.RichText = true
  1385. anchorTitle.TextScaled = true
  1386. anchorTitle.TextColor3 = Color3.new(1,1,1)
  1387. anchorTitle.BackgroundTransparency = 0.6
  1388. anchorTitle.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1389. anchorTitle.Parent = anchorSelectors
  1390.  
  1391. local anchorM = Instance.new("TextButton")
  1392. anchorM.ZIndex = 0
  1393. anchorM.AnchorPoint = Vector2.new(0.5,0.5)
  1394. anchorM.Position = UDim2.new(0.5,0,0.5,0)
  1395. anchorM.Size = UDim2.new(0.4,0,0.4,0)
  1396. anchorM.BackgroundColor3 = Color3.new(0,1,0)
  1397. anchorM.BackgroundTransparency = 0.4
  1398. anchorM.Text = ""
  1399. anchorM.Parent = anchorSelectors
  1400. anchorM.Activated:Connect(function() anchorVal.Value = 0 end)
  1401. local anchorTL = Instance.new("TextButton")
  1402. anchorTL.ZIndex = -1
  1403. anchorTL.Position = UDim2.new(0,0,0,0)
  1404. anchorTL.Size = UDim2.new(0.5,0,0.5,0)
  1405. anchorTL.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1406. anchorTL.BackgroundTransparency = 0.4
  1407. anchorTL.Text = ""
  1408. anchorTL.Parent = anchorSelectors
  1409. anchorTL.Activated:Connect(function() anchorVal.Value = 1 end)
  1410. local anchorTR = Instance.new("TextButton")
  1411. anchorTR.ZIndex = -2
  1412. anchorTR.Position = UDim2.new(0.5,0,0,0)
  1413. anchorTR.Size = UDim2.new(0.5,0,0.5,0)
  1414. anchorTR.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1415. anchorTR.BackgroundTransparency = 0.4
  1416. anchorTR.Text = ""
  1417. anchorTR.Parent = anchorSelectors
  1418. anchorTR.Activated:Connect(function() anchorVal.Value = 2 end)
  1419. local anchorBL = Instance.new("TextButton")
  1420. anchorBL.ZIndex = -3
  1421. anchorBL.Position = UDim2.new(0,0,0.5,0)
  1422. anchorBL.Size = UDim2.new(0.5,0,0.5,0)
  1423. anchorBL.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1424. anchorBL.BackgroundTransparency = 0.4
  1425. anchorBL.Text = ""
  1426. anchorBL.Parent = anchorSelectors
  1427. anchorBL.Activated:Connect(function() anchorVal.Value = 3 end)
  1428. local anchorBR = Instance.new("TextButton")
  1429. anchorBR.ZIndex = -4
  1430. anchorBR.Position = UDim2.new(0.5,0,0.5,0)
  1431. anchorBR.Size = UDim2.new(0.5,0,0.5,0)
  1432. anchorBR.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1433. anchorBR.BackgroundTransparency = 0.4
  1434. anchorBR.Text = ""
  1435. anchorBR.Parent = anchorSelectors
  1436. anchorBR.Activated:Connect(function() anchorVal.Value = 4 end)
  1437.  
  1438. anchorVal.Changed:Connect(function()
  1439. for i,v in pairs(anchorSelectors:GetChildren()) do
  1440. if v:IsA("TextButton") then
  1441. if -1 * v.ZIndex == anchorVal.Value then
  1442. v.BackgroundColor3 = Color3.new(0,1,0)
  1443. else
  1444. v.BackgroundColor3 = Color3.new(0.25,0.25,0.5)
  1445. end
  1446. end
  1447. end
  1448. end)
  1449.  
  1450. local sizeInput = Instance.new("TextBox")
  1451. sizeInput.Position = UDim2.new(0,0,1,5)
  1452. sizeInput.Size = UDim2.new(1,0,1,0)
  1453. sizeInput.BackgroundColor3 = Color3.new(0.2,0.2,0.2)
  1454. sizeInput.BackgroundTransparency = 0.4
  1455. sizeInput.Text = ""
  1456. sizeInput.PlaceholderText = "Pixel Size"
  1457. sizeInput.TextColor3 = Color3.new(1,1,1)
  1458. sizeInput.TextScaled = true
  1459. sizeInput.Parent = inputBox
  1460.  
  1461. local active = Instance.new("BoolValue")
  1462. active.Value = false
  1463. local function drawIt()
  1464. local cnActive = nil
  1465. if not active.Value then --realistically I don't need to have it prevent concurrent drawings, it makes it more reliable tho
  1466. active.Value = true
  1467. cnActive = game:GetService("UserInputService").InputBegan:Connect(function(Input, gameProcessed)
  1468. if Input.UserInputType == Enum.UserInputType.MouseButton1 and not gameProcessed then
  1469. cnActive:Disconnect()
  1470. cnActive = nil
  1471. activateButton.BackgroundColor3 = Color3.new(1,0,0)
  1472. cursorOverlay.Visible = false
  1473. activateButton.Text = "In Progress"
  1474. local size = tonumber(sizeInput.Text) or DEFAULT_SIZE
  1475. size = math.min(size, MAX_PIXEL_SIZE)
  1476.  
  1477. local mouse = plr:GetMouse()
  1478. local unitRay = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y)
  1479. DRAWIMAGE(unitRay, inputBox.Text, size, anchorVal.Value, raycastModeVal.Value)
  1480. active.Value = false
  1481. end
  1482. end)
  1483. end
  1484. end
  1485.  
  1486. activateButton.Activated:Connect(drawIt)
  1487. inputBox.FocusLost:Connect(function(enter)
  1488. if enter then
  1489. drawIt()
  1490. end
  1491. end)
  1492.  
  1493. active.Changed:Connect(function()
  1494. if active.Value then
  1495. activateButton.BackgroundColor3 = Color3.new(1,0.65,0)
  1496. activateButton.Text = "Active"
  1497. cursorOverlay.Visible = true
  1498. else
  1499. activateButton.BackgroundColor3 = Color3.new(0,1,0)
  1500. activateButton.Text = "Go"
  1501. cursorOverlay.Visible = false
  1502. end
  1503. end)
  1504.  
  1505. --funni rainbow spray cloud
  1506. local rainbowOn = Instance.new("BoolValue")
  1507. rainbowOn.Value = false
  1508.  
  1509. local rainbowFarf = Instance.new("TextButton")
  1510. rainbowFarf.AnchorPoint = Vector2.new(1,1)
  1511. rainbowFarf.Position = UDim2.new(1,-5,1,-5)
  1512. rainbowFarf.Size = UDim2.new(0.5,0,0.4,0)
  1513. rainbowFarf.SizeConstraint = Enum.SizeConstraint.RelativeYY
  1514. rainbowFarf.BackgroundColor3 = Color3.new(1,0,0)
  1515. rainbowFarf.BackgroundTransparency = 0.4
  1516. rainbowFarf.Text = "<b>Rainbow Cloud (funny)</b>"
  1517. rainbowFarf.RichText = true
  1518. rainbowFarf.TextScaled = true
  1519. rainbowFarf.Parent = frame
  1520. rainbowFarf.Activated:Connect(function()
  1521. rainbowOn.Value = not rainbowOn.Value
  1522. end)
  1523.  
  1524. local rand = Random.new()
  1525. local function randomColor()
  1526. return(Color3.new(rand:NextNumber(), rand:NextNumber(),rand:NextNumber()))
  1527. end
  1528.  
  1529. rainbowOn.Changed:Connect(function()
  1530. local character = game.Players.LocalPlayer.Character
  1531. if not character then
  1532. warn("u no exist")
  1533. end
  1534. local paint = game.Players.LocalPlayer.Character:FindFirstChild("SprayPaint")
  1535. if paint == nil then
  1536. paint = game.Players.LocalPlayer.Backpack:FindFirstChild("SprayPaint")
  1537. end
  1538. if paint == nil then
  1539. warn("Unable to find paint can")
  1540. return
  1541. end
  1542. if rainbowOn.Value then
  1543. rainbowFarf.BackgroundColor3 = Color3.new(0,1,0)
  1544. while rainbowOn.Value do
  1545. paint.SprayEffect:FireServer(true, randomColor())
  1546. wait(0.05)
  1547. paint.SprayEffect:FireServer(false)
  1548. end
  1549. else
  1550. rainbowFarf.BackgroundColor3 = Color3.new(1,0,0)
  1551. paint.SprayEffect:FireServer(false)
  1552. end
  1553. end)
  1554.  
  1555. local kill = Instance.new("TextButton")
  1556. kill.AnchorPoint = Vector2.new(1,0)
  1557. kill.Position = UDim2.new(1,-5,0,5)
  1558. kill.Size = UDim2.new(0.1,0,0.1,0)
  1559. kill.ZIndex = 2
  1560. kill.RichText = true
  1561. kill.Text = "<b>X</b>"
  1562. kill.TextScaled = true
  1563. kill.BackgroundTransparency = 0.4
  1564. kill.BackgroundColor3 = Color3.new(1,0,0)
  1565. kill.SizeConstraint = Enum.SizeConstraint.RelativeXX
  1566. kill.Parent = frame
  1567.  
  1568. --clean up
  1569. kill.Activated:Connect(function()
  1570. if cnActive ~= nil then
  1571. cnActive:Disconnect()
  1572. cnActive = nil
  1573. end
  1574. if cnMouse ~= nil then
  1575. cnMouse:Disconnect()
  1576. cnMouse = nil
  1577. end
  1578. local stuffFolder = workspace:FindFirstChild("__CLIENTHAX")
  1579. if stuffFolder ~= nil then
  1580. stuffFolder:Destroy()
  1581. end
  1582. rainbowOn.Value = false
  1583. ScreenGui:Destroy()
  1584. end)
  1585.  
  1586. end) if not succ then err("ERROR: "..err) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement