I programmed the Mandelbrot set with python but that was weird looking so I searched for smooth colors. I've programmed a smooth colouring function using log and linear interpolation but whatever I try I can't get what I want:
self.palette = [(3, 25, 61),(5, 43, 107),(7, 61, 153),(20, 96, 226),(20, 164, 226),(74, 181, 226),(138, 211, 242),(205, 234, 247),(225, 237, 242),(255,255,255)]
Here is my palette
if n == self.max_iterations:
self.screen.set_at((x, y), (110, 13, 13))
else:
gradient = 1 + n - math.log(math.log(abs(m))) / math.log(2.0)
iteration = n + 1 - gradient
color1 = list(self.palette[n % 10])
if n % 10 <= 8:
color2 = list(self.palette[n % 10+1])
else:
color2 = list(self.palette[-1])
color = [[], [], []]
for number, elt in enumerate(color):
color[number] = color1[number] + (iteration % 1)*(color2[number]-color1[number])
self.screen.set_at((x, y), tuple(color))
Here my colouring function
And here what I get
As you can see colors are smooth but in the wrong way there is no continuity in the colors
I would like to have something like this :
ideal result
we do not see color gaps