aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event.c12
-rw-r--r--src/fractals/burningship.c7
-rw-r--r--src/fractals/tricorn.c4
-rw-r--r--src/main.c2
4 files changed, 17 insertions, 8 deletions
diff --git a/src/event.c b/src/event.c
index 668a599..e868ae8 100644
--- a/src/event.c
+++ b/src/event.c
@@ -69,9 +69,10 @@ int event_keydown(int key, t_state *state)
int event_mouse(int button, int x, int y, t_state *state)
{
- (void)x;
- (void)y;
+ /* (void)x; */
+ /* (void)y; */
+ /* printf("%d\n", button); */
if (button == MLX_MOUSE_SCROLL_UP)
{
h_zoom_in(state);
@@ -85,6 +86,13 @@ int event_mouse(int button, int x, int y, t_state *state)
/* state->center.r -= MOVE_SPEED * (double)(x - WINDOW_WIDTH / 2) / WINDOW_WIDTH; */
/* state->center.i -= MOVE_SPEED * (double)(y - WINDOW_HEIGHT / 2) / WINDOW_HEIGHT; */
}
+ else if (button == MLX_MOUSE_LEFT)
+ {
+ printf("%d %d\n", x, y);
+ state->center.r = ((double)x / FWINDOW_WIDTH) * state->plane.r - state->plane.r / 2.0;
+ state->center.i = ((double)y / FWINDOW_HEIGHT) * state->plane.i - state->plane.i / 2.0;
+
+ }
else
return (0);
state->updated = false;
diff --git a/src/fractals/burningship.c b/src/fractals/burningship.c
index 07baf38..d9e1a9c 100644
--- a/src/fractals/burningship.c
+++ b/src/fractals/burningship.c
@@ -20,9 +20,10 @@ int burningship(t_state *state, t_complex c)
t_complex z;
t_complex z_square;
double tmp;
-
+
(void)state;
- z = c;
+ z.r = c.r;
+ z.i = c.i;
n = -1;
while (++n < state->iterations)
{
@@ -30,7 +31,7 @@ int burningship(t_state *state, t_complex c)
z_square.r = z.r * z.r;
if (z_square.r + z_square.i > BURNING_SHIP_ESCAPE_RADIUS_SQUARED)
break;
- tmp = z_square.r - z_square.i + z.r;
+ tmp = z_square.r - z_square.i + c.r;
z.i = fabs(2.0 * z.r * z.i + c.i);
z.r = fabs(tmp);
}
diff --git a/src/fractals/tricorn.c b/src/fractals/tricorn.c
index 2abe01b..63c003b 100644
--- a/src/fractals/tricorn.c
+++ b/src/fractals/tricorn.c
@@ -20,7 +20,7 @@ int tricorn(t_state *state, t_complex c)
t_complex z;
t_complex z_square;
double tmp;
-
+
(void)state;
z = c;
n = -1;
@@ -30,7 +30,7 @@ int tricorn(t_state *state, t_complex c)
z_square.r = z.r * z.r;
if (z_square.r + z_square.i > TRICORN_ESCAPE_RADIUS_SQUARED)
break;
- tmp = z_square.r - z_square.i + z.r;
+ tmp = z_square.r - z_square.i + c.r;
z.i = -2.0 * z.r * z.i + c.i;
z.r = tmp;
}
diff --git a/src/main.c b/src/main.c
index 22e8c84..841eb69 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
return (0);
}
mlx_hook(state.window_ptr, 17, 0, event_quit, (void*)&state);
- mlx_hook(state.window_ptr, 2, 2, event_keydown, (void*)&state);
+ mlx_key_hook(state.window_ptr, event_keydown, (void*)&state);
mlx_hook(state.window_ptr, 6, 64, event_mouse_motion, (void*)&state);
mlx_mouse_hook(state.window_ptr, event_mouse, (void*)&state);
mlx_loop_hook(state.mlx_ptr, render_update, (void*)&state);