diff options
author | 2025-05-19 16:19:10 +0200 | |
---|---|---|
committer | 2025-05-19 16:19:10 +0200 | |
commit | d658971135bc1016325b223a3b21007be5fcc6e8 (patch) | |
tree | 66b4a9221cd4a47df1ed5dd2f8c083cd9f145ce4 /src/main/engine/engine.c | |
parent | 45579c2a734ea8f679655d0a59f5535078ecb568 (diff) | |
download | tris-d658971135bc1016325b223a3b21007be5fcc6e8.tar.gz tris-d658971135bc1016325b223a3b21007be5fcc6e8.zip |
Add the Circle type
Diffstat (limited to 'src/main/engine/engine.c')
-rw-r--r-- | src/main/engine/engine.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/engine/engine.c b/src/main/engine/engine.c index bea9554..92222bb 100644 --- a/src/main/engine/engine.c +++ b/src/main/engine/engine.c @@ -25,6 +25,7 @@ #include "../util.h" #include "ui/ui.h" #include "../util/list.h" +#include "types.h" #ifdef X11 #include <X11/Xlib.h> @@ -45,6 +46,7 @@ typedef struct Line { typedef struct Engine { UI *ui; + list_t *circles; void (*draw_frame)(); } Engine; @@ -66,6 +68,7 @@ engine_init(int w, int h) log_error("Error allocating memory for engine"); exit(EXIT_FAILURE); } + engine->circles = list_create(); width = w; height = h; @@ -77,6 +80,26 @@ engine_init(int w, int h) lines = list_create(); } +static Circle * +engine_new_circle(float cx, float cy, float r, int num_segments, int outline) +{ + Circle *circle = malloc(sizeof(Circle)); + circle->cx = cx; + circle->cy = cy; + circle->r = r; + circle->num_segments = num_segments; + circle->outline = outline; + + return circle; +} + +void +engine_draw_circle(float cx, float cy, float r, int num_segments, int outline) +{ + if (engine == NULL || engine->circles == NULL) return; + list_add(engine->circles, engine_new_circle(cx, cy, r, num_segments, outline)); +} + static Line * engine_new_line(int x1, int y1, int x2, int y2) { |