Skip to content

Commit

Permalink
Put coordinates in proper order for drawing a rectangle.
Browse files Browse the repository at this point in the history
Fixes issue #862.
  • Loading branch information
tkeffer committed Apr 4, 2023
1 parent b5a7904 commit 48f6053
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions bin/weeplot/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,20 @@ def marker(self, xy_seq, marker_type, marker_size=10, **options):

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):
Expand Down

0 comments on commit 48f6053

Please sign in to comment.