/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/05 19:35:01 by ljiriste #+# #+# */
-/* Updated: 2024/04/18 11:47:43 by ljiriste ### ########.fr */
+/* Updated: 2024/04/25 10:35:46 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
+#include <math.h>
#include <X11/X.h>
#include <X11/keysym.h>
#include <mlx.h>
calculate_base(s);
}
draw_fractal(s);
- s->view.color_shift += s->view.color_shift_speed;
+ s->view.color_shift = fmod(s->view.color_shift + s->view.color_shift_speed, 1.);
+ if (s->view.color_shift < 0)
+ s->view.color_shift += 1;
}
return (0);
}
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/05 19:57:50 by ljiriste #+# #+# */
-/* Updated: 2024/04/25 09:43:26 by ljiriste ### ########.fr */
+/* Updated: 2024/04/25 11:13:38 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
#include <math.h>
+#define THRESHOLD 256
+
double normalize_count(int count, double norm, double color_stability)
{
return (fmod((double)(count + 1 - log(log(norm) / log(2)) / log(2)) / color_stability, 1.));
c.r = x;
c.i = y;
- count = 1;
+ count = 4;
z.r = x;
z.i = y;
- if (complex_norm(c) > 4)
- return (normalize_count(1, 4, settings->color_stability));
- while (complex_norm(z) < 256 && count < settings->detail)
+ if (complex_norm(c) > THRESHOLD)
+ return (normalize_count(count, THRESHOLD, settings->color_stability));
+ while (complex_norm(z) <= THRESHOLD && count < settings->detail)
{
z = complex_add(complex_mul(z, z), c);
++count;
c.r = x;
c.i = y;
- count = 0;
+ count = 4;
z.r = 0;
z.i = 0;
- if (complex_norm(c) > 4)
- return (normalize_count(1, 4, settings->color_stability));
- while (complex_norm(z) < 256 && count < settings->detail)
+ if (complex_norm(c) > THRESHOLD)
+ return (normalize_count(count + 1, THRESHOLD, settings->color_stability));
+ while (complex_norm(z) <= THRESHOLD && count < settings->detail)
{
z = complex_add(complex_mul(complex_conj(z), complex_conj(z)), c);
++count;