Skip to content
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

Mirror function #783

Merged
merged 6 commits into from
May 8, 2023
Merged

Mirror function #783

merged 6 commits into from
May 8, 2023

Conversation

sebastiantia
Copy link

@sebastiantia sebastiantia commented May 6, 2023

Implements mirror function addressing issue #536

Checklist:

  • The GitHub pipeline is OK (green),
    meaning that both pylint (static code analyzer) and black (code formatter) are happy with the changes of this PR.

  • A unit test is covering the code added / modified by this PR

  • This PR is ready to be merged

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

@sebastiantia
Copy link
Author

@Lucas-C Mirror transformations with .image and .text are working as expected with this implementation, but things get wonky with cells and I haven't dug deep enough to understand whether it is behaving as expected... any advice would be great :)

fpdf/fpdf.py Outdated Show resolved Hide resolved
test/test_mirror.py Show resolved Hide resolved
fpdf/fpdf.py Outdated Show resolved Hide resolved
fpdf/fpdf.py Outdated Show resolved Hide resolved
fpdf/fpdf.py Show resolved Hide resolved
test/test_mirror.py Show resolved Hide resolved
@Lucas-C
Copy link
Member

Lucas-C commented May 6, 2023

@allcontributors please add @sebastiantia fro code

@allcontributors
Copy link

@Lucas-C

I've put up a pull request to add @sebastiantia! 🎉

test/test_mirror.py Outdated Show resolved Hide resolved
test/test_mirror.py Outdated Show resolved Hide resolved
test/test_mirror.py Outdated Show resolved Hide resolved
test/test_mirror.py Outdated Show resolved Hide resolved
@Lucas-C
Copy link
Member

Lucas-C commented May 6, 2023

things get wonky with cells and I haven't dug deep enough to understand whether it is behaving as expected... any advice would be great :)

The good news is that cells get perfectly well mirrored with your code! 😊

You just need to reset the FPDF.x position before calling FPDF.cell again within with pdf.mirror().
I added code suggestions to your unit test function that should solve the issue you had.

@sebastiantia
Copy link
Author

things get wonky with cells and I haven't dug deep enough to understand whether it is behaving as expected... any advice would be great :)

The good news is that cells get perfectly well mirrored with your code! 😊

You just need to reset the FPDF.x position before calling FPDF.cell again within with pdf.mirror(). I added code suggestions to your unit test function that should solve the issue you had.

Ahh that explains it. Thanks for the detailed code suggestions and review :)

@sebastiantia sebastiantia marked this pull request as ready for review May 7, 2023 02:58
@sebastiantia sebastiantia requested a review from Lucas-C May 7, 2023 02:58
Copy link
Member

@Lucas-C Lucas-C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made you some final comments.
Once you have answered / addressed them,
I'll be happy to merge this nicePR!

CHANGELOG.md Show resolved Hide resolved
docs/Transformations.md Show resolved Hide resolved
docs/Transformations.md Outdated Show resolved Hide resolved
docs/Transformations.md Show resolved Hide resolved
fpdf/fpdf.py Outdated Show resolved Hide resolved
test/test_mirror.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 7, 2023

Codecov Report

Patch coverage: 91.66% and project coverage change: +0.02 🎉

Comparison is base (37fc30f) 93.26% compared to head (b4a19e5) 93.29%.

❗ Current head b4a19e5 differs from pull request most recent head 49f88ef. Consider uploading reports for the commit 49f88ef to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #783      +/-   ##
==========================================
+ Coverage   93.26%   93.29%   +0.02%     
==========================================
  Files          27       27              
  Lines        7324     7348      +24     
  Branches     1328     1329       +1     
==========================================
+ Hits         6831     6855      +24     
- Misses        308      309       +1     
+ Partials      185      184       -1     
Impacted Files Coverage Δ
fpdf/fpdf.py 92.55% <86.66%> (+0.05%) ⬆️
fpdf/enums.py 98.00% <100.00%> (+0.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sebastiantia sebastiantia requested a review from Lucas-C May 7, 2023 20:02
@Lucas-C Lucas-C merged commit 47e910f into py-pdf:master May 8, 2023
10 checks passed
@Lucas-C
Copy link
Member

Lucas-C commented May 8, 2023

Merged!

Thank you very much @sebastiantia for your contribution! 👍

@Lucas-C
Copy link
Member

Lucas-C commented May 8, 2023

I forgot to recommend having a unit test for the case where angle is a number,
so after mergig this PR I added an extra commit with a few extra changes 😊
e208ab4

The new documention section will appear there in a few minutes:
https://pyfpdf.github.io/fpdf2/Transformations.html#mirror

I hope you enjoyed contributing to fpdf2 @sebastiantia!
You did a really good job.

@sebastiantia
Copy link
Author

I forgot to recommend having a unit test for the case where angle is a number, so after mergig this PR I added an extra commit with a few extra changes 😊 e208ab4

The new documention section will appear there in a few minutes: https://pyfpdf.github.io/fpdf2/Transformations.html#mirror

I hope you enjoyed contributing to fpdf2 @sebastiantia! You did a really good job.

Thanks again for all the help and opportunity :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants