void julia_ext(t_tids *t, t_f f, t_f_data *d) { while (f.x < d->ww) { f.y = (t->index - 1) * (d->wh / d->threads); while (f.y < f.len) { f = init_julia(f, d); while (f.i < f.iter) { f.tmp = f.z_r; f.z_r = f.z_r * f.z_r - f.z_i * f.z_i + f.c_r; f.z_i = (f.tmp + f.tmp) * f.z_i + f.c_i; f.i++; if (f.z_r * f.z_r + f.z_i * f.z_i > 4) break ; } if (d->crazy) f.color = det_color(f.color, f.i, f.iter); else f.color = boring_color(f.color, f.i, f.iter); if (f.y >= 0 && f.x >= 0 && f.y <= d->wh && f.x <= d->ww) ft_putpixel_frct(f.x, f.y, f.color, d); f.y++; } f.x++; } }
t_env *init_env(void) { t_env *e; e = (t_env *)malloc(sizeof(t_env)); if (e == NULL) error_malloc(); e->win_width = WIDTH; e->win_height = HEIGHT; e->x = 0; e->y = 0; e->z = 150; e->option_x = WIDTH / 2; e->option_y = HEIGHT / 2; e->color_max = 0x000000; e->mlx = mlx_init(); e->i_max = 50; e->mouse_stop = 0; e->psychedelic = 0; e->color_value = 1; e->img = mlx_new_image(e->mlx, e->win_width, e->win_height); e->pxl = mlx_get_data_addr(e->img, &(e->bpp), &(e->s_line), &(e->ed)); e->mdb = init_mandelbrot(); e->jul = init_julia(); return (e); }
void reinit(t_win *win, t_frac *f) { if (win->type == FOL_JULIA) init_julia(f); else if (win->type == FOL_MANDEL) init_mandelbrot(f); else if (win->type == FOL_BURNI) init_burning_ship(f); }
int julia_key_events(int key, t_env *e) { if (key == ESC) exit(0); if (key == KEY_C) handle_color(e); if (key == UP || key == DOWN || key == LEFT || key == RIGHT) handle_pos(key, e->j); if (key == KEY_R) init_julia(e->j, e); if (key == KEY_H) e->help = !e->help ? 1 : 0; expose_hook(e); return (1); }
static void launch_fractol(int type) { t_env e; e.type = type; init_mlx(&(e.mlx)); if (type == TYPE_JULIA) init_julia(&(e.info), &(e.data)); else if (type == TYPE_MANDELBROT) init_mandelbrot(&(e.info), &(e.data)); else if (type == TYPE_BUDDHABROT) init_buddhabrot(&(e.info), &(e.data)); mlx_expose_hook(e.mlx.win, expose_hook, &e); mlx_loop(e.mlx.mlx); }
int julia(t_data *d, int x, int y, int max_i) { init_julia(d, x, y); while (++d->u.i < max_i) { d->u.zxx = d->u.rz * d->u.rz; d->u.zyy = d->u.iz * d->u.iz; d->u.old_rz = d->u.rz; d->u.old_iz = d->u.iz; d->u.rz = d->u.zxx - d->u.zyy + d->u.rc; d->u.iz = 2 * d->u.iz * d->u.old_rz + d->u.ic; if (d->u.rz == d->u.old_rz && d->u.iz == d->u.old_iz) d->u.i = max_i - 1; if (d->u.zxx + d->u.zyy > 4.0) break ; } if (d->u.i >= max_i) return (0); return (get_img_color(d, d->u.i, max_i)); }
int julia_special(t_data *d, int x, int y, int max_i) { double color; init_julia(d, x, y); while (++d->u.i < max_i) { d->u.old_rz = d->u.rz; d->u.rz = d->u.rz * d->u.rz - d->u.iz * d->u.iz; d->u.iz = 2 * d->u.old_rz * d->u.iz; d->u.rz += d->u.rc; d->u.iz += d->u.ic; if (d->u.rz * d->u.rz + d->u.iz * d->u.iz > 4.0) break ; d->u.i++; } if (d->u.i >= max_i) return (0); color = d->u.i + 1 - log(log(d->u.rz + d->u.iz)) / log(2); return (get_img_color(d, color, max_i)); }
int expose_hook(t_env *e) { if (e->av[1] && ft_strcmp(e->av[1], "-j") == 0) { init_julia(e); julia(e); } else if (e->av[1] && ft_strcmp(e->av[1], "-m") == 0) mandel(e); else if (e->av[1] && ft_strcmp(e->av[1], "-t") == 0) tric(e); else if (e->av[1] && ft_strcmp(e->av[1], "-J") == 0) { init_cub_julia(e); cub_julia(e); } else print_command(); mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0); return (0); }