diff options
author | Vincent Sanders <vince@netsurf-browser.org> | 2009-07-10 18:36:49 +0000 |
---|---|---|
committer | Vincent Sanders <vince@netsurf-browser.org> | 2009-07-10 18:36:49 +0000 |
commit | 680298e61ce664e95b3f8143c0c0b814d5966f2a (patch) | |
tree | cd4bdf673143a3ff8496498927de526adfb9804e /gtk/gtk_plotters.c | |
parent | 5feb7018c5228a22d370d070c1f7c3dad2c71e25 (diff) | |
download | netsurf-680298e61ce664e95b3f8143c0c0b814d5966f2a.tar.gz netsurf-680298e61ce664e95b3f8143c0c0b814d5966f2a.tar.bz2 |
plotters line refactor
svn path=/trunk/netsurf/; revision=8446
Diffstat (limited to 'gtk/gtk_plotters.c')
-rw-r--r-- | gtk/gtk_plotters.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c index e323cb590..bc990199b 100644 --- a/gtk/gtk_plotters.c +++ b/gtk/gtk_plotters.c @@ -49,8 +49,7 @@ GdkDrawable *current_drawable; GdkGC *current_gc; cairo_t *current_cr; -static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed); +static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style); static bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill); static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width, colour c, const float transform[6]); @@ -129,21 +128,31 @@ bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *st return true; } -bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width, - colour c, bool dotted, bool dashed) +bool nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style) { - nsgtk_set_colour(c); - if (dotted) + + nsgtk_set_colour(style->stroke_colour); + + switch (style->stroke_type) { + case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + default: + nsgtk_set_solid(); + break; + + case PLOT_OP_TYPE_DOT: /**< Doted plot */ nsgtk_set_dotted(); - else if (dashed) + break; + + case PLOT_OP_TYPE_DASH: /**< dashed plot */ nsgtk_set_dashed(); - else - nsgtk_set_solid(); + break; + } - if (width == 0) - width = 1; + if (style->stroke_width == 0) + cairo_set_line_width(current_cr, 1); + else + cairo_set_line_width(current_cr, style->stroke_width); - cairo_set_line_width(current_cr, width); cairo_move_to(current_cr, x0 + 0.5, y0 + 0.5); cairo_line_to(current_cr, x1 + 0.5, y1 + 0.5); cairo_stroke(current_cr); |