Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import binascii #Binary stuff
- from PIL import Image #Create image
- from PIL import ImageFont #Write text
- from PIL import ImageDraw #Ditto
- #WORK IN PROGRESS...
- #still very buggy
- width, height = (1000, 500) #<--- Image dimensions, CUSTOMIZE THIS!
- def avAll(object):
- """LIST OF TUPLES(LEN=3)"""
- a,b,c=[],[],[]
- a.append([i[0] for i in object])
- b.append([i[1] for i in object])
- c.append([i[2] for i in object])
- a = [sum(i)/len(i) for i in a]
- b = [sum(i)/len(i) for i in b]
- c = [sum(i)/len(i) for i in c]
- return (a,b,c)
- def binencode(object):
- return bin(int(binascii.hexlify(object), 16)).replace('b','')
- def chop(object,length):
- return [object[i:i+length] for i in range(0, len(object), length)]
- def recur2(object, n):
- step = len(object)
- b = []
- for i in object:
- for i2 in range(n):
- b.append(i)
- b.append((0,0,0))
- return b
- def comma(x):
- if type(x) not in [int, long]:
- raise TypeError("x must be a valid integer")
- if x < 0:
- return '-' + comma(-x)
- f = ''
- while x >= 1000:
- x, r = divmod(x, 1000)
- f = ",%03d%s" % (r, f)
- return "%d%s" % (x, f)
- def colfhex(value):
- lv = len(value)
- return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
- try:
- b = raw_input(">>>").upper()
- secret_number = comma(int(''.join([binencode(i) for i in b]), 2)) #large number.
- hexy_bits = chop(str(hex(int(''.join([binencode(i) for i in b]), 2))[2:][:-1]), 6) #color hexes with remainder
- color_pallet = [colfhex(_) for _ in chop(str(hex(int(''.join([binencode(i) for i in b]), 2))[2:][:-1]), 6)[:-1]] #<-what really matters
- remainder = hexy_bits[-1:]
- colordata = recur2(color_pallet, width/len(hexy_bits[:-1]))
- print hexy_bits
- img = Image.new('RGB', (width,height), "white")
- img.putdata(colordata*height)
- draw = ImageDraw.Draw(img)
- font = ImageFont.truetype("arial.ttf", 50)
- draw.text((0, 0),"+"+remainder[0],(255,255,255),font=font)
- img.show()
- except IndexError: print "Input too short! Must be greater than 6 characters."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement