-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f367324
commit 62ef196
Showing
10 changed files
with
104 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/01/16 11:41:57 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 01:24:20 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:27:08 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/03/16 00:12:27 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 01:22:40 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:41:42 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -20,5 +20,5 @@ int ft_getfirstdecimal(float n) | |
nb = (int)n; | ||
if (nb < 0) | ||
nb = -nb; | ||
return(nb % 10); | ||
} | ||
return (nb % 10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2018/11/13 16:19:26 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 01:40:30 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:42:09 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,58 +6,80 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/03/13 21:07:55 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/15 23:47:16 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 04:08:04 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "fractol.h" | ||
|
||
static void ft_calc_2(t_render *r, int fract, int it_max) | ||
static void ft_calc_3(t_render *r, int fract, int it_max, double y) | ||
{ | ||
double x; | ||
|
||
if (fract == 5 || fract == 11) | ||
{ | ||
while (((x = r->rz * r->rz) - y) < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = x - y + r->rc; | ||
r->iz = 2 * r->r * r->iz + r->ic; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
} | ||
} | ||
|
||
static void ft_calc_2(t_render *r, int fract, int it_max, double y) | ||
{ | ||
double x; | ||
|
||
if (fract == 3 || fract == 9) | ||
{ | ||
while ((r->rz * r->rz + r->iz * r->iz) < 4 && r->a < it_max) | ||
while ((x = r->rz * r->rz) + y < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = r->rz * r->rz - r->iz * r->iz + r->rc; | ||
r->rz = x - y + r->rc; | ||
r->iz = -2 * r->r * r->iz + r->ic; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
} | ||
else if (fract == 4 || fract == 10) | ||
{ | ||
while ((r->rz * r->rz + r->iz * r->iz) < 4 && r->a < it_max) | ||
while ((x = r->rz * r->rz) + y < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = r->rz * r->rz - r->iz * r->iz + r->rc; | ||
r->rz = x - y + r->rc; | ||
r->iz = 2 * fabs(r->r) * fabs(r->iz) + r->ic; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
} | ||
} | ||
|
||
static void ft_calc_1(t_render *r, int fract, int it_max) | ||
static void ft_calc_1(t_render *r, int fract, int it_max, double y) | ||
{ | ||
double x; | ||
double y; | ||
|
||
if (fract == 1 || fract == 7) | ||
{ | ||
while (((x = r->rz * r->rz) + (y = r->iz * r->iz)) < 4 && r->a < it_max) | ||
while ((x = r->rz * r->rz) + y < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = x - y + r->rc; | ||
r->iz = 2 * r->r * r->iz + r->ic; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
} | ||
else if (fract == 2 || fract == 8) | ||
{ | ||
while ((r->rz * r->rz + r->iz * r->iz) < 4 && r->a < it_max) | ||
while ((x = r->rz * r->rz) + y < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = r->rz * r->rz * r->rz - 3 * r->rz * r->iz * r->iz + r->rc; | ||
r->iz = 3 * r->r * r->r * r->iz - r->iz * r->iz * r->iz + r->ic; | ||
r->rz = x * r->rz - 3 * r->rz * y + r->rc; | ||
r->iz = 3 * r->r * r->r * r->iz - y * r->iz + r->ic; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
} | ||
|
@@ -69,41 +91,30 @@ void ft_calc(t_render *r, int fract, int it_max, double p) | |
double y; | ||
double z; | ||
|
||
x = 0; | ||
y = 0; | ||
r->a = 0; | ||
if (fract == 8 || fract == 12) | ||
if (fract == 8 || fract == 12) | ||
{ | ||
if (fract == 8) | ||
r->rc = r->rc + 0.155; | ||
if (fract == 12) | ||
r->rc = r->rc + 0.253; | ||
r->ic = r->ic + 0.013; | ||
} | ||
y = r->iz * r->iz; | ||
if (fract == 1 || fract == 2 || fract == 7 || fract == 8) | ||
ft_calc_1(r, fract, it_max); | ||
ft_calc_1(r, fract, it_max, y); | ||
else if (fract == 3 || fract == 4 || fract == 9 || fract == 10) | ||
ft_calc_2(r, fract, it_max); | ||
ft_calc_2(r, fract, it_max, y); | ||
else if (fract == 5 || fract == 11) | ||
{ | ||
while (((x = r->rz * r->rz) + (y = r->iz * r->iz)) < 4 && r->a < it_max) | ||
{ | ||
r->r = r->rz; | ||
r->rz = x - y + r->rc; | ||
r->iz = 2 * r->r * r->iz + r->ic; | ||
r->a++; | ||
} | ||
} | ||
ft_calc_3(r, fract, it_max, y); | ||
else if (fract == 6 || fract == 12) | ||
{ | ||
x = r->rz * r->rz; | ||
y = r->iz * r->iz; | ||
while (x + y < 4 && r->a < it_max) | ||
while ((x = r->rz * r->rz) + y < 4 && r->a < it_max) | ||
{ | ||
z = p * atan2(r->iz, r->rz); | ||
r->rz = (pow(x + y, p / 2)) * cos(z) + r->rc; | ||
r->iz = (pow(x + y, p / 2)) * sin(z) + r->ic; | ||
x = r->rz * r->rz; | ||
y = r->iz * r->iz; | ||
r->a++; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/03/11 18:39:39 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 01:53:33 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:21:03 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -21,34 +21,17 @@ static void deal_key_reset(int key, t_win *win) | |
ft_reset_fractale(win); | ||
} | ||
|
||
static void deal_key_move(int key, t_win *win) | ||
static void deal_key_2(int key, t_win *win) | ||
{ | ||
if (key == ARROW_UP) | ||
win->p.moove_ver -= SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_DOWN) | ||
win->p.moove_ver += SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_RIGHT) | ||
win->p.moove_hor += SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_LEFT) | ||
win->p.moove_hor -= SIZE_MOV / win->p.zoom; | ||
} | ||
|
||
int deal_key(int key, t_win *win) | ||
{ | ||
if (key == ARROW_DOWN || key == ARROW_UP \ | ||
|| key == ARROW_RIGHT || key == ARROW_LEFT) | ||
deal_key_move(key, win); | ||
else if (key == PAGE_UP) | ||
win->p.it_max += 1; | ||
else if (key == PAGE_DOWN && win->p.it_max > 2) | ||
win->p.it_max -= 1; | ||
else if (key == TOUCH_SUP && (win->fract == 6 || win->fract == 12)) | ||
if (key == TOUCH_SUP && (win->fract == 6 || win->fract == 12)) | ||
win->p.pow += 0.1; | ||
else if (key == TOUCH_INF && (win->fract == 6 || win->fract == 12) && win->p.pow > 1) | ||
else if (key == TOUCH_INF && (win->fract == 6 \ | ||
|| win->fract == 12) && win->p.pow > 1) | ||
win->p.pow -= 0.1; | ||
else if (key == TOUCH_CRF && (win->fract == 6 || win->fract == 12)) | ||
win->p.pow += 1; | ||
else if (key == TOUCH_CRO && (win->fract == 6 || win->fract == 12) && win->p.pow > 1) | ||
else if (key == TOUCH_CRO && (win->fract == 6 \ | ||
|| win->fract == 12) && win->p.pow > 1) | ||
win->p.pow -= 1; | ||
else if (key == TOUCH_Z) | ||
(win->menu == 0) ? (win->menu += 1) : (win->menu = 0); | ||
|
@@ -58,6 +41,22 @@ int deal_key(int key, t_win *win) | |
(win->vig_it == 0) ? (win->vig_it += 1) : (win->vig_it = 0); | ||
else if (key == TOUCH_M && win->fract > 6) | ||
(win->motion == 0) ? (win->motion += 1) : (win->motion = 0); | ||
} | ||
|
||
int deal_key(int key, t_win *win) | ||
{ | ||
if (key == ARROW_UP) | ||
win->p.moove_ver -= SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_DOWN) | ||
win->p.moove_ver += SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_RIGHT) | ||
win->p.moove_hor += SIZE_MOV / win->p.zoom; | ||
else if (key == ARROW_LEFT) | ||
win->p.moove_hor -= SIZE_MOV / win->p.zoom; | ||
else if (key == PAGE_UP) | ||
win->p.it_max += 1; | ||
else if (key == PAGE_DOWN && win->p.it_max > 2) | ||
win->p.it_max -= 1; | ||
else if (key == TOUCH_C) | ||
(win->p.color > 999999999) ? (win->p.color = 99) \ | ||
: (win->p.color *= 1.5); | ||
|
@@ -66,6 +65,7 @@ int deal_key(int key, t_win *win) | |
deal_key_reset(key, win); | ||
else if (key == TOUCH_ESC) | ||
ft_exit(win); | ||
deal_key_2(key, win); | ||
ft_create_all(win); | ||
return (1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/03/11 18:40:43 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/15 23:24:26 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:38:00 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -78,8 +78,7 @@ int deal_mouse(int mouse, int x, int y, t_win *win) | |
win->p.zoom *= (double)COEF_ZOOM; | ||
win->p.x1 = oldx - (double)x / win->p.zoom; | ||
win->p.y1 = oldy - (double)y / win->p.zoom; | ||
if (win->immersive == 1) | ||
win->p.it_max += 1; | ||
(win->immersive == 1) ? win->p.it_max += 1 : 0; | ||
} | ||
(mouse == 1) ? deal_mouse_click(win, x, y) : 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/01/22 11:48:56 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 03:17:31 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:28:56 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -16,7 +16,7 @@ void ft_usage(void) | |
{ | ||
write(1, "Usage: ./fractol [fractal name]\n\n", 34); | ||
write(1, "Fractal names (use name, with uppercase letter) :\n", 51); | ||
write(1, "1. Mandelbrot\n2. Duobrot\n3. Tricorn\n4. Burningship", 51); | ||
write(1, "1. Mandelbrot\n2. Duobrot\n3. Tricorn\n4. Burningship\n", 52); | ||
write(1, "5. Palmtree\n6. Multibrot\n7. Julia\n8. Andy\n", 43); | ||
write(1, "9. Microcells\n10. Brain\n11. Flower\n12. Multijulia\n", 51); | ||
write(1, "\nExample: './fractol Mandelbrot' - Displays Mandelbrot\n", 56); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,34 +6,32 @@ | |
/* By: nvienot <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/01/22 21:29:22 by nvienot #+# #+# */ | ||
/* Updated: 2019/03/16 02:50:50 by nvienot ### ########.fr */ | ||
/* Updated: 2019/03/16 03:34:45 by nvienot ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "fractol.h" | ||
|
||
static void ft_get_pow(t_win *win) | ||
{ | ||
char *x; | ||
char *y; | ||
char *z; | ||
float ent; | ||
int dec; | ||
char *x; | ||
char *y; | ||
float ent; | ||
int dec; | ||
|
||
ent = (float)win->p.pow; | ||
dec = ((int)(10 * ent) % 10); | ||
y = ft_itoa(ent); | ||
x = ft_strjoinnfree(y, ".", 1); | ||
z = ft_itoa(dec); | ||
x = ft_strjoinnfree(x, z, 3); | ||
x = ft_strjoinnfree(ft_itoa(ent), ".", 1); | ||
x = ft_strjoinnfree(x, ft_itoa(dec), 3); | ||
mlx_string_put(win->mlx_ptr, win->win_ptr, 170, 45, GREY, x); | ||
mlx_string_put(win->mlx_ptr, win->win_ptr, 140, 25, \ | ||
GREY, y = ft_itoa(win->p.it_max)); | ||
free(x); | ||
free(y); | ||
} | ||
|
||
static void ft_print_menu_1(t_win *win) | ||
{ | ||
char *x; | ||
|
||
if (win->fract == 1) | ||
mlx_string_put(win->mlx_ptr, win->win_ptr, 120, 5, GREY, F1); | ||
else if (win->fract == 2) | ||
|
@@ -58,10 +56,6 @@ static void ft_print_menu_1(t_win *win) | |
mlx_string_put(win->mlx_ptr, win->win_ptr, 120, 5, GREY, F11); | ||
else if (win->fract == 12) | ||
mlx_string_put(win->mlx_ptr, win->win_ptr, 120, 5, GREY, F12); | ||
mlx_string_put(win->mlx_ptr, win->win_ptr, 140, 25, \ | ||
GREY, x = ft_itoa(win->p.it_max)); | ||
ft_get_pow(win); | ||
free(x); | ||
} | ||
|
||
static void ft_print_menu_2(t_win *win) | ||
|
@@ -95,6 +89,7 @@ void ft_print_menu(t_win *w) | |
mlx_string_put(w->mlx_ptr, w->win_ptr, 10, 25, GREY, "Iterations |"); | ||
mlx_string_put(w->mlx_ptr, w->win_ptr, 10, 45, GREY, "Power (Multi) |"); | ||
ft_print_menu_1(w); | ||
ft_get_pow(w); | ||
mlx_string_put(w->mlx_ptr, w->win_ptr, 10, 65, \ | ||
GREY, "Press Z to display controls"); | ||
mlx_string_put(w->mlx_ptr, w->win_ptr, 10, 635, GREY, "Motion_ju mode"); | ||
|
Oops, something went wrong.