diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-02-24 13:48:17 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-02-24 13:48:17 +0100 |
| commit | 8db6918f320b792698f385bb2ea58ddd94cba6fe (patch) | |
| tree | 1df107a1357c11ba4473721b2ab608c842efbdf6 /src/state.c | |
| parent | ee4c9685acd70b9b12b22d967c2a45e9a63a714c (diff) | |
| download | fractol-8db6918f320b792698f385bb2ea58ddd94cba6fe.tar.gz fractol-8db6918f320b792698f385bb2ea58ddd94cba6fe.tar.bz2 fractol-8db6918f320b792698f385bb2ea58ddd94cba6fe.zip | |
window_complex position buffer, basic palette, mandelbrot working
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/state.c b/src/state.c index 4f33041..33aa98b 100644 --- a/src/state.c +++ b/src/state.c @@ -6,16 +6,37 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/24 09:58:01 by cacharle #+# #+# */ -/* Updated: 2020/02/24 10:43:08 by cacharle ### ########.fr */ +/* Updated: 2020/02/24 12:34:50 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "fractol.h" +/* #define PALETTE_START 0x000022 */ +/* #define PALETTE_END 0xd62f2f */ +#define PALETTE_START 0x000000 +#define PALETTE_END 0xffffff + static void st_state_init_palette(t_state *state) { + t_color tmp; + int step_r; + int step_g; + int step_b; + int i; - + tmp.hexcode = PALETTE_START; + step_r = ft_abs((PALETTE_END >> 16) - (PALETTE_START >> 16) ) / PALETTE_SIZE; + step_g = ft_abs(((PALETTE_END >> 8) & 0xff) - ((PALETTE_START >> 8) & 0xff)) / PALETTE_SIZE; + step_b = ft_abs((PALETTE_END & 0xff) - (PALETTE_START & 0xff) ) / PALETTE_SIZE; + i = -1; + while (++i < PALETTE_SIZE) + { + state->palette[i] = tmp; + tmp.rgb.r += step_r; + tmp.rgb.g += step_g; + tmp.rgb.b += step_b; + } } int state_init(t_state *state, char *fractal_name) @@ -33,6 +54,13 @@ int state_init(t_state *state, char *fractal_name) state->window.data = mlx_get_data_addr(state->window.id, &state->window.depth, &state->window.size_line, &state->window.endian); state->running = true; + state->func = &mandelbrot; + state->center.a = 0.0; + state->center.b = 0.0; + state->plane.a = 4.0; + state->plane.b = 4.0; + render_update_window_complex(state); + st_state_init_palette(state); return (0); } |
