import webcolors


COLORBREWER_COLORS = [(166, 206, 227), (31, 120, 180), (178, 223, 138), (51, 160, 44), (251, 154, 153), (227, 26, 28), (253, 191, 111), (255, 127, 0), (202, 178, 214), (106, 61, 154), (255, 255, 153), (177, 89, 40)]


def generate_color(initial_color_list):
    colors_to_generate = initial_color_list
    colors_used = []

    while True:
        try:
            color = colors_to_generate.pop(0)
            colors_used.append(color)
        except IndexError:
            new_colors = get_new_colors(colors_used)
            colors_to_generate = new_colors
            colors_used = []

        yield webcolors.rgb_to_hex(color)


def calculate_distance_between_colors(color1, color2):
    """ Takes 2 color tupes and returns the average between them
    """
    return ((color1[0] + color2[0]) / 2, (color1[1] + color2[1]) / 2, (color1[2] + color2[2]) / 2)


def get_new_colors(colors_used):
    new_colors = []
    for i in xrange(len(colors_used) - 1):
        new_colors.append(calculate_distance_between_colors(colors_used[i], colors_used[i+1]))

    return new_colors

if __name__ == "__main__":
    for i in xrange(5):
        color = generate_color(COLORBREWER_COLORS)
        print(color.next())

@@ -1,8 +1,40 @@
+import hashlib%0Aimport colorsys%0A%0A
 import w
@@ -42,16 +42,16 @@
 bcolors%0A
-
 %0A%0ACOLORB
@@ -260,16 +260,380 @@
 9, 40)%5D%0A
+BASE_HUES = %5B0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9%5D%0ABASE_LUMINANCE = 0.5%0A%0A%0Adef word_to_color(word):%0A    %22%22%22 Takes a string and returns an RGB color based on the%0A    md5 hash of that string %22%22%22%0A    md5 = hashlib.md5()%0A    md5.update(word)%0A    hash_value = md5.hexdigest()%0A    rgb = '#' + hash_value%5B0:2%5D + hash_value%5B2:4%5D + hash_value%5B4:6%5D%0A    return rgb%0A
 %0A%0Adef ge
@@ -1301,24 +1301,149 @@
 lors_used):%0A
+    %22%22%22 Take a list of colors and generate a new list of colors with%0A    the averages of the original colors in the list %22%22%22%0A
     new_colo
@@ -1589,16 +1589,16 @@
 i+1%5D))%0A%0A
-
     retu
@@ -1612,16 +1612,992 @@
 colors%0A%0A
+%0Adef get_color(base_hues, base_luminance):%0A    %22%22%22 Generate colors based on varying luminance%22%22%22%0A    count = 0%0A    while True:%0A        hue = base_hues%5B0 + count %25 len(base_hues)%5D%0A        luminance = base_luminance + (%0A            (0.2 * (count // len(base_hues))) %25 (0.9 - base_luminance)%0A        )%0A        yield colorsys.hls_to_rgb(hue, luminance, 1.0)%0A        count += 1%0A%0A%0Adef save_html_page():%0A    %22%22%22%0A    Save an HTML page with your generated colors to see the pallate%0A    %22%22%22%0A    with open('test.html', 'w') as f:%0A        f.write('%3Chtml%3E%3Chead%3E%3C/head%3E%3Cbody%3E')%0A        for idx, value in enumerate(get_color(BASE_HUES, BASE_LUMINANCE)):%0A            f.write('%3Cdiv style=%22background-color:rgb(%7Br%7D,%7Bg%7D,%7Bb%7D)%22%3E%7Bvalue%7D%3C/div%3E'.format(%0A                value=value,%0A                r=int(value%5B0%5D * 255),%0A                g=int(value%5B1%5D * 255),%0A                b=int(value%5B2%5D * 255),%0A            ))%0A            if idx == 100:%0A                break%0A        f.write('%3C/body%3E%3C/html%3E')%0A%0A%0A
 if __nam

Add new color generators, add docstrings