diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-05-10 14:08:07 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-05-10 14:08:07 +0200 |
| commit | 6d9c284a24555a7df0b37661ff3c5491d6d0449a (patch) | |
| tree | 58d7958e7e6f59181463343891b1a590016cf5ef /inc | |
| parent | aea23b389a5eba09b3865209a08843e66481dd54 (diff) | |
| download | cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.tar.gz cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.tar.bz2 cardioid-6d9c284a24555a7df0b37661ff3c5491d6d0449a.zip | |
First primitive cardioid drawing
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/cardioid.h | 27 | ||||
| -rw-r--r-- | inc/graphics.h | 5 |
2 files changed, 31 insertions, 1 deletions
diff --git a/inc/cardioid.h b/inc/cardioid.h new file mode 100644 index 0000000..23ba64a --- /dev/null +++ b/inc/cardioid.h @@ -0,0 +1,27 @@ +#ifndef CARDIOID_H +# define CARDIOID_H + +# include <stddef.h> +# include <SDL2/SDL.h> + +typedef struct +{ + size_t points_num; + SDL_Point *points; + SDL_Point center; + size_t radius; + // double multiplication; +} t_cardioid; + +# define MIN(x, y) ((x) < (y) ? (x) : (y)) + +# define CARDIOID_ADD_POINTS(cardioid, n) cardioid_update_points((cardioid), (cardioid)->points_num + (n)) +# define CARDIOID_SUB_POINTS(cardioid, n) \ + cardioid_update_points((cardioid), (cardioid)->points_num < (n) ? 0 : (cardioid)->points_num - (n)) + +int cardioid_init(t_cardioid *cardioid, size_t points_num, int width, int height); +int cardioid_update_window(t_cardioid *cardioid, int width, int height); +int cardioid_update_points(t_cardioid *cardioid, size_t points_num); +void cardioid_quit(t_cardioid *cardioid); + +#endif diff --git a/inc/graphics.h b/inc/graphics.h index efe7dcd..bb7e491 100644 --- a/inc/graphics.h +++ b/inc/graphics.h @@ -4,14 +4,17 @@ # include <stdbool.h> # include <SDL2/SDL.h> +# include "cardioid.h" + typedef struct { SDL_Window *window; SDL_Renderer *renderer; + t_cardioid *cardioid; bool running; } t_state; -void graphics_init(t_state *state, int width, int height); +void graphics_init(t_state *state, int width, int height, t_cardioid *cardioid); void graphics_quit(t_state *state); void graphics_run(t_state *state); |
