GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — I changed the offset code for draw_text for RendererAgg fixing issue #13044 by safdarzareef · Pull Request #20057 · matplotlib/matplotlib Conversation
|
|
I don't understand why these are leading to broken tests? I think its obviously OK to break the tests for non-zero rotation, but breaking them for zero rotation doesn't seem right. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think it is because when taking the components of the offset according to the non-rotation angle which is 0 degrees, we are setting y0 to be sin(0)*old y0 = 0. But I don’t think there should be a y offset due to y0, there is a y offset regardless due to yd. So that is why it might break tests with non-rotated text. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think you'll need to give us a little more detail. We can't break everyone who depends on our code without a really good reason. I think this would be easier with a diagram and some numbers. I appreciate that none of this is helped by the fact that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am thinking that you are on the right track here. I haven't looked at how much the images would change, but I am inclined to say that it might be worth fixing if the results have been seriously wrong all this time. Maybe we can do some sort of special back-compat mode for unrotated text in order to limit the extent of the impact?
Can you comment on the difference between this fix and #19114?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| xo, yo = font.get_bitmap_offset() | ||
| xo /= 64.0 | ||
| yo /= 64.0 | ||
| h = sqrt(xo**2 + yo**2) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Personally, I prefer using hypot() instead, but I don't know if it really matters in the context of bounding box calculations.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it will matter, but we could still change it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| xd = d * sin(radians(angle)) | ||
| yd = d * cos(radians(angle)) | ||
| xo = h * cos(radians(angle)) | ||
| yo = h * sin(radians(angle)) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If we are going to calculate radians(angle) four times, might as well just do it once and store it in a variable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also, these four lines here would greatly benefit from a comment explaining the trigonometry. Usually, cos() goes with x, and y goes with sin(). Seeing it two different ways here for the offset and the descent is confusing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I can explain the offset trigonometry, but I just left the code for the descent as it was before. The descent seems wrong - but I am unaware of the reason why it was like that before so I left it there. Basic trigonometry suggests that x components should be calculated by multiplying a number by the cosine of its angle and y components should be calculated by multiplying a number by the sine of its angle - so that is why I used that for the offset but I do think the descent should be in the same form too.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| yo = h * sin(radians(angle)) | ||
| x = round(x + xo + xd) | ||
| y = round(y + yo + yd) | ||
| y = round(y + yo - yd) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
much like the trig above, I think this will also need a quick proof in the comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think I have a proof for this at the moment except that in the draw_mathtext function the y is calculated in a similar manner and by subtracting the y offset we get a satisfactory result.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This fix and #19114 is different because #19114 tried to fix the bounding box and we are trying to change the offset for the text. But the problem is not with the bounding box but rather the text itself - here's an example to prove it: Here's an example of text without the bounding box: And you can see there is a problem with the offset of the text even when a bounding box isn't drawn. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
So I never could find the draw_text_image function in the source code actually. I was trying to look for it to check whether it solves rotation correctly or not. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing and reopening to get fresh test results. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
👋🏻 Hello, @safdarzareef ! Are you interested in picking this back up? Can we help you with this? Please let us know 😄 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.