diff options
author | Sebastian Leske <sebastian.leske@sleske.name> | 2015-08-20 18:20:50 +0200 |
---|---|---|
committer | Sebastian Leske <sebastian.leske@sleske.name> | 2015-08-30 22:47:54 +0200 |
commit | dc6eae261c42bf574cb34c52a3e2200da03e1b79 (patch) | |
tree | 90c12092afe9138ef34a375540ed678e70e0092e /navit/graphics | |
parent | 927d793179f294465f277d258e501a5291a32551 (diff) | |
download | navit-dc6eae261c42bf574cb34c52a3e2200da03e1b79.tar.gz |
gtk_drawing_area:Implement draw_circle - #66, part 5
Implement draw_circle using Cairo. Extract set_stroke_params_from_gc.
Diffstat (limited to 'navit/graphics')
-rw-r--r-- | navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c index 37596b72d..eb44042f6 100644 --- a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c +++ b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <signal.h> #include <sys/time.h> +#include <math.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <cairo.h> @@ -292,6 +293,14 @@ set_drawing_color(cairo_t *cairo, struct color c) } static void +set_stroke_params_from_gc(cairo_t *cairo, struct graphics_gc_priv *gc) +{ + set_drawing_color(cairo, gc->c); + cairo_set_dash(cairo, gc->dashes, gc->ndashes, gc->offset); + cairo_set_line_width(cairo, gc->linewidth); +} + +static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) { int i; @@ -301,9 +310,7 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point * for (i=1; i<count; i++) { cairo_line_to(gr->cairo, p[i].x, p[i].y); } - set_drawing_color(gr->cairo, gc->c); - cairo_set_dash(gr->cairo, gc->dashes, gc->ndashes, gc->offset); - cairo_set_line_width(gr->cairo, gc->linewidth); + set_stroke_params_from_gc(gr->cairo, gc); cairo_stroke(gr->cairo); } @@ -330,7 +337,9 @@ draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct poi static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) { - gdk_draw_arc(gr->drawable, gc->gc, FALSE, p->x-r/2, p->y-r/2, r, r, 0, 64*360); + cairo_arc (gr->cairo, p->x, p->y, r/2, 0.0, 2*M_PI); + set_stroke_params_from_gc(gr->cairo, gc); + cairo_stroke(gr->cairo); } static void |