summarylogtreecommitdiffstats
path: root/pillow-rect.patch
blob: 5d2aa04ec641794c8c24b59e6d61804a3cb751eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/bin/weeplot/utilities.py b/bin/weeplot/utilities.py
index 73e955bd..f1c9d33a 100644
--- a/bin/weeplot/utilities.py
+++ b/bin/weeplot/utilities.py
@@ -431,14 +431,20 @@ class ScaledDraw(object):
 
     def rectangle(self, box, **options):
         """Draw a scaled rectangle.
-        
-        box: A pair of 2-way tuples, containing coordinates of opposing corners
-        of the box.
-        
+
+        box: A pair of 2-way tuples for the lower-left, then upper-right corners of
+            the box [(llx, lly), (urx, ury)]
+
         options: passed on to draw.rectangle. Usually contains 'fill' (the color)
         """
-        box_scaled = [(coord[0] * self.xscale + self.xoffset + 0.5,
-                       coord[1] * self.yscale + self.yoffset + 0.5) for coord in box]
+        # Unpack the box
+        (llsx, llsy), (ursx, ursy) = box
+
+        ulix = int(llsx * self.xscale + self.xoffset + 0.5)
+        uliy = int(ursy * self.yscale + self.yoffset + 0.5)
+        lrix = int(ursx * self.xscale + self.xoffset + 0.5)
+        lriy = int(llsy * self.yscale + self.yoffset + 0.5)
+        box_scaled = ((ulix, uliy), (lrix, lriy))
         self.draw.rectangle(box_scaled, **options)
 
     def vector(self, x, vec, vector_rotate, **options):