-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplay_itterators.c
109 lines (99 loc) · 3.07 KB
/
display_itterators.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* display_itterators.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: znichola <znichola@student.42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/01 18:30:30 by znichola #+# #+# */
/* Updated: 2022/12/01 18:40:40 by znichola ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
int mandelbrot_itterations(t_app *p)
{
t_complex z;
t_complex c;
int i;
i = 1;
p->points[0] = rworld_to_screen(p, fpoint(0.0, 0.0));
while (i < MAXPOINTS)
{
z = ftc(rscreen_to_world(p, p->points[i - 1]));
c = ftc(rscreen_to_world(p, p->mouse_down));
p->points[i] = rworld_to_screen(p, ctf(c_addition(c_power2(z), c)));
put_circle_fast(&p->img, 2, p->points[i], colour_lerp(1, MAXPOINTS, i));
i++;
}
return (0);
}
// return (mandelbrot_like(test, ftc(a->world_mouse_right), depth));
int julia_itterations(t_app *p)
{
t_complex z;
t_complex c;
int i;
t_fpoint test;
i = 1;
test = rscreen_to_world(p, p->mouse_down);
p->points[0] = rworld_to_screen(p, test);
while (i < MAXPOINTS)
{
z = ftc(rscreen_to_world(p, p->points[i - 1]));
c = ftc(p->world_mouse_right);
p->points[i] = rworld_to_screen(p, ctf(c_addition(c_power2(z), c)));
put_circle_fast(&p->img, 2, p->points[i], colour_lerp(1, MAXPOINTS, i));
i++;
}
return (0);
}
int burningship_itterations(t_app *p)
{
t_complex z;
t_complex c;
int i;
i = 1;
p->points[0] = rworld_to_screen(p, fpoint(0.0, 0.0));
while (i < MAXPOINTS)
{
z = ftc(rscreen_to_world(p, p->points[i - 1]));
c = ftc(rscreen_to_world(p, p->mouse_down));
p->points[i] = rworld_to_screen(p,
ctf(c_abs(c_addition(c_power2(z), c))));
put_circle_fast(&p->img, 2, p->points[i], colour_lerp(1, MAXPOINTS, i));
i++;
}
return (0);
}
int burningjulia_itterations(t_app *p)
{
t_complex z;
t_complex c;
int i;
t_fpoint test;
i = 1;
test = rscreen_to_world(p, p->mouse_down);
p->points[0] = rworld_to_screen(p, test);
while (i < MAXPOINTS)
{
z = ftc(rscreen_to_world(p, p->points[i - 1]));
c = ftc(p->world_mouse_right);
p->points[i] = rworld_to_screen(p,
ctf(c_abs(c_addition(c_power2(z), c))));
put_circle_fast(&p->img, 2, p->points[i], colour_lerp(1, MAXPOINTS, i));
i++;
}
return (0);
}
int display_itterations(t_app *p)
{
if (p->fractal_select == MANDELBROT)
mandelbrot_itterations(p);
else if (p->fractal_select == BURNINGSHIP)
burningship_itterations(p);
else if (p->fractal_select == JULIA)
julia_itterations(p);
else if (p->fractal_select == NONAME)
burningjulia_itterations(p);
return (0);
}