ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
24.96k stars 1.75k forks source link

Setting a stroke width for a `Tex` object gives "M" devil horns #3328

Open sudgy opened 1 year ago

sudgy commented 1 year ago

Consider the following scene:

class Test(Scene):
    def construct(self):
        test = Tex("M")
        test.set_stroke(color = RED, width = 8)
        self.add(test)

This is the result with the cairo renderer:

Test_ManimCE_v0 17 3

I would expect those devil horns not to be there. Interestingly, while the problem seems to be there in the opengl renderer as well, it's not nearly as pronounced.

uwezi commented 1 year ago

If you scale up your code you can see exactly where those "horns" come from and that they are unavoidable.

LaTeX renders the output in order to only fill the outline of the font with no stroke - so expecting anything useful from showing the stroke seems strange to me, especially with a stroke width which is wider than the lines of the letters.

class Test(Scene):
    def construct(self):
        test = Tex("M").scale_to_fit_height(6)
        test.set_stroke(color = RED, width = 8)
        self.add(test) 

bild

uwezi commented 1 year ago

actually I am not able to reproduce your un-scaled image on my system with Manim 0.17.3. Instead I get this output: bild

and here is some animated code showing what is happening:

class Test2(Scene):
    def construct(self):
        stroke = ValueTracker(0)
        test = always_redraw(lambda:
            Tex("M").scale_to_fit_height(2).set_stroke(color = RED, width = stroke.get_value())
        )
        self.add(test)   
        self.play(stroke.animate.set_value(160), rate_func=rate_functions.linear, run_time=3)       

https://github.com/ManimCommunity/manim/assets/8582807/b37b95aa-e6f1-4717-87cf-eb8febf1bdb0

jsonvillanueva commented 1 year ago

3321 Might fix this?

uwezi commented 1 year ago

Having a thick stroke around a text letter in my view does not really make sense... And yes, text rendering in opengl is currently kind-of broken and MrDiver is working on it.

uwezi commented 1 year ago

This is the output of my animated script using --renderer=opengl 0n 0.17.3 - no horns there either...

https://github.com/ManimCommunity/manim/assets/8582807/ee7e9732-0ff9-47bd-8695-3b484b4ec079

sudgy commented 1 year ago

Having a thick stroke around a text letter in my view does not really make sense...

I use it in my videos to have an outline around letters. I draw the text twice, once with a thick, black stroke, and then another time normally on top of it. It looks perfect in most situations, but this is the one situation where it looks weird.

I'm a bit surprised that some people aren't having this issue at all. For the people not having this issue, are you using the cairo renderer? If so, what is the information I should provide to help figure out where the difference lies? I use ArchLinux, and my manim version is 0.17.3.

MrDiver commented 1 year ago

There is a thing called background_stroke

uwezi commented 1 year ago

what is the information I should provide to help figure out where the difference lies?

...start by showing the version of all your libraries pip list and the update status of your LaTeX libraries. I have no horns on two Windows 10 system (AMD and Intel) as well as a WSL-Ubuntu using cairo and opengl.

sudgy commented 1 year ago

There is a thing called background_stroke

Aw man why didn't I hear about this sooner? That would have saved me some headaches. However, using background_stroke still creates horns.

Here's the output of pip list:

Package             Version                            Editable project location
------------------- ---------------------------------- ---------------------------------------
asttokens           2.2.1
attrs               22.2.0
autocommand         2.2.2
backcall            0.2.0
btrfsutil           6.3.2
cffi                1.15.1
chardet             5.1.0
click               8.1.3
click-default-group 1.2.2
cloup               0.13.1
colorama            0.4.6
colour              0.1.5
contourpy           1.1.0
cryptography        41.0.2
cycler              0.11.0
dbus-python         1.3.2
decorator           5.1.1
distlib             0.3.6
distro              1.8.0
executing           1.2.0
fastjsonschema      2.18.0
filelock            3.12.0
fonttools           4.40.0
glcontext           2.3.7
idna                3.4
inflect             7.0.0
ipython             8.13.2
isosurfaces         0.1.0
jaraco.context      4.3.0
jaraco.functools    3.8.0
jaraco.text         3.11.1
jedi                0.18.2
kingdon             0.1.0                              /home/sudgy/programs/python/kingdon
kiwisolver          1.4.4
lensfun             0.3.4
lensfun             0.3.4
libtorrent          2.0.9
llvmlite            0.40.0
louis               3.26.0
manim               0.17.3
manimgl             1.6.1                              /home/sudgy/programs/python/manim/manim
ManimPango          0.4.3
mapbox-earcut       1.0.1
markdown-it-py      2.2.0
matplotlib          3.7.1
matplotlib-inline   0.1.6
mdurl               0.1.2
moderngl            5.8.2
moderngl-window     2.4.3
more-itertools      9.1.0
mpmath              1.3.0
multipledispatch    0.6.0
netsnmp-python      1.0a1
networkx            2.8.8
noise               1.2.2
numba               0.57.1
numpy               1.25.1
ordered-set         4.1.0
packaging           23.1
parso               0.8.3
pexpect             4.8.0
pickleshare         0.7.5
Pillow              9.5.0
pip                 23.2.1
platformdirs        3.9.1
ply                 3.11
pocketsphinx        5.0.1
prompt-toolkit      3.0.38
ptyprocess          0.7.0
pure-eval           0.2.2
pycairo             1.23.0
pycparser           2.21
pydantic            1.10.9
pydub               0.25.1
pyenchant           3.2.2
pyglet              2.0.6
Pygments            2.15.1
PyGObject           3.44.1
PyOpenGL            3.1.7
pyparsing           3.0.9
pyperclip           1.8.2
pyrr                0.10.3
python-dateutil     2.8.2
PyYAML              6.0
Reflector           2023.6.28.0.36.1
requests            2.28.2
rich                13.4.2
scipy               1.10.1
screeninfo          0.8.1
setuptools          68.0.0
six                 1.16.0
skia-pathops        0.7.4
sounddevice         0.4.6
srt                 3.5.3
stack-data          0.6.2
svgelements         1.9.3
sympy               1.11.1
TBB                 0.2
tomli               2.0.1
tqdm                4.65.0
traitlets           5.9.0
trove-classifiers   2023.7.8
typing_extensions   4.7.1
uc-micro-py         1.0.2
urllib3             1.26.15
validate-pyproject  0.13.post1.dev0+gb752273.d20230520
validators          0.20.0
virtualenv          20.21.0
watchdog            2.3.1
wcwidth             0.2.6
wheel               0.40.0

How do I see the update status of my LaTeX libraries? I just have the ArchLinux texlive-most package installed, and that's version 2023.66594-19.