Advertisement
Natsukl

gartic phone bot

Nov 13th, 2023 (edited)
2,585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | Source Code | 0 0
  1. # gartic phone bot
  2. # works with any paint program with a box tool as well
  3. import pyautogui
  4. from PIL import Image
  5. import time
  6. import math
  7. img = Image.open("your-image.png") # should be a image with only black and only white aka a silhouette
  8. img_BW = img.convert("1")
  9. img_BW = img_BW.load()
  10. width, height = img.size
  11. time.sleep(5) # waits for you to put your mouse over to the gartic phone window
  12. mousex, mousey = pyautogui.position()
  13. pyautogui.PAUSE = 0.05 # if it is too slow make this number smaller, if it too fast (image not proparly drawing) make the number bigger
  14. pyautogui.MINIMUM_DURATION = 0.0
  15. aspect = min(img.size)
  16. square = 1
  17. pixelsize = 1 # size of the pixels, e.g. 8 would make the pixels 8 times larger for making something like pixle art
  18. while square < aspect:
  19.     square *= 2
  20. square /= 2
  21. square = int(square)
  22. while square > 0:
  23.     for y in range(math.floor(height / square)):
  24.         for x in range(math.floor(width / square)):
  25.             all_black = True
  26.             for x2 in range(square):
  27.                 for y2 in range(square):
  28.                     if not img_BW[x*square+x2,y*square+y2] == 0:
  29.                         all_black = False
  30.             if all_black == True:
  31.                 pyautogui.moveTo(mousex+x*square*pixelsize,mousey+y*square*pixelsize)
  32.                 pyautogui.drag(square*pixelsize, square*pixelsize, button='left')
  33.                 for x2 in range(square):
  34.                     for y2 in range(square):
  35.                         img_BW[x*square+x2,y*square+y2] = 1
  36.     square = int(square/2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement