-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
31537 text wrap figure edge #31546
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
base: main
Are you sure you want to change the base?
31537 text wrap figure edge #31546
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -757,6 +757,21 @@ def _get_dist_to_box(self, rotation, x0, y0, figure_box): | |
| Return the distance from the given points to the boundaries of a | ||
| rotated box, in pixels. | ||
| """ | ||
| # Normalize rotation; transform_angles can return values outside | ||
| # [0, 360) with tiny float noise. | ||
| rotation = rotation % 360 | ||
| # Short-circuit cardinal angles, otherwise cos(radians(90)) makes | ||
| # the trig formula below blow up when the text is on the edge. | ||
| tol = 1e-10 | ||
|
Member
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. Why choose a / exactly this tolerance?
Contributor
Author
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. Picked it a few orders of magnitude above the float noise I saw, but with the existing % 360 in get_rotation, the tolerance isn't actually needed. Removing it. |
||
| if rotation < tol or rotation > 360 - tol: | ||
| return figure_box.x1 - x0 | ||
| if abs(rotation - 90) < tol: | ||
| return figure_box.y1 - y0 | ||
| if abs(rotation - 180) < tol: | ||
| return x0 - figure_box.x0 | ||
| if abs(rotation - 270) < tol: | ||
| return y0 - figure_box.y0 | ||
|
|
||
| if rotation > 270: | ||
| quad = rotation - 270 | ||
| h1 = (y0 - figure_box.y0) / math.cos(math.radians(quad)) | ||
|
|
||
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.
AFAICS this is already done within
set_rotationorget_rotation.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.
Yep, missed that. Dropping the % 360 line.