-
Notifications
You must be signed in to change notification settings - Fork 14
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
Providing a Stable API #28
Comments
That's a tough one. On one hand, it would obviously good to offer this toolkit to others. On the other hand, it means much more work. Currently, we only have to meet Manim's needs; there will certainly be other needs once it is used in other projects. Are we sure we can handle the additional workload? |
I think there shouldn't be much of workload though. Even if there is, I think there should be other developers taking interest to develop this project. And, yes this is a cool project, which I, personally, love to work on. I haven't seen any python project, even if its a binding, provide text rendering as this project does and we have wheels which pretty much work on any platform, that makes me think, why other projects, say pillow, can't use it. Also, on the other hand I think the current implementation of Also, currently we seem to duplicate code in |
True.
IMHO, We could probably keep |
I had a look over PangoAttribute, which should be used ideally instead of the dicts which are currently in place, like t2g and t2c. I had previously worked on them in this branch but had stopped it because it required a lot of work to do. Essentially what I thought when I was doing that was, having a This API looks good to me, but still, I was wondering if there is a better way to do it, suggestions @PhilippImhof? |
I am not sure I understand the question. As the user will still have to define |
Yeah, markup is great. |
Pygments supports HTML output. I think I might be able to write a Pango formatter, it seems to be more or less straightforward to do so; but that's what I suppose after having skimmed the docs. |
I tried that, but it seems too difficult to convert them because pygments uses CSS which Pango doesn't support at all. The best is to convert them using PangoAttributes, and I will soon be working on it anyhow. |
I have just given it a quick try and it seems to work. There is some fine-tuning and intensive testing left to do, of course. |
from pygments import highlight
from pygments.lexers import JavascriptLexer
from pygments.formatters import PangoMarkupFormatter
code = """
function bla(n, m) {
console.log(n*m);
}
"""
print(highlight(code, JavascriptLexer(), PangoMarkupFormatter())) yields
and with this I can do from manim import *
from manimpango import *
class TestCode(Scene):
def construct(self):
text = MarkupText(
"""<tt><span fgcolor="#008000"><b>function</b></span> bla(n, m) {
console.log(n<span fgcolor="#666666">*</span>m);
}
</tt>""")
self.play(Write(text))
self.wait() to get: TestCode.mp4 |
This looks really cool. 👍 |
Now, I think the first thing we should do is provide an API to access the image other than SVG. So, the first step I think would be to clean some repetitive code, and organize it as such a |
@PhilippImhof Can you list down what all we should refactor? ManimCommunity/manim#1102 (comment) |
Also, we should add an API to return the buffer so that outside of Manim, as we can't expect them to parse those SVG files. We should kinda use buffer API from CPython, where we can get the image data from Cairo when we are using Image Surface using |
I am working on this next :) |
IMHO this is well thought and a good way to go! |
Now that I'm planning for ManimCommunity/manim#2355 I think this is the time to fix this also. |
Currently, this project is just for the use of Manim, and mostly it can't be used outside of manim, with the functions it provides.
Having a stable API so that it can be used outside of Manim would be super cool, for example, I recently read python-pillow/Pillow#2255 and found that Pillow can't render text correctly, especially for languages with more ligatures, at least it requires raqm and isn't available by default in the wheels, and by if we had a stable API Pillow could use this to render text.
I would like to hear some ideas on how this can be done and how the API should look like.
Thoughts @PhilippImhof?
The text was updated successfully, but these errors were encountered: