From: Lukas Jiriste Date: Tue, 5 Dec 2023 19:20:21 +0000 (+0100) Subject: Add general function for constructing Julia sets X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=1a444f533b3e92ae3ae181d238c80141e7335f01;p=42%2Ffract-ol.git Add general function for constructing Julia sets This function has different prototype that mandelbrot function so some work should be done about unifying it for easier swapping of the two. This function may be used to construct specialized functions. --- diff --git a/julia.c b/julia.c new file mode 100644 index 0000000..aa63a9a --- /dev/null +++ b/julia.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* julia.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ljiriste +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/05 19:57:50 by ljiriste #+# #+# */ +/* Updated: 2023/12/05 20:16:54 by ljiriste ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "vect2.h" +#include "complex.h" + +double general_julia(void *zeroth, double resolution, + void (*tested_f)(void *), int (*is_over_thresh)(void *)) +{ + int count; + + count = 0; + while (!is_over_thresh(zeroth) && count < 100 * resolution) + { + tested_f(zeroth); + ++count; + } + if (count == 100 * resolution) + return (-1); + return (fmod(count / 100., 1.)); +}