-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add a new bezier() method to draw curves #496
Comments
Would like to work on it, if no one else is working. |
You are very welcome, go on! |
hello, if its available can I work on it? |
Ping @JDeepD: have you started working on this, or are you planning to do so soon? |
I am planning to work on this soon. Since I have not contributed to fpdf2 before, I am looking into some code and documentation. But @Aashish-Upadhyay-101 can work on it as I would probably need some more time to understand the codebase and begin working on it. |
nice, before starting I have a few questions |
@JDeepD : thank you for you answer. If @Aashish-Upadhyay-101 creates a PR first, you input will be welcome as a reviewer on it!
@Aashish-Upadhyay-101 yes, no method exist at this moment. |
@Lucas-C, I have to make function that renders bezier curve. To actually render on the pdf which function or library this project is using? I think drawing.py has some functions inside it, right? |
As mentioned in the issue description, the drawing.py module has several classes that implement the geometric calculations: It might be easiest to just create a wrapper around one (or several) of those. Actually, I think that several of our bespoke geometry methods could be simplified by calling the drawing.py module instead of doing the work themselves. |
I'm new to open source and really struggling to do this....! can you help? |
Hi @Aashish-Upadhyay-101, and welcome.
Could you try to explain precisely on what points you are struggling? Usually, when contributing to an open source project, the first steps are :
|
@Lucas-C I tried to Setup locally, but got error when I run test 1. first of all the test failed with errors2. After that i'm also confused where to start like from where should i began.3. Afer that, I'm also confused which file to modify and how to add bezier() functionAs I'm purely a beginner and really want to success in this area, I will do whatever it takes to learn so please guide me through Or maybe you can assign me a little bit biginner friendly simple issue to get started with? |
Did you install the requirements first? Install dependencies using
The
The codebase should generally remain uniform. See how other functions are implemented and try to implement the |
@JDeepD I got this error message when I tried to install the requirements.txt |
@JDeepD now everything is setup, now I will try to implement bezier |
@JDeepD can you help me with bezier() function.
but don't know afterwards how to implement it, can you guide me |
You need to read some internal code for it. See the links mentioned in the top comment by Lucas. |
@JDeepD I think if you have already understanded the code base, you can work on this issue. |
@Aashish-Upadhyay-101 If you have left working on this issue, then please let us know. |
@JDeepD I left working on this issue, I think I need some more time to understand whats going on. |
I would like to work on this issue? Just let me know..... |
Great! Feel free to drop a comment if you start working on this. |
Also, thank you for your help & answers here @JDeepD! @all-contributors please add @JDeepD for question |
I've begun work on this issue. I've opened draft PR (#596) so that I can share my progress. From what I understand, here is my approach: The Bezier curve methods created in #196 can't be used here as they are for the case of 2 control points only. However, they can be seen as a special case of the general Bezier curve with arbitrarily many control points. My revised plan is to write a more general Bezier curve method of which the original methods will be special cases. I notice that in the description of the issue, the method should also take a style argument. Given that we are rendering a line (which may not necessarily be closed unless the last point is the same coordinates as the first point), does it make sense to have style options that we would normally have for closed shapes (such as fill and draw). |
As can be seen in the CodePen snippet on the following page, yes bezier curves with filling make sense: Your plan sounds great 😊 |
I see. I read through some of the implemented methods in the |
Yes, absolutely 😊 |
@jeettrivedi, you might want to check out the svg.py module and compare how it uses the bezier methods in drawing.py. You can probably keep it simpler than that because you don't need to deal with other path elements, but the parts handling curves (especially continuous curves) may still be useful to study. |
@jeettrivedi: are you still working on this issue? |
Hey, I am actively working on it right now. I will have questions likely next week. Thank you for checking in! |
Great! |
@Lucas-C I have a question. So far, I wrote a simple method to generate the path string for a bezier curve given the points and the method then passes that path string to the method While debugging this, I examined the path string (after unit transformations) that is passed to
I tried to look for an |
You can check the annex A of the 1.7 PDF spec for the meaning of PDF operators. |
Hi @jeettrivedi |
Without news from @jeettrivedi, and given that no PR is currently open regarding this, |
Hello, just wondering if this is still up for grabs? I am interested in working on this. |
Yes, you can work on implementing this feature, a PR would be welcome! 👍 |
I'm set up and have started working on this. I have some questions about how I should implement this.
These seem to be used by PaintedPath. Should FPDF2.bezier() create a PaintedPath object? with self.drawing_context(debug_stream=debug_stream) as ctxt:
path = PaintedPath(x=x, y=y)
path.style.paint_rule = paint_rule
yield path
ctxt.add_item(path) It looks like in order to add a shape to the document, other methods are getting a drawing context and then using the context's Thanks in advance. This will be my first significant (taking >10min) FOSS contribution, so the codebase is imposing, but the code makes sense and I will keep reading and playing with the code to figure out as much as possible on my own and ask questions when needed. |
That seems like a valid approach to me, yes!
Yes. You can take inspiration from the usages of
Sorry for the delay in answering you 😞 |
Thanks for your advice. I will get back on this this week! |
Good job @awmc000! |
I think we can close this issue? I'll be looking through the issues on this project, I'm interested in doing more. |
Yup, the PR didn't use the standard phrasing of "fixes ###", so it didn't get closed automatically. |
Documentation on Bézier curves:
There is some suggested usage example, once implemented, inspired by the existing polygon() method:
@torque already implemented bezier curves in PR #196 in order to support SVG:
https://github.com/PyFPDF/fpdf2/blob/2.5.6/fpdf/drawing.py#L2016
The goal here is to expose this feature as a new public
FPDF
method.Of course, new unit tests should be added, as well as a new documentation section in
docs/Shapes.md
By implementing this feature you, as a benevolent FLOSS developper, will provide access to the large community of fpdf2 users to a standard and useful PDF functionality.
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.
This issue can count as part of hacktoberfest
The text was updated successfully, but these errors were encountered: