Open Farbfetzen opened 5 years ago
Ok, histogram coloring exists now. But how do I combine it with smooth coloring?
Additionally, there are still bugs. This works:
plot_fractal(
mandelbrot(
1200,
900,
color_mode = "smooth",
color_palette = colorRampPalette(c("blue", "orange", "red", "white"))(128),
re_width = 0.001,
center = -0.749+0.1i
)
)
But this doesn't:
plot_fractal(
mandelbrot(
1200,
900,
color_mode = "histogram",
color_palette = colorRampPalette(c("blue", "orange", "red", "white"))(128),
re_width = 0.001,
center = -0.749+0.1i
)
)
The resulting image looks wrong and it gives this warning:
Warning message:
In color_matrix[outside] <- color_palette[hues] :
number of items to replace is not a multiple of replacement length
Ok, that bug is fixed now.
Still, I want to combine it with color smoothing. I could rewrite the color histogram function to optionally only return the reduced palette. And then the smooth coloring function can just use that palette instead of the full one? I somehow need to make sure that the colors are applied to the right pixels.
It seems like the implementation for the smooth colors I got from Wikipedia is unecessarily complicated. Here are some helpful links I found: http://linas.org/art-gallery/escape/escape.html https://www.codingame.com/playgrounds/2358/how-to-plot-the-mandelbrot-set/adding-some-colors I have the feeling that the code in the first link is better and easier. But there is no interpolation? Test these algorithms and compare with the ones already in the package. The second link seems to show how to combine histogram coloring with smoothing.
Just found out about the colorspace
package. Could be useful for making better palettes, maybe also hsv?
It should be possible to interpolate in hsv color space.
What about hcl colors? hue, chroma, luminence, see grDevices::hcl.colors()
. How about I just choose one palette as the default and then let the user specify a vector of colors that gets looped or not? Make the default palettes constants that get exportet with the package.
https://en.wikipedia.org/wiki/Mandelbrot_set#Histogram_coloring
Maybe combine with smooth coloring.