From e5b2b11ec020494d5bc6fb577f444d2b874a8bed Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 25 May 2019 21:30:31 -0500 Subject: [PATCH] Why have I forgotten trigonometry again --- examples/cluster.c | 39 +++++++++++++++++++++++++++++++++++---- include/hexagram/module.h | 2 -- src/module.c | 12 +++--------- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/examples/cluster.c b/examples/cluster.c index 9f7eebb..83baf21 100644 --- a/examples/cluster.c +++ b/examples/cluster.c @@ -6,8 +6,9 @@ #include #include +#include -static void redraw(cairo_surface_t *sfc, cairo_t *ctx) { +static void redraw(cairo_t *ctx) { /* * Paint canvas black */ @@ -27,10 +28,10 @@ static void redraw(cairo_surface_t *sfc, cairo_t *ctx) { /* * Draw two smaller circles */ - cairo_arc(ctx, 442, 368, 64, 0, 360); + cairo_arc(ctx, 442, 368, 64, 0, 360 * (M_PI/180)); cairo_stroke(ctx); - cairo_arc(ctx, 578, 368, 64, 0, 360); + cairo_arc(ctx, 582, 368, 64, 0, 360 * (M_PI/180)); cairo_stroke(ctx); /* @@ -41,9 +42,38 @@ static void redraw(cairo_surface_t *sfc, cairo_t *ctx) { cairo_line_to(ctx, 592, 288); cairo_line_to(ctx, 432, 288); cairo_line_to(ctx, 432, 48); + cairo_set_source_rgb(ctx, 0.75, 0, 0); + cairo_fill(ctx); + + cairo_move_to(ctx, 432, 48); + cairo_line_to(ctx, 592, 48); + cairo_line_to(ctx, 592, 288); + cairo_line_to(ctx, 432, 288); + cairo_line_to(ctx, 432, 48); + cairo_set_source_rgb(ctx, 1, 1, 1); cairo_stroke(ctx); } +static void draw_text(cairo_t *cr) { + cairo_select_font_face(cr, "Helvetica", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + + cairo_set_font_size(cr, 13); + + cairo_move_to(cr, 208 + 192, 240); + cairo_save(cr); + cairo_rotate(cr, 45.0 * (M_PI/180)); + cairo_show_text(cr, "10"); + cairo_restore(cr); + + cairo_move_to(cr, 208, 240 + 192); + cairo_save(cr); + cairo_rotate(cr, 90.0 * (M_PI/180)); + cairo_show_text(cr, "20"); + cairo_restore(cr); +} + int main(int argc, char **argv) { Display *display; Window win; @@ -79,7 +109,8 @@ int main(int argc, char **argv) { ctx = cairo_create(sfc); - redraw(sfc, ctx); + redraw(ctx); + draw_text(ctx); while (1) { XExposeEvent *expose; diff --git a/include/hexagram/module.h b/include/hexagram/module.h index a1451d8..0985e87 100644 --- a/include/hexagram/module.h +++ b/include/hexagram/module.h @@ -14,8 +14,6 @@ int hexagram_module_close(hexagram_module *module); const char *hexagram_module_name(hexagram_module *module); -int hexagram_module_win(hexagram_module *module); - int hexagram_module_run(hexagram_module *module, hexagram_dict *buses); diff --git a/src/module.c b/src/module.c index c4a93d7..b7bd9e5 100644 --- a/src/module.c +++ b/src/module.c @@ -5,13 +5,15 @@ #include #include +#include + #include +#include struct _hexagram_module { const char *soname; void *handle; char *(*name)(); - int (*win)(); int (*run)(hexagram_dict *buses); pid_t pid; }; @@ -58,14 +60,6 @@ const char *hexagram_module_name(hexagram_module *module) { return module->name(); } -int hexagram_module_win(hexagram_module *module) { - if (module->win == NULL) { - return -1; - } - - return module->win(); -} - int hexagram_module_run(hexagram_module *module, hexagram_dict *buses) { if (module->run == NULL) {