-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_vignettes.c
147 lines (136 loc) · 4.37 KB
/
ft_vignettes.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vignettes.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nvienot <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/03 17:57:16 by nvienot #+# #+# */
/* Updated: 2019/03/15 23:39:51 by nvienot ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void ft_create_mandelbrot_vig(t_thrd *thrd)
{
t_render r;
r.zoom_x = VIG_HOR_SIZE / (X2_M - X1_M);
r.zoom_y = VIG_VER_SIZE / (Y2_M - Y1_M);
r.x = (VIG_HOR_SIZE * thrd->id) / NB_THREADS;
while (r.x < ((VIG_HOR_SIZE * (thrd->id + 1) / NB_THREADS)))
{
r.y = 0;
r.rc = r.x / r.zoom_x + X1_M;
while (r.y < IMG_VER_SIZE)
{
r.ic = r.y / r.zoom_y + Y1_M;
r.rz = 0;
r.iz = 0;
ft_calc(&r, 1, thrd->w->p.it_max, 0);
if (r.a == thrd->w->p.it_max && thrd->w->p.it_max > 0 && r.x > 0 \
&& r.x < VIG_HOR_SIZE - 1 && r.y > 0 && r.y < VIG_VER_SIZE - 1)
mlx_put_pixel_to_image(thrd->w->vig, r.x, r.y, (0));
r.y++;
}
r.x++;
}
}
void ft_create_duobrot_vig(t_thrd *thrd)
{
t_render r;
r.zoom_x = VIG_HOR_SIZE / (X2_M - X1_M);
r.zoom_y = VIG_VER_SIZE / (Y2_M - Y1_M);
r.x = (VIG_HOR_SIZE * thrd->id) / NB_THREADS;
while (r.x < ((VIG_HOR_SIZE * (thrd->id + 1) / NB_THREADS)))
{
r.y = 0;
r.rc = r.x / (r.zoom_x * 0.90) + X1_M + 0.55;
while (r.y < IMG_VER_SIZE)
{
r.ic = r.y / (r.zoom_y * 0.90) + Y1_M - 0.15;
r.rz = 0;
r.iz = 0;
ft_calc(&r, 2, thrd->w->p.it_max, 0);
if (r.a == thrd->w->p.it_max && thrd->w->p.it_max > 0 && r.x > 0 \
&& r.x < VIG_HOR_SIZE - 1 && r.y > 0 && r.y < VIG_VER_SIZE - 1)
mlx_put_pixel_to_image(thrd->w->vig, r.x, \
r.y + VIG_VER_SIZE, (0));
r.y++;
}
r.x++;
}
}
void ft_create_tricorn_vig(t_thrd *thrd)
{
t_render r;
r.zoom_x = VIG_HOR_SIZE / (X2_M - X1_M);
r.zoom_y = VIG_VER_SIZE / (Y2_M - Y1_M);
r.x = (VIG_HOR_SIZE * thrd->id) / NB_THREADS;
while (r.x < ((VIG_HOR_SIZE * (thrd->id + 1) / NB_THREADS)))
{
r.y = 0;
r.rc = r.x / (r.zoom_x * 0.9) + X1_M + 0.2;
while (r.y < IMG_VER_SIZE)
{
r.ic = r.y / (r.zoom_y * 0.9) + Y1_M - 0.1;
r.rz = 0;
r.iz = 0;
ft_calc(&r, 3, thrd->w->p.it_max, 0);
if (r.a == thrd->w->p.it_max && thrd->w->p.it_max > 0 && r.x > 0 \
&& r.x < VIG_HOR_SIZE - 1 && r.y > 0 && r.y < VIG_VER_SIZE - 1)
mlx_put_pixel_to_image(thrd->w->vig, r.x, \
r.y + VIG_VER_SIZE * 2, (0));
r.y++;
}
r.x++;
}
}
void ft_create_julia_vig(t_thrd *thrd)
{
t_render r;
r.zoom_x = VIG_HOR_SIZE / (X2_J - X1_J);
r.zoom_y = VIG_VER_SIZE / (Y2_J - Y1_J);
r.x = (VIG_HOR_SIZE * thrd->id) / NB_THREADS;
r.rc = 0.285 + thrd->w->p.rc;
r.ic = 0.01 + thrd->w->p.ic;
while (r.x < ((VIG_HOR_SIZE * (thrd->id + 1) / NB_THREADS)))
{
r.y = 0;
while (r.y < IMG_VER_SIZE)
{
r.rz = r.x / (r.zoom_x * 0.85) + X1_J - 0.15;
r.iz = r.y / (r.zoom_y * 0.85) + Y1_J - 0.15;
ft_calc(&r, 7, thrd->w->p.it_max, 0);
if (r.a == thrd->w->p.it_max && thrd->w->p.it_max > 0 && r.x > 0 \
&& r.x < VIG_HOR_SIZE - 1 && r.y > 0 && r.y < VIG_VER_SIZE - 1)
mlx_put_pixel_to_image(thrd->w->vig, r.x, \
r.y + VIG_VER_SIZE * 3, (0));
r.y++;
}
r.x++;
}
}
void ft_create_andy_vig(t_thrd *thrd)
{
t_render r;
r.zoom_x = VIG_HOR_SIZE / (X2_J + 1 - X1_J);
r.zoom_y = VIG_VER_SIZE / (Y2_J - Y1_J);
r.x = (VIG_HOR_SIZE * thrd->id) / NB_THREADS;
while (r.x < ((VIG_HOR_SIZE * (thrd->id + 1) / NB_THREADS)))
{
r.y = 0;
while (r.y < IMG_VER_SIZE)
{
r.rc = 0.285 + thrd->w->p.rc;
r.ic = 0.01 + thrd->w->p.ic;
r.rz = r.x / (r.zoom_x * 0.90) + X1_J - 0.65;
r.iz = r.y / (r.zoom_y * 0.90) + Y1_J - 0.1;
ft_calc(&r, 8, thrd->w->p.it_max, 0);
if (r.a == thrd->w->p.it_max && thrd->w->p.it_max > 0 && r.x > 0 \
&& r.x < VIG_HOR_SIZE - 1 && r.y > 0 && r.y < VIG_VER_SIZE - 1)
mlx_put_pixel_to_image(thrd->w->vig, r.x, \
r.y + VIG_VER_SIZE * 4, (0));
r.y++;
}
r.x++;
}
}