-
Notifications
You must be signed in to change notification settings - Fork 72
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
Implement @layer
based on local variables?
#323
Comments
We are not using global variables. Those state vars needed for thread safety, like In general, for breaking changes I am not the one to decide. There is no need to remove I would prefer to talk about real issues. Solving issues on base of general statements like "It is inelegant and errorprone" are typically not solving anything but still consume time. A general redesign of the Luxor package is definitely not on my scope. If you could provide a suggestion to get rid of the use of |
Thanks for your pointing out the concept confusion. Yes,
This issue and that reply are something conceived in my mind, which is on a very early stage. I share it here for discussion. |
Except that in this case the global state is essentially needed so that Luxor.jl can be used from a parallel running consumer code. Luxor.jl itself doesn't use parallelism of any kind.
Only works if we/Luxor.jl itself uses internally threads. This is not the case. The problem is, that Luxor.jl is called from parallel running threads and has no control about this implementation from where it is called.
Yes, but moves the problem to a general redesign and frankly, I doubt that a clean thread safe wrapper around Cairo can be written. It would be interesting to experiment with Cairo's
Of course, I have seen this already, and @cormullion response is clear. Despite that, perhaps I will try it out and see if this really resolves the problem with
If there would be real issues, but there aren't. We are still on the abstract general concerns level. Luxor.jl is doing well since years and I don't believe it will run into many trouble in the coming years. Again, I am against solutions without real problems. There is not a thing like "perfect" or "subversive" solution, there are only solutions of real problems. We had yours, we solved it. This is a solution. Your refactored code isn't a solution, it's an alternative implementation, which is something worthwhile on it's own, but I will not have time for any project like this, which is the reason I talk so much about this ;-) |
Thanks for your patience and your time.
I already tried this.
Here is the result:
I first refactored the The code is just a demonstration, and I can see some flaws in the result pictures. But I think it's enough to demonstrate the feasibility of my proposal. |
I think most would agree that a breaking change is worth imposing if there are substantial gains to be had. Which isn't really the case here. Now, if someone rewrote the text/font functions to improve font selection and text handling, and upgraded LaTeX/Typst functionality, that would certainly be worth the pain of going to a breaking release, judging from the issues raised. As I commented here:
Have you considered forking Luxor and modernizing it with your preferred approaches to drawing creation and use of contexts? Luxor.jl is 10 years old next month. Maybe this is a good time for a redesign. |
Luxor is 10 years old, Cairo is 22 years old, and Pango is 25. They carry some luggage and inelegant, work-hardened solutions. A lot of the good Luxor stuff is missing in Images.jl-land, bar typesetting. I don't think typesetting should ideally be integrated too tightly into graphics production, given the immense complexities of typesetting. |
Just to clarify, making Luxor |
Thanks for participating @guo-yong-zhi ! |
Currently, the
@layer
is a shortcut forgsave()
...grestore()
, where thegsave
/grestore
use the global stack_SAVED_COLORS_STACK
to track the current state. It is inelegant and errorprone. Additionally, it makes multithreaded programming difficult. Says #238 @oheil :Could we use local variables instead of global ones? Here is a simple and clear implementation, which doesn't need
_SAVED_COLORS_STACK
and_saved_colors
anymore:Unfortunately, it would be a breaking change for the user of
gsave
andgrestore
(but not for the user of@layer
). If you think this is a good idea, I can polish it and make a PR at the right time.The text was updated successfully, but these errors were encountered: