I have made this code to create an image like the one google have when you search color picker.
the problem is in the for loop with j, if that part is commented out then I can click around in the image without slow down. So my question is if there some way to simplify the math or something I don't know about python that makes it slow here.
def create_palette(src, color):
width = 255
height = 255
for x in xrange(255):
for y in xrange(255):
new_color = [color[0],color[1],color[2],255.0]
x_distance = float(x)/float(width)
y_distance = float(y)/float(height)
for j in xrange(3):
new_color[j] += float(255-new_color[apply_y]) * x_distance
new_color[j] -= float(new_color[j]) * y_distance
src.set_at((x,y), new_color)
return src