app: change segment drawing to using pixel centers and CAP_SQUARE line ends

This looks exactly the same for the selection, but is needed like that
for segment drawing in tools.
This commit is contained in:
Michael Natterer 2010-09-23 14:26:52 +02:00
parent ddc63de6d6
commit 612aee9f33
3 changed files with 11 additions and 6 deletions

View File

@ -385,6 +385,7 @@ selection_render_mask (Selection *selection)
cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA); cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
gimp_cairo_add_segments (cr, gimp_cairo_add_segments (cr,

View File

@ -224,6 +224,7 @@ gimp_display_shell_set_layer_style (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
if (GIMP_IS_LAYER_MASK (drawable)) if (GIMP_IS_LAYER_MASK (drawable))
{ {
@ -258,6 +259,7 @@ gimp_display_shell_set_selection_out_style (GimpDisplayShell *shell,
g_return_if_fail (cr != NULL); g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
pattern = gimp_cairo_stipple_pattern_create (&selection_out_fg, pattern = gimp_cairo_stipple_pattern_create (&selection_out_fg,
&selection_out_bg, &selection_out_bg,
@ -326,9 +328,10 @@ gimp_display_shell_set_tool_bg_style (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL); g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 3.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width (cr, 3.0);
gimp_cairo_set_source_rgba (cr, &tool_bg); gimp_cairo_set_source_rgba (cr, &tool_bg);
} }
@ -339,8 +342,9 @@ gimp_display_shell_set_tool_fg_style (GimpDisplayShell *shell,
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL); g_return_if_fail (cr != NULL);
cairo_set_line_width (cr, 1.0);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width (cr, 1.0);
gimp_cairo_set_source_rgba (cr, &tool_fg); gimp_cairo_set_source_rgba (cr, &tool_fg);
} }

View File

@ -101,13 +101,13 @@ gimp_cairo_add_segments (cairo_t *cr,
{ {
if (segs[i].x1 == segs[i].x2) if (segs[i].x1 == segs[i].x2)
{ {
cairo_move_to (cr, segs[i].x1 + 0.5, segs[i].y1); cairo_move_to (cr, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
cairo_line_to (cr, segs[i].x2 + 0.5, segs[i].y2); cairo_line_to (cr, segs[i].x2 + 0.5, segs[i].y2 - 1.0);
} }
else else
{ {
cairo_move_to (cr, segs[i].x1, segs[i].y1 + 0.5); cairo_move_to (cr, segs[i].x1 + 0.5, segs[i].y1 + 0.5);
cairo_line_to (cr, segs[i].x2, segs[i].y2 + 0.5); cairo_line_to (cr, segs[i].x2 - 1.0, segs[i].y2 + 0.5);
} }
} }
} }