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
Opacity - semi transparent objects #487
Conversation
... I wanted to create a draft pull request, but I misclicked. Now I can't see an option to change this to a draft PR.. Any ideas? :( |
@Hopding I've updated this PR, so now it contains opacity (and borderOpacity) for all the draw options (text, image, page, rectangle, line, square, ellipse, circle, svgpath) |
@soadzoor Thanks for working on this! I'll take a look. No worries about the draft PR. I don't think the status can be changed once it's opened, but that's no big deal. |
@soadzoor Can you please update a few of the integration tests to use this feature? |
@Hopding Sure, if you tell me how to do that! :) |
@soadzoor Have you been able to run the integration tests? https://github.com/Hopding/pdf-lib/blob/master/CONTRIBUTING.md#running-the-integration-tests |
@Hopding I haven't checked that one yet! It's past midnight here, so I'll do it tomorrow if that's okay :) |
Sounds good! No rush |
@Hopding I've updated test 2, 4, and 12, so now they contain some kind of opacity. I manually copy-pasted the same modifications from html to node/ts, deno/ts, and rn/js, and I'm not sure if that's the proper way of doing it. I didn't feel very professional while I was doing it, but for tests, it might be okay, I don't know. Please let me know what you think! |
@soadzoor The tests look good! Thanks! And yes, there's a lot of copy/pasting between the tests for Node, Deno, React Native, and the Browser. It does feel a bit clunky, but it is by far the simplest approach and isn't a big deal since they're just tests. In a previous version of pdf-lib I tried to avoid the copy/pasting and reuse the tests. It turned into a complicated mess because each environment needs things to be a little bit different. |
@Hopding I see your point, it's completely fine for tests, I think. :) Let me know if you'd need any modifications to this! |
I'll probably merge it this evening. But I might make a few tweaks and also need to run through all the tests before cutting a release. So I'd expect to cut a release with this feature sometime this weekend. |
@Hopding Sounds good! Thank you! |
* Added opacity and borderOpacity to drawSvgPath options * Added opacity and borderOpacity to PDFPageDrawSVGOptions * Added opacity and borderOpacity to PDFPage options * Added ability to set opacity and borderOpacity for svgpath * Fixes * Some cleanup * Wrapped functionality to private methods + added opacity feature for drawImage * Added opacity to rectangle, square, ellipse, circle, text, line * Added opacity for drawpage * Updated a few integration tests with the new opacity features Co-authored-by: Peter Varga <peter.varga@xyicon.com>
Hey @Hopding ,
So I thought I'd submit a PR for #210 , as you suggested yesterday.
Some notes:
opacity
andborderOpacity
is 1 (or left untouched, as the default value is 1 for both of them)? I'm not sure about best practices when it comes to PDF.svgPath
s so far, I'd still need to add these things todrawText
(as in the original issue), and a lot of other stuff (drawLine
,drawCircle
,drawSquare
,drawImage
, etc). In that case, I should try to avoid most of the code duplication related to this feature with private methods for example. Please let me know if you have any preferences, thoughts, warnings about this!Have a great week!