aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/event.c4
-rw-r--r--src/state.c22
2 files changed, 23 insertions, 3 deletions
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)