diff options
author | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-26 11:14:11 +0000 |
---|---|---|
committer | Sven Weidauer <sven.weidauer@gmail.com> | 2011-02-26 11:14:11 +0000 |
commit | 8b1a36e2dbe6930e4d166327e564d2420eb0febe (patch) | |
tree | a5aa1831f7aaf5f9fc92789eb1a72b92a7ac8fea /cocoa/plotter.m | |
parent | 2a693de4dfb684332e9b9a1f748914c6da08206c (diff) | |
download | netsurf-8b1a36e2dbe6930e4d166327e564d2420eb0febe.tar.gz netsurf-8b1a36e2dbe6930e4d166327e564d2420eb0febe.tar.bz2 |
Correctly centering lines on pixel grid if their width is even.
svn path=/trunk/netsurf/; revision=11823
Diffstat (limited to 'cocoa/plotter.m')
-rw-r--r-- | cocoa/plotter.m | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cocoa/plotter.m b/cocoa/plotter.m index c51e82c91..c42f0d9a6 100644 --- a/cocoa/plotter.m +++ b/cocoa/plotter.m @@ -70,7 +70,7 @@ static void cocoa_plot_path_set_stroke_pattern(NSBezierPath *path,const plot_sty break; } - [path setLineWidth: cocoa_px_to_pt( pstyle->stroke_width )]; + [path setLineWidth: cocoa_px_to_pt( pstyle->stroke_width > 0 ? pstyle->stroke_width : 1 )]; } static bool plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle) @@ -87,7 +87,9 @@ static bool plot_line(int x0, int y0, int x1, int y1, const plot_style_t *pstyle const bool horizontal = y0 == y1; const bool vertical = x0 == x1; - cocoa_center_pixel( !horizontal, !vertical ); + const bool oddThickness = pstyle->stroke_width != 0 ? (pstyle->stroke_width % 2) != 0 : true; + + if (oddThickness) cocoa_center_pixel( !horizontal, !vertical ); [cocoa_convert_colour( pstyle->stroke_colour ) set]; [path stroke]; @@ -141,7 +143,7 @@ void cocoa_plot_render_path(NSBezierPath *path,const plot_style_t *pstyle) } if (pstyle->stroke_type != PLOT_OP_TYPE_NONE) { - cocoa_center_pixel( true, true ); + if (pstyle->stroke_width % 2 != 0) cocoa_center_pixel( true, true ); cocoa_plot_path_set_stroke_pattern(path,pstyle); |