From 66493421e65d8cbda3e17fdbe43824387e3d51a7 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 23 May 2018 13:04:19 +0100 Subject: Plotters: Change stroke width in the plot_style_t to fixed point. --- frontends/gtk/plotters.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'frontends/gtk/plotters.c') diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c index 88e7760c6..6178104d5 100644 --- a/frontends/gtk/plotters.c +++ b/frontends/gtk/plotters.c @@ -88,6 +88,20 @@ static inline void nsgtk_set_dashed(void) } +/** + * Set cairo context line width. + */ +static inline void nsgtk_set_line_width(plot_style_fixed width) +{ + if (width == 0) { + cairo_set_line_width(current_cr, 1); + } else { + cairo_set_line_width(current_cr, + plot_style_fixed_to_double(width)); + } +} + + /** * \brief Sets a clip rectangle for subsequent plot operations. * @@ -191,10 +205,7 @@ nsgtk_plot_disc(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_arc(current_cr, x, y, radius, 0, M_PI * 2); @@ -242,10 +253,7 @@ nsgtk_plot_line(const struct redraw_context *ctx, nsgtk_set_colour(style->stroke_colour); } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); /* core expects horizontal and vertical lines to be on pixels, not * between pixels @@ -331,10 +339,7 @@ nsgtk_plot_rectangle(const struct redraw_context *ctx, break; } - if (style->stroke_width == 0) - cairo_set_line_width(current_cr, 1); - else - cairo_set_line_width(current_cr, style->stroke_width); + nsgtk_set_line_width(style->stroke_width); cairo_rectangle(current_cr, rect->x0 + 0.5, -- cgit v1.2.3