114 lines
2.9 KiB
C
114 lines
2.9 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* fractals2.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/12/26 22:05:33 by houtworm #+# #+# */
|
||
|
/* Updated: 2022/12/29 18:38:12 by houtworm ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "../fractol.h"
|
||
|
|
||
|
void mandelpower(t_varlist *vl, int x, int y, t_cnbr c)
|
||
|
{
|
||
|
t_cnbr z;
|
||
|
t_cnbr t;
|
||
|
t_cnbr r;
|
||
|
int i;
|
||
|
|
||
|
i = 0;
|
||
|
z = c;
|
||
|
while (vl->iter > i && (z.re * z.re + z.im * z.im < 100))
|
||
|
{
|
||
|
r.re = sqrt(z.re * z.re + z.im * z.im);
|
||
|
r.im = atan2(z.im, z.re);
|
||
|
r.re = powl(r.re, vl->power);
|
||
|
r.im = vl->power * r.im;
|
||
|
t.re = r.re * cos(r.im) + c.re;
|
||
|
t.im = r.re * sin(r.im) + c.im;
|
||
|
z = t;
|
||
|
i++;
|
||
|
vl->calc++;
|
||
|
}
|
||
|
vl->calc++;
|
||
|
if (vl->iter == i)
|
||
|
mlx_put_pixel(vl->img, x, y, 0x000000FF);
|
||
|
else
|
||
|
mlx_put_pixel(vl->img, x, y, vl->colors[(i + vl->cshi) % vl->csha]);
|
||
|
}
|
||
|
|
||
|
void tricorn(t_varlist *vl, int x, int y, t_cnbr c)
|
||
|
{
|
||
|
t_cnbr z;
|
||
|
t_cnbr t;
|
||
|
int i;
|
||
|
|
||
|
i = 0;
|
||
|
z = c;
|
||
|
while (vl->iter > i && (z.re * z.re + z.im * z.im < 100))
|
||
|
{
|
||
|
t.re = z.re * z.re - z.im * z.im + c.re;
|
||
|
t.im = -2 * z.re * z.im + c.im;
|
||
|
z = t;
|
||
|
i++;
|
||
|
vl->calc++;
|
||
|
}
|
||
|
vl->calc++;
|
||
|
if (vl->iter == i)
|
||
|
mlx_put_pixel(vl->img, x, y, 0x000000FF);
|
||
|
else
|
||
|
mlx_put_pixel(vl->img, x, y, vl->colors[(i + vl->cshi) % vl->csha]);
|
||
|
}
|
||
|
|
||
|
void rorschach(t_varlist *vl, int x, int y, t_cnbr c)
|
||
|
{
|
||
|
t_cnbr z;
|
||
|
t_cnbr t;
|
||
|
int i;
|
||
|
|
||
|
i = 0;
|
||
|
z = c;
|
||
|
while (vl->iter > i && (z.re * z.re + z.im * z.im < 100))
|
||
|
{
|
||
|
t.re = fabsl(z.re);
|
||
|
z.re = z.re * z.re - z.im * z.im - c.re;
|
||
|
z.im = 2 * z.im * t.re - c.im;
|
||
|
i++;
|
||
|
vl->calc++;
|
||
|
}
|
||
|
vl->calc++;
|
||
|
if (vl->iter == i)
|
||
|
mlx_put_pixel(vl->img, x, y, 0x000000FF);
|
||
|
else
|
||
|
mlx_put_pixel(vl->img, x, y, vl->colors[(i + vl->cshi) % vl->csha]);
|
||
|
}
|
||
|
|
||
|
void powerflower(t_varlist *vl, int x, int y, t_cnbr z)
|
||
|
{
|
||
|
t_cnbr t;
|
||
|
t_cnbr r;
|
||
|
int i;
|
||
|
|
||
|
i = 0;
|
||
|
while (vl->iter > i && (z.re * z.re + z.im * z.im < 100))
|
||
|
{
|
||
|
r.re = sqrt(z.re * z.re + z.im * z.im);
|
||
|
r.im = atan2(z.im, z.re);
|
||
|
r.re = powl(r.re, vl->power);
|
||
|
r.im = vl->power * r.im;
|
||
|
t.re = (r.re + vl->julre) * cos(r.im);
|
||
|
t.im = (r.re + vl->julim) * sin(r.im);
|
||
|
z = t;
|
||
|
i++;
|
||
|
vl->calc++;
|
||
|
}
|
||
|
vl->calc++;
|
||
|
if (vl->iter == i)
|
||
|
mlx_put_pixel(vl->img, x, y, 0x000000FF);
|
||
|
else
|
||
|
mlx_put_pixel(vl->img, x, y, vl->colors[(i + vl->cshi) % vl->csha]);
|
||
|
}
|