Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # gartic phone bot
- # works with any paint program with a box tool as well
- import pyautogui
- from PIL import Image
- import time
- import math
- img = Image.open("your-image.png") # should be a image with only black and only white aka a silhouette
- img_BW = img.convert("1")
- img_BW = img_BW.load()
- width, height = img.size
- time.sleep(5) # waits for you to put your mouse over to the gartic phone window
- mousex, mousey = pyautogui.position()
- 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
- pyautogui.MINIMUM_DURATION = 0.0
- aspect = min(img.size)
- square = 1
- pixelsize = 1 # size of the pixels, e.g. 8 would make the pixels 8 times larger for making something like pixle art
- while square < aspect:
- square *= 2
- square /= 2
- square = int(square)
- while square > 0:
- for y in range(math.floor(height / square)):
- for x in range(math.floor(width / square)):
- all_black = True
- for x2 in range(square):
- for y2 in range(square):
- if not img_BW[x*square+x2,y*square+y2] == 0:
- all_black = False
- if all_black == True:
- pyautogui.moveTo(mousex+x*square*pixelsize,mousey+y*square*pixelsize)
- pyautogui.drag(square*pixelsize, square*pixelsize, button='left')
- for x2 in range(square):
- for y2 in range(square):
- img_BW[x*square+x2,y*square+y2] = 1
- square = int(square/2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement