0

There is a module in python colour, it has the function range_to that gives a list of colours that are between two colours.

I tried to accomplish the same task using my own function, but it keeps repeating these values, again and again i.e. the same values(that lie between the colors), in the same order.

For example, if I need colours between red and blue and the list should be list_rb = [e1, e2, ... , en]. Then, my program gives me:

my_list = list_rb + list_rb + list_rb or my_list = [e1, e2, ... en, e1, e2, ... en, e1, e2, ... en]

Following is the function, that I wrote:

def generate_color(f, lcc):

    # lcc = [r_1, g_1, b_1, r_2, b_2, g_2]

    col1 = []
    for i in range(lcc[0], lcc[1]):
        for j in range(lcc[2], lcc[3]):
            for k in range(lcc[4], lcc[5]):
                T = (k, j, i)
                col1.append('#%02x%02x%02x' % T)

    T = (lcc[0], lcc[1], lcc[2])
    for i in range(400):
        l1 = (lcc[0] - lcc[3]) // 256
        l2 = (lcc[1] - lcc[4]) // 256
        l3 = (lcc[2] - lcc[5]) // 256
        T = (T[0] - l1, T[1] - l2, T[2] - l3)
        col1.append('#%02x%02x%02x' % T)
        print(T)

I am open to all suggestions and even a completely new algorithm

Eshita Shukla
  • 791
  • 1
  • 8
  • 30
  • 1
    google HSL / HSV - convert your RGB to HSL and compare the _hue_ value - if its numericall y close ( careful it wraps around, handle that) they are similar, see f.e. https://en.wikipedia.org/wiki/HSL_and_HSV - getting a range of color is done by simply incrementing the hue. – Patrick Artner Dec 14 '18 at 18:21
  • maybe related: [how to copy and clone a list](https://stackoverflow.com/questions/2612802/how-to-clone-or-copy-a-list) - your code is no [mcve] so we can not help - please adjust your code so we can execute it and observe the erroneos behaviour – Patrick Artner Dec 14 '18 at 18:29

0 Answers0