new features ported from macos branch
This commit is contained in:
parent
4a955f0f17
commit
ec0d447081
4 changed files with 84 additions and 10 deletions
|
@ -136,6 +136,8 @@ void parallel_fractal(t_fractol *fr);
|
|||
|
||||
void zoom_in(t_fractol *frm, int x, int y);
|
||||
void zoom_out(t_fractol *fr);
|
||||
void zoom_in_key(t_fractol *fr);
|
||||
void zoom_out_key(t_fractol *fr);
|
||||
void move_left(t_fractol *fr);
|
||||
void move_right(t_fractol *fr);
|
||||
void move_up(t_fractol *fr);
|
||||
|
@ -147,4 +149,7 @@ int change_real(t_fractol *fr, int x, int *start_x);
|
|||
int change_imagianry(t_fractol *fr, int x, int *start_x);
|
||||
void gradient_hook(t_fractol *fr);
|
||||
|
||||
void julia_samples(t_fractol *fr, double real, double img);
|
||||
void mandelbrot_samples(t_fractol *fr, double x, double y);
|
||||
|
||||
#endif
|
||||
|
|
31
src/fractal_samples.c
Normal file
31
src/fractal_samples.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* fractal_samples.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/25 14:52:57 by gtertysh #+# #+# */
|
||||
/* Updated: 2017/03/25 14:52:58 by gtertysh ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fractol.h"
|
||||
|
||||
void julia_samples(t_fractol *fr, double real, double img)
|
||||
{
|
||||
complex_equal(real, img, &fr->frac->com_const);
|
||||
new_and_clear_image(fr);
|
||||
parallel_fractal(fr);
|
||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
||||
}
|
||||
|
||||
void mandelbrot_samples(t_fractol *fr, double x, double y)
|
||||
{
|
||||
fr->frac->mov.x = x;
|
||||
fr->frac->mov.y = y;
|
||||
fr->frac->mov.z = 1;
|
||||
new_and_clear_image(fr);
|
||||
parallel_fractal(fr);
|
||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
||||
}
|
32
src/hooks.c
32
src/hooks.c
|
@ -6,30 +6,52 @@
|
|||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/16 18:59:03 by gtertysh #+# #+# */
|
||||
/* Updated: 2017/03/24 14:02:46 by gtertysh ### ########.fr */
|
||||
/* Updated: 2017/03/25 14:59:09 by gtertysh ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fractol.h"
|
||||
|
||||
void sample(t_fractol *fr, int key)
|
||||
{
|
||||
if (fr->frac->frac_type == 0 && key == 18)
|
||||
julia_samples(fr, -1.037, 0.17);
|
||||
if (fr->frac->frac_type == 0 && key == 19)
|
||||
julia_samples(fr, -0.1, 0.651);
|
||||
if (fr->frac->frac_type == 0 && key == 20)
|
||||
julia_samples(fr, 0.285, 0.01);
|
||||
if (fr->frac->frac_type == 1 && key == 18)
|
||||
mandelbrot_samples(fr, -1.30000000000002603931, 0);
|
||||
if (fr->frac->frac_type == 1 && key == 19)
|
||||
mandelbrot_samples(fr, 0.0297908120967462314188, -0.458060975296945872);
|
||||
if (fr->frac->frac_type == 1 && key == 20)
|
||||
mandelbrot_samples(fr, 0.471844506346038136365, -1.1151425080399373598);
|
||||
}
|
||||
|
||||
int key_hook(int keycode, void *fr)
|
||||
{
|
||||
if (keycode == 53)
|
||||
quit(fr);
|
||||
if (keycode == 24)
|
||||
zoom_in_key(fr);
|
||||
if (keycode == 27)
|
||||
zoom_out_key(fr);
|
||||
if (keycode == 49)
|
||||
gradient_hook(fr);
|
||||
if (keycode == 124)
|
||||
move_left(fr);
|
||||
if (keycode == 123)
|
||||
move_left(fr);
|
||||
if (keycode == 124)
|
||||
move_right(fr);
|
||||
if (keycode == 125)
|
||||
move_up(fr);
|
||||
if (keycode == 126)
|
||||
move_up(fr);
|
||||
if (keycode == 125)
|
||||
move_down(fr);
|
||||
if (keycode == 69)
|
||||
change_limit_up(fr);
|
||||
if (keycode == 78)
|
||||
change_limit_down(fr);
|
||||
if (keycode == 18 || keycode == 19 || keycode == 20)
|
||||
sample(fr, keycode);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/24 19:21:45 by gtertysh #+# #+# */
|
||||
/* Updated: 2017/03/24 21:12:49 by gtertysh ### ########.fr */
|
||||
/* Updated: 2017/03/25 14:53:26 by gtertysh ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -29,7 +29,7 @@ int change_imagianry(t_fractol *fr, int x, int *start_x)
|
|||
{
|
||||
if (fr->frac->com_const.im < 3)
|
||||
{
|
||||
fr->frac->com_const.im += 0.05;
|
||||
fr->frac->com_const.im += 0.01;
|
||||
to_render = 1;
|
||||
}
|
||||
*start_x = x;
|
||||
|
@ -38,7 +38,7 @@ int change_imagianry(t_fractol *fr, int x, int *start_x)
|
|||
{
|
||||
if (fr->frac->com_const.im > -4)
|
||||
{
|
||||
fr->frac->com_const.im -= 0.05;
|
||||
fr->frac->com_const.im -= 0.1;
|
||||
to_render = 1;
|
||||
}
|
||||
*start_x = x;
|
||||
|
@ -55,7 +55,7 @@ int change_real(t_fractol *fr, int x, int *start_x)
|
|||
{
|
||||
if (fr->frac->com_const.rl < 3)
|
||||
{
|
||||
fr->frac->com_const.rl += 0.05;
|
||||
fr->frac->com_const.rl += 0.1;
|
||||
to_render = 1;
|
||||
}
|
||||
*start_x = x;
|
||||
|
@ -64,10 +64,26 @@ int change_real(t_fractol *fr, int x, int *start_x)
|
|||
{
|
||||
if (fr->frac->com_const.rl > -4)
|
||||
{
|
||||
fr->frac->com_const.rl -= 0.05;
|
||||
fr->frac->com_const.rl -= 0.1;
|
||||
to_render = 1;
|
||||
}
|
||||
*start_x = x;
|
||||
}
|
||||
return (to_render);
|
||||
}
|
||||
|
||||
void zoom_in_key(t_fractol *fr)
|
||||
{
|
||||
fr->frac->mov.z *= 1.5;
|
||||
new_and_clear_image(fr);
|
||||
parallel_fractal(fr);
|
||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
||||
}
|
||||
|
||||
void zoom_out_key(t_fractol *fr)
|
||||
{
|
||||
fr->frac->mov.z /= 1.5;
|
||||
new_and_clear_image(fr);
|
||||
parallel_fractal(fr);
|
||||
mlx_put_image_to_window(fr->mlx, fr->win, fr->img->ptr, 0, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue