Guest User

Doodlrr

a guest
Dec 16th, 2019
3,891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. '''
  2. Doodlrr by Eric Hamilton
  3. '''
  4. import pyautogui
  5. import random
  6. import time
  7. import math
  8.  
  9.  
  10.  
  11. height = 800
  12. width = 800
  13. sizePosition = (714, 84)
  14. sizeOptions= (166, 211, 254, 297)
  15. canvasOrigin = (5, 168, 5 + width, 168+height)
  16. moveX = 0
  17. moveY = 0
  18. swatchTopLeft = (0, 0)
  19. swatchBottomRight = (0, 0)
  20. swatchOffset = (0,0)
  21.  
  22. colors = { 'black':(1, 3), 'blue':(1, 9), 'red':(1, 4), 'orange':(1, 5),
  23. 'yellow':(1, 6), 'green':(1, 7), 'purple':(1, 9)}
  24.  
  25.  
  26. center = (width/2 + canvasOrigin[0], height/2 + canvasOrigin[1])
  27.  
  28.  
  29. pyautogui.moveTo(center)
  30.  
  31. def colorCoords(color):
  32. index = colors.get(color)
  33. x = swatchTopLeft[0] + (index[1] * swatchOffset[0])
  34. y = swatchTopLeft[1] + (index[0] * swatchOffset[1])
  35. return (x, y)
  36.  
  37. def pickSize():
  38. size = random.choice(sizeOptions)
  39. pyautogui.moveTo(sizePosition)
  40. pyautogui.click()
  41. pyautogui.moveTo(sizePosition[0], size)
  42. time.sleep(0.25)
  43. pyautogui.click()
  44.  
  45. def waitLoop(length):
  46. print('Press Enter to Continue')
  47. input()
  48. count = length
  49. while count >0:
  50. print(str(count)+'...')
  51. time.sleep(1)
  52. count-=1
  53.  
  54.  
  55.  
  56. def pickColor():
  57. color = random.choice(list(colors.keys()))
  58. colorPosition = colorCoords(color)
  59. #print(colorPosition)
  60. pyautogui.moveTo(colorPosition)
  61. pyautogui.click()
  62.  
  63. def getDestination():
  64. global moveX
  65. global moveY
  66.  
  67. pos = pyautogui.position()
  68. startX = pos[0]
  69. startY = pos[1]
  70. strokeRand = random.randint(2, 30)
  71.  
  72. moveX = random.randint(startX - int((width/strokeRand)), startX + int((width/strokeRand)))
  73. moveY = random.randint(startY - int((height/strokeRand)), startY + int((height/strokeRand)))
  74. if moveX > canvasOrigin[0] + width:
  75. return False
  76. elif moveX < canvasOrigin[0]:
  77. return False
  78. elif moveY > canvasOrigin[1] + height:
  79. return False
  80. elif moveY < canvasOrigin[1]:
  81. return False
  82. else:
  83. return True
  84.  
  85. def curve():
  86. startX = random.randint(canvasOrigin[0], canvasOrigin[2])
  87. startY = random.randint(canvasOrigin[1], canvasOrigin[3])
  88. endX = random.randint(canvasOrigin[0], canvasOrigin[2])
  89. endY = random.randint(canvasOrigin[1], canvasOrigin[3])
  90.  
  91. pyautogui.moveTo(startX, startY)
  92. dist = abs(endX - startX)
  93. for j in range(dist):
  94. current = pyautogui.position()
  95. currX = current[0]
  96. currY = current[1]
  97. if endX > startX:
  98. newX = currX+1
  99. if endX < startX:
  100. newX = currX-1
  101. newY = center[1] + math.tan(newX)#*(random.randint(2, height/2))
  102. pyautogui.dragTo(newX, newY)
  103.  
  104.  
  105.  
  106.  
  107. def run(repeat):
  108.  
  109. for x in range(repeat):
  110. if random.randint(0,100) > 90:
  111. pickColor()
  112. if random.randint(0,100) > 95:
  113. pickSize()
  114. #if random.randint(0,100) > 75:
  115. # curve()
  116. #print(x)
  117. going = False
  118. startX = random.randint(0+canvasOrigin[0], width+canvasOrigin[0])
  119. startY = random.randint(0+canvasOrigin[1], height+canvasOrigin[1])
  120. pyautogui.moveTo(startX, startY)
  121. while not going:
  122. if getDestination():
  123. going = True
  124. #print('from ' +str(startX)+',' +str(startY)+' to '+str(moveX)+','+str(moveY))
  125. pyautogui.dragTo(moveX, moveY, button='left')
  126. going = False
  127. if x % 100 == 0:
  128. print(x)
  129. showMenu()
  130.  
  131. def rebuildCoords():
  132. global width
  133. global height
  134. global canvasOrigin
  135. global center
  136. global sizePosition
  137. global sizeOptions
  138. global swatchOffset
  139. global swatchBottomRight
  140. global swatchTopLeft
  141.  
  142. print('Be sure you can see your print output during this process.')
  143. print('What is the width of the Canvas in pixels?')
  144. pixW = input()
  145. width = int(pixW)
  146. print('What is the height of the Canvas in pixels?')
  147. pixH = input()
  148. height = int(pixH)
  149. print('K, now to get screen coordinates of certain features in Paint.')
  150. print('press Enter')
  151. input()
  152. print('How long do you need to get your cursor in place? (seconds)')
  153. waitTime = int(input())
  154. print('Move your cursor to the top left color swatch in Paint')
  155. waitLoop(waitTime)
  156. pos1 = pyautogui.position()
  157. print('Captured')
  158. print('Now move your cursor to the bottom right color swatch in Paint')
  159. waitLoop(waitTime)
  160. pos2 = pyautogui.position()
  161. swatchTopLeft = pos1
  162. swatchBottomRight = pos2
  163. print('Captured')
  164. offsetX = (pos2[0] - pos1[0]) / 10
  165. offsetY = (pos2[1] - pos1[1]) / 3
  166. swatchOffset = (offsetX, offsetY)
  167. print('Next, move your cursor to the Brush Size Button')
  168. print('Epstein Didn\'t Kill Himself')
  169. waitLoop(waitTime)
  170. brushPos = pyautogui.position()
  171. print('Captured')
  172. sizePosition = brushPos
  173. print('Move the cursor to the smallest brush size option')
  174. print('keep in mind you have to click for this one')
  175. waitLoop(waitTime)
  176. smallPos = pyautogui.position()
  177. print('Move the cursor to the largest brush size option')
  178. waitLoop(waitTime)
  179. bigPos = pyautogui.position()
  180. small = smallPos[1]
  181. big = bigPos[1]
  182. diff = (big - small) /4
  183. sizeOptions = (small, small+diff , small+(diff*2) ,big)
  184. print('Lastly, hold your cursor at the top left corner of the image canvas')
  185. print('Get it as close as possible')
  186. waitLoop(waitTime)
  187. origPos = pyautogui.position()
  188. canvasOrigin = (origPos[0], origPos[1], origPos[0]+width, origPos[1]+height)
  189. center = (width/2 + canvasOrigin[0], height/2 + canvasOrigin[1])
  190.  
  191.  
  192.  
  193. def getCoords(repeat):
  194. for x in range(repeat):
  195. print(pyautogui.position())
  196. time.sleep(1)
  197.  
  198. def showMenu():
  199. print('Type a Number and Press Enter:')
  200. print('1: Run')
  201. print('2: Get Cursor Coords')
  202. print('3: Hol up let me do that stupid coordinate thing again because its confusing')
  203. result = input()
  204. if result == '1':
  205. print('ctrl alt del if this goes crazy')
  206. print('How many strokes?')
  207. ticks = input()
  208. run(int(ticks))
  209. if result == '2':
  210. print('For how long? (secs)')
  211. secs = input()
  212. getCoords(int(secs))
  213. if result == '3':
  214. rebuildCoords()
  215. rebuildCoords()
  216. showMenu()
Advertisement
Add Comment
Please, Sign In to add comment