-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Use left/right top/bottom instead of width/height in Rectangle #9072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e8ce736
8208ddc
03fba6b
f40607e
8ee4da2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -687,10 +687,7 @@ def _update_patch_transform(self): | |
makes it very important to call the accessor method and | ||
not directly access the transformation member variable. | ||
""" | ||
x0 = self.convert_xunits(self._x0) | ||
y0 = self.convert_yunits(self._y0) | ||
x1 = self.convert_xunits(self._x1) | ||
y1 = self.convert_yunits(self._y1) | ||
x0, y0, x1, y1 = self._convert_units() | ||
bbox = transforms.Bbox.from_extents(x0, y0, x1, y1) | ||
rot_trans = transforms.Affine2D() | ||
rot_trans.rotate_deg_around(x0, y0, self.angle) | ||
|
@@ -703,6 +700,16 @@ def _update_x1(self): | |
def _update_y1(self): | ||
self._y1 = self._y0 + self._height | ||
|
||
def _convert_units(self): | ||
''' | ||
Convert bounds of the rectangle | ||
''' | ||
x0 = self.convert_xunits(self._x0) | ||
y0 = self.convert_yunits(self._y0) | ||
x1 = self.convert_xunits(self._x1) | ||
y1 = self.convert_yunits(self._y1) | ||
return x0, y0, x1, y1 | ||
|
||
def get_patch_transform(self): | ||
self._update_patch_transform() | ||
return self._rect_transform | ||
|
@@ -720,7 +727,7 @@ def get_xy(self): | |
return self._x0, self._y0 | ||
|
||
def get_width(self): | ||
"Return the width of the rectangle" | ||
"Return the width of the rectangle" | ||
return self._width | ||
|
||
def get_height(self): | ||
|
@@ -797,6 +804,7 @@ def set_bounds(self, *args): | |
self.stale = True | ||
|
||
def get_bbox(self): | ||
x0, y0, x1, y1 = self._convert_units() | ||
return transforms.Bbox.from_extents(self._x0, self._y0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this need to use the unit conversions, as in _update_patch_transform()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it probably does, but no-one every added it originally. I'll add it in another commit. |
||
self._x1, self._y1) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this call to
convert_units
? Am I missing a side effect or was this meant to be passed to thefrom_extents
call?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
_x0
,_y0
etc. coords are now all stored in the class with units attached, so this strips the units because I don't thinkfrom_extents
takes units.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the next line passes in
self._x0
etc notx0
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. PR incoming