[meld] linkmap: Simplify our bezier drawing



commit 658170e4e2703adba96f6dfbf52985a59efe3ee7
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Dec 15 08:37:14 2018 +1000

    linkmap: Simplify our bezier drawing

 meld/linkmap.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/meld/linkmap.py b/meld/linkmap.py
index 5653f4bd..af555c16 100644
--- a/meld/linkmap.py
+++ b/meld/linkmap.py
@@ -75,9 +75,8 @@ class LinkMap(Gtk.DrawingArea):
             self.views[1].get_line_num_for_y(pix_start[1] + height),
         ]
 
-        wtotal = allocation.width
         # For bezier control points
-        x_steps = [-0.5, wtotal / 2, wtotal / 2, wtotal + 0.5]
+        x_steps = [-0.5, allocation.width / 2, allocation.width + 0.5]
         q_rad = math.pi / 2
 
         left, right = self.view_indices
@@ -98,24 +97,24 @@ class LinkMap(Gtk.DrawingArea):
             if (t0 < 0 and t1 < 0) or (t0 > height and t1 > height):
                 if f0 == f1:
                     continue
-                context.arc(x_steps[0], f0 - 0.5 + RADIUS, RADIUS, -q_rad, 0)
+                context.arc(x_steps[0], f0 - 0.5 + RADIUS, RADIUS, q_rad * 3, 0)
                 context.arc(x_steps[0], f1 - 0.5 - RADIUS, RADIUS, 0, q_rad)
                 context.close_path()
             elif (f0 < 0 and f1 < 0) or (f0 > height and f1 > height):
                 if t0 == t1:
                     continue
-                context.arc_negative(x_steps[3], t0 - 0.5 + RADIUS, RADIUS,
-                                     -q_rad, q_rad * 2)
-                context.arc_negative(x_steps[3], t1 - 0.5 - RADIUS, RADIUS,
+                context.arc_negative(x_steps[2], t0 - 0.5 + RADIUS, RADIUS,
+                                     q_rad * 3, q_rad * 2)
+                context.arc_negative(x_steps[2], t1 - 0.5 - RADIUS, RADIUS,
                                      q_rad * 2, q_rad)
                 context.close_path()
             else:
                 context.move_to(x_steps[0], f0 - 0.5)
                 context.curve_to(x_steps[1], f0 - 0.5,
-                                 x_steps[2], t0 - 0.5,
-                                 x_steps[3], t0 - 0.5)
-                context.line_to(x_steps[3], t1 - 0.5)
-                context.curve_to(x_steps[2], t1 - 0.5,
+                                 x_steps[1], t0 - 0.5,
+                                 x_steps[2], t0 - 0.5)
+                context.line_to(x_steps[2], t1 - 0.5)
+                context.curve_to(x_steps[1], t1 - 0.5,
                                  x_steps[1], f1 - 0.5,
                                  x_steps[0], f1 - 0.5)
                 context.close_path()


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