aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fractol.h4
-rw-r--r--src/event.c4
-rw-r--r--src/state.c22
3 files changed, 26 insertions, 4 deletions
diff --git a/include/fractol.h b/include/fractol.h
index 05172b5..e054086 100644
--- a/include/fractol.h
+++ b/include/fractol.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 09:28:16 by cacharle #+# #+# */
-/* Updated: 2020/02/25 16:21:56 by cacharle ### ########.fr */
+/* Updated: 2020/02/25 18:07:42 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -53,6 +53,7 @@
# define MLXK_L 37
# define MLXK_D 2
# define MLXK_F 3
+# define MLXK_S 1
# define MLXK_PLUS 24
# define MLXK_MINUS 27
@@ -134,6 +135,7 @@ typedef struct
int state_init(t_state *state, char *fractal_name);
int state_destroy(t_state *state);
void state_update_palette(t_state *state);
+void state_shift_palette(t_state *state);
/*
** render.c
diff --git a/src/event.c b/src/event.c
index d3adc1b..b701d2f 100644
--- a/src/event.c
+++ b/src/event.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 09:52:35 by cacharle #+# #+# */
-/* Updated: 2020/02/25 17:04:38 by cacharle ### ########.fr */
+/* Updated: 2020/02/25 18:08:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -49,6 +49,8 @@ int event_keydown(int key, t_state *state)
h_zoom_in(state);
else if (key == MLXK_D)
h_zoom_out(state);
+ else if (key == MLXK_S)
+ state_shift_palette(state);
else
return (0);
state->updated = false;
diff --git a/src/state.c b/src/state.c
index ae9f107..4d94075 100644
--- a/src/state.c
+++ b/src/state.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 09:58:01 by cacharle #+# #+# */
-/* Updated: 2020/02/25 17:31:49 by cacharle ### ########.fr */
+/* Updated: 2020/02/25 18:28:02 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,13 +27,31 @@ void state_update_palette(t_state *state)
while (++i < state->iterations)
{
hsl.h = (int)(255.0 * ((double)i / (double)state->iterations));
- hsl.s = 100;
+ hsl.s = 150;
hsl.l = 127;
state->palette[i] = color_hsl_to_rgb(hsl);
}
state->palette[i].hexcode = 0x111111;
}
+void state_shift_palette(t_state *state)
+{
+ int i;
+ t_color_hsl hsl;
+ int shift_size;
+
+ /* printf("yo\n"); */
+ i = -1;
+ shift_size = 255 / state->iterations;
+ while (++i < state->iterations)
+ {
+ hsl = color_rgb_to_hsl(state->palette[i]);
+ hsl.h += shift_size;
+ hsl.h %= 256;
+ state->palette[i] = color_hsl_to_rgb(hsl);
+ }
+}
+
static int st_state_dispatch_func(t_state *state, char *fractal_name)
{
if (ft_strcmp(fractal_name, "mandelbrot") == 0)