[RFC] Off-by-one in linkmap cairo drawing ?



Hello,

could someone please comment on the validity of:

Attachment #133349: maybe this one is more complete
for bug #580311

The screenshots were taken with the first (obsoleted) patch

What are all those magical 0.5 values for anyways ?

-- 
Vincent Legoll
diff --git a/filediff.py b/filediff.py
index ac5063c..cf2979f 100644
--- a/filediff.py
+++ b/filediff.py
@@ -1116,8 +1116,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             return [self._pixel_to_line(idx, pix_start[idx]), self._pixel_to_line(idx, pix_start[idx]+htotal)]
         visible = [None] + bounds(which) + bounds(which+1)
 
+        adjust = 0
+
         # For bezier control points
-        x_steps = [-0.5, (1. / 3) * wtotal, (2. / 3) * wtotal, wtotal + 0.5]
+        x_steps = [-adjust, (1. / 3) * wtotal, (2. / 3) * wtotal, wtotal + adjust]
 
         def paint_pixbuf_at(pixbuf, x, y):
             context.translate(x, y)
@@ -1148,14 +1150,14 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             if t0 == t1:
                 t0 -= 1
 
-            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], f1 + 0.5,
-                             x_steps[0], f1 + 0.5)
+            context.move_to(x_steps[0], f0 - adjust)
+            context.curve_to(x_steps[1], f0 - adjust,
+                             x_steps[2], t0 - adjust,
+                             x_steps[3], t0 - adjust)
+            context.line_to(x_steps[3], t1 + adjust)
+            context.curve_to(x_steps[2], t1 + adjust,
+                             x_steps[1], f1 + adjust,
+                             x_steps[0], f1 + adjust)
             context.close_path()
 
             context.set_source_rgb(*self.fill_colors[c[0]])
@@ -1171,8 +1173,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 paint_pixbuf_at(pix0, 0, f0)
 
         # allow for scrollbar at end of textview
-        mid = int(0.5 * self.textview[0].allocation.height) + 0.5
-        context.set_source_rgba(0., 0., 0., 0.5)
+        mid = int(adjust * self.textview[0].allocation.height) + adjust
+        context.set_source_rgba(0., 0., 0., adjust)
         context.move_to(.35 * wtotal, mid)
         context.line_to(.65 * wtotal, mid)
         context.stroke()


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