[vte/wip/mosaic: 32/35] draw: Make new diagonal characters align better with box drawings



commit 99b4200f8b5fff177ecc7fee16cff103f2b4ae15
Author: Christian Persch <chpe src gnome org>
Date:   Mon Nov 18 23:26:55 2019 +0100

    draw: Make new diagonal characters align better with box drawings
    
    Make the new diagonal characters align with the horizontal and
    vertical box drawing characters, by making them have a square end.

 src/vtedraw.cc | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/vtedraw.cc b/src/vtedraw.cc
index d657f286..6ec47570 100644
--- a/src/vtedraw.cc
+++ b/src/vtedraw.cc
@@ -2139,31 +2139,42 @@ _vte_draw_terminal_draw_graphic(struct _vte_draw *draw,
                 const int v = c - 0x1fba0;
                 const int map[15] = { 0b0001, 0b0010, 0b0100, 0b1000, 0b0101, 0b1010, 0b1100, 0b0011,
                                       0b1001, 0b0110, 0b1110, 0b1101, 0b1011, 0b0111, 0b1111 };
-                cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+                cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
+                cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
                 cairo_set_line_width(cr, light_line_width);
-                adjust = light_line_width / 2.;
+                adjust = (light_line_width & 1) ? .5 : 0.;
+                double const dx = light_line_width / 2.;
+                double const dy = light_line_width / 2.;
                 if (map[v] & 1) {
                         /* upper left */
-                        cairo_move_to(cr, x + adjust, y + upper_half);
-                        cairo_line_to(cr, x + left_half, y + adjust);
+                        cairo_move_to(cr, x, ycenter + adjust);
+                        cairo_line_to(cr, x + dx, ycenter + adjust);
+                        cairo_line_to(cr, xcenter + adjust, y + dy);
+                        cairo_line_to(cr, xcenter + adjust, y);
                         cairo_stroke(cr);
                 }
                 if (map[v] & 2) {
                         /* upper right */
-                        cairo_move_to(cr, xright - adjust, y + upper_half);
-                        cairo_line_to(cr, x + left_half, y + adjust);
+                        cairo_move_to(cr, xright, ycenter + adjust);
+                        cairo_line_to(cr, xright - dx, ycenter + adjust);
+                        cairo_line_to(cr, xcenter + adjust, y + dy);
+                        cairo_line_to(cr, xcenter + adjust, y);
                         cairo_stroke(cr);
                 }
                 if (map[v] & 4) {
                         /* lower left */
-                        cairo_move_to(cr, x + adjust, y + upper_half);
-                        cairo_line_to(cr, x + left_half, ybottom - adjust);
+                        cairo_move_to(cr, x, ycenter + adjust);
+                        cairo_line_to(cr, x + dx, ycenter + adjust);
+                        cairo_line_to(cr, xcenter + adjust, ybottom - dy);
+                        cairo_line_to(cr, xcenter + adjust, ybottom);
                         cairo_stroke(cr);
                 }
                 if (map[v] & 8) {
                         /* lower right */
-                        cairo_move_to(cr, xright - adjust, y + upper_half);
-                        cairo_line_to(cr, x + left_half, ybottom - adjust);
+                        cairo_move_to(cr, xright, ycenter + adjust);
+                        cairo_line_to(cr, xright - dx, ycenter + adjust);
+                        cairo_line_to(cr, xcenter + adjust, ybottom - dy);
+                        cairo_line_to(cr, xcenter + adjust, ybottom);
                         cairo_stroke(cr);
                 }
                 break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]