Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Requirements:
- # 'pip install selenium', run from command line (requires pip, Google how to get it if running pip doesn't recognise as a command)
- # Google Chrome Webdriver, @ https://sites.google.com/a/chromium.org/chromedriver/downloads
- #
- # Helpful install guide: https://www.youtube.com/watch?v=8iAqUVvytJk
- import time
- from selenium import webdriver
- from time import sleep
- driver = webdriver.Chrome('PATH TO DRIVER.EXE') # Optional argument, if not specified will search path.
- driver.get('http://colorthis.space/');
- time.sleep(3) # Let the user actually see something!
- hex_char = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
- colors = [
- [255, 255, 255, 255],
- [228, 228, 228, 255],
- [136, 136, 136, 255],
- [34, 34, 34, 255],
- [255, 167, 209, 255],
- [229, 0, 0, 255],
- [229, 149, 0, 255],
- [160, 106, 66, 255],
- [229, 217, 0, 255],
- [148, 224, 68, 255],
- [2, 190, 1, 255],
- [0, 211, 221, 255],
- [0, 131, 199, 255],
- [0, 0, 234, 255],
- [207, 110, 228, 255],
- [130, 0, 128, 255]
- ]
- img1 = [
- '3333333333333333333333333333333333333333333333333333333333333333333333333',
- '3666666666666666666666666666666666666666666666666666666666666666666666663',
- '3633663633366336333633663366666633663366366666666666663633363636636666663',
- '3636363636663666363636363636666366636666366363663636333663663636333633663',
- '3636363666363666363633663636336363636363663636363636363663663336636636363',
- '3633663633366336333636363366336633663363663636366366333633666636636636363',
- '3666666666666666666666666666666666666666666666666666666666666666666666663',
- '3333333333333333333333333333333333333333333333333333333333333333333333333',
- 278,83
- ]
- img2 = [
- '3666666666666666666666666666666666666666666666666666666666666666666666663',
- '3666666666663666666363336363663663666363663636366366333633366666666666663',
- '3666666666636636663663666363636363636363363636363636636636666666666666663',
- '3666666666636633663663336333633363636363633633363336636633366666666666663',
- '#36666666636663663666663636363636363636363363636363663663666666666666663#',
- '##366666663666366366633363636363663636636636363636366366333666666666663##',
- '###3666666666666666666666666666666666666666666666666666666666666666663###',
- '####33333333333333333333333333333333333333333333333333333333333333333####',
- 278,91
- ]
- img3 = [
- "3333333333333333333333333333333333",
- "3cccccccc333333333332ccccccccc2123",
- "3cccccc3333333333333332cccccccc123",
- "3ccccc33333333333333333cccccccc223",
- "3cccc3333337773337733333cccccccc23",
- "3cccc33333766666667733332ccccccc23",
- "3cccc33337666666666773333ccccccc23",
- "3cccc33377666666666677333ccccccc23",
- "3cccc333766666666666673332cccccc23",
- "3cccc337766666666666673332cccccc23",
- "3ccccc376666666666666673332ccccc23",
- "3ccccc373333366666333337332ccccc23",
- "3ccccc737777766466667777337ccccc23",
- "3cccc7777733366446633777376ccccc23",
- "3ccccc677766666447666677766ccccc23",
- "3ccccc666666664447776677766ccccc23",
- "3ccccc766666644447776667772ccccc23",
- "3ccccc366666664447776667762cccccc3",
- "3ccccc76666666747777666762ccccccc3",
- "3ccccc27666666677777767722cccccc13",
- "3ccccc2766667666777776676ccccccc13",
- "3cccccc766676666777766667ccccccc13",
- "3cccccc376666667776666667ccccccc13",
- "3cccccc3776666666666666672cccccc23",
- "3cccccc2377666666666666772cccccc13",
- "3ccccccc36776666666666762ccccccc13",
- "3ccccccc26676666666677662ccccccc13",
- "3cccc3c276667777777766662ccccccc13",
- "3333333676666666666666662ccc32cc13",
- "3333336666666666666666666c33333313",
- "3333337676666666666666666333333313",
- "3333333333666666666666333333333313",
- "3222222233333111111111111122222223",
- 298,50
- ]
- img4 = [
- "####3333333333333333",
- "###36666666666666666",
- "##366666633366666666",
- "#3666666636666666666",
- "36666666633366666666",
- "36666666666366666666",
- "36666666633366666666",
- "36666666666666666666",
- "36666666636366666666",
- "36666666636366666666",
- "36666666633366666666",
- "36666666636366666666",
- "36666666636366666666",
- "36666666666666666666",
- "36666666663666666666",
- "36666666636366666666",
- "36666666633366666666",
- "36666666636366666666",
- "36666666636366666666",
- "36666666666666666666",
- "36666666366636666666",
- "36666666363636666666",
- "36666666363636666666",
- "36666666363636666666",
- "36666666636366666666",
- "36666666666666666666",
- "36666666366636666666",
- "36666666336636666666",
- "36666666363636666666",
- "36666666366336666666",
- "36666666366636666666",
- "36666666666666666666",
- "36666666666666666666",
- 278,50
- ]
- img5 = [
- "333333333333333####",
- "6666666666666663###",
- "66666666666666663##",
- "666666666666666663#",
- "6666666666666666663",
- "6666666666666666663",
- "6666666363666666663",
- "6666666363666666663",
- "6666666333666666663",
- "6666666363666666663",
- "6666666363666666663",
- "6666666666666666663",
- "6666666636666666663",
- "6666666363666666663",
- "6666666333666666663",
- "6666666363666666663",
- "6666666363666666663",
- "6666666666666666663",
- "6666666333666666663",
- "6666666636666666663",
- "6666666636666666663",
- "6666666636666666663",
- "6666666636666666663",
- "6666666666666666663",
- "6666666333666666663",
- "6666666366666666663",
- "6666666333666666663",
- "6666666366666666663",
- "6666666333666666663",
- "6666666666666666663",
- "6666666666666666663",
- "6666666666666666663",
- "6666666666666666663",
- 332,50
- ]
- imageMatrixs = [img1,img2,img3,img4,img5]
- imageColorsGrouped = []
- imageColorsIndex = []
- imageColorsHex = ''
- imageFormatted = []
- def placenext(looking=False):
- if driver.execute_script('return notified'):
- looking = True
- for matrix in imageMatrixs:
- imageCalled = driver.execute_script('return ctx.getImageData(' + str(matrix[-2]) + ',' + str(matrix[-1]) + ',' + str(len(matrix[0])) + ',' + str(len(matrix)-2) + ').data')
- imageColorsGrouped = [imageCalled[i:i+4] for i in range(0, len(imageCalled), 4)]
- imageColorsIndex = []
- for cArray in imageColorsGrouped:
- imageColorsIndex.append(colors.index(cArray))
- imageColorsHex = ''
- for cIndex in imageColorsIndex:
- imageColorsHex += hex_char[cIndex]
- height = len(matrix) - 2
- imageFormat = []
- imageWidth = (len(imageColorsHex)/(height))
- for i in range(height):
- imageFormat.append(imageColorsHex[(i*imageWidth):((i+1)*imageWidth)])
- if looking == True:
- for x in range(len(matrix[0])):
- if looking == True:
- for y in range(len(matrix)-2):
- if looking == True and matrix[y][x] != '#':
- selectY = ( y + matrix[-1] )
- selectX = ( x + matrix[-2] )
- try:
- if int(hex_char.index(imageFormat[y][x])) == hex_char.index(matrix[y][x]):
- pass
- elif looking == True:
- currC = str(hex_char.index(matrix[y][x]))
- try:
- driver.execute_script("tryColorPixel(" + str(selectX) + "," + str(selectY) + "," + str(currC) + ")")
- except:
- print("Issue on Sending pixel")
- print('Coloring:', selectX, selectY, currC)
- looking = False
- else:
- pass
- except IndexError:
- print("Index Error")
- def run():
- counter = 0
- counter2 = 0
- while True:
- if counter == 7:
- counter = 0
- time.sleep(0.4)
- placenext()
- elif counter2 == 120:
- counter2 = 0
- time.sleep(5)
- driver.refresh()
- print('Page Refreshed')
- else:
- counter += 1
- counter2 += 1
- time.sleep(0.7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement