Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import pprint
- pp=pprint.PrettyPrinter()
- # things to permute
- def get_permutations(l,n):
- """Self-explanatory"""
- return list(set(itertools.permutations(l,n)))
- def get_color_families(step):
- """
- Don't use this. Too many similar colors.
- """
- values = tuple([i - 1*(i>=256) for i in range(0,257,step)])
- out = []
- for a in values:
- for b in values:
- for c in values:
- v = (a,b,c)
- if 255 in v:
- out.append(v)
- return tuple(set(out))
- # return [(0,((i//256)%256)//step,i%256) for i in range(0,256**3,step)]
- # pp.pprint(get_color_families(64))
- with open("rbg_templates.txt") as f:
- colorCombs = [[int(v) for v in i.split(',')] for i in f.read().split('\n') ]
- # example contents:
- # 255,0,0
- # 255,64,0
- # 255,64,64
- # 255,127,0
- # 255,127,64
- # 255,127,127
- # 255,192,0
- # 255,255,0
- # 255,255,127
- # 255,255,255
- # notice that these are the digits of a base-256 number as it is incremented
- # BRB automating that
- # even those could be generated algorithmically
- N = 3
- outList = []
- # interleave the color families in order to keep the visuals interesting
- interleaved = colorCombs[:len(colorCombs)//2] + colorCombs[len(colorCombs)//2:][::-1]
- # print(interleaved)
- for i in interleaved:
- outList += get_permutations(i,N)[::-1]
- outstr = "const int numColors = {number};\nint niceColors[][3] = {{\n\t {colors} \n}};".format(
- number=len(outList),
- colors=",\n\t".join([str(i).replace("(","{").replace(")","}") for i in outList])
- )
- print(outstr)
- with open("permutations.txt",'w') as f:
- f.write(outstr)
Advertisement
Add Comment
Please, Sign In to add comment