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

Improve arc rendering #488

Closed
Lucas-C opened this issue Aug 16, 2022 · 1 comment · Fixed by #492
Closed

Improve arc rendering #488

Lucas-C opened this issue Aug 16, 2022 · 1 comment · Fixed by #492

Comments

@Lucas-C
Copy link
Member

Lucas-C commented Aug 16, 2022

There are currently two methods to render arcs with fpdf2:

However artefacts are visibles on line junctions when generating those shapes with start_from_center=True & end_at_center=True:

image

Whereas it should be like this (image from HexaPDF):

image

The solution here is probably to use the h path operator, intead of closing arcs with a line using l:
cf. fpdf/fpdf.py#L1651

You will find all required information about path operators in the 1.7 PDF spec.
Reading the existing code of the arc() & solid_arc() methods should also help you understand how shapes are drawn.

This is also an opportunity to add unit tests combining start_from_center=True & end_at_center=True in test/shapes/test_arc.py.
Please read the related documentation to get information on how to add tests: https://pyfpdf.github.io/fpdf2/Development.html#testing
I suggest the following approach: taking inpiration from the existing test functions,
write a basic usage scenario that calls assert_pdf_equal(pdf, "new_test_name.pdf", tmp_path, generate=True), and run pytest -vv test/shape/test_arc.py -k new_test_name
The generate=True argument is very useful to write new tests as it will generate the reference PDF file.
Once you'll be happy with the PDF file generated, you will just have to remove generate=True and you'll get a fine non-regression unit test.

Check #258 for more context

Pleae feel free to ask any question regarding this task or fpdf2 😊


By implementing this feature you, as a benevolent FLOSS developper, will improve a useful feature of this library, benefiting the large community of fpdf2 users.
As a contributor you will get review feedbacks from maintainers & other contributors, and learn about the lifecycle & structure of a Python library on the way.
You will also be added to the contributors list & map.

@Lucas-C
Copy link
Member Author

Lucas-C commented Sep 8, 2022

This has been released in v2.5.7

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

Successfully merging a pull request may close this issue.

1 participant