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