manim icon indicating copy to clipboard operation
manim copied to clipboard

BulletedList `color` does not set the bullet color

Open kjczarne opened this issue 1 year ago • 4 comments

Description of bug / unexpected behavior

I tried styling the BulletedList Mobject as fully black and the bullet points still appear white.

Expected behavior

I would expect also the bullet points to turn black.

How to reproduce the issue

Code for reproducing the problem
        t3 = BulletedList(
            "Low Signal-to-Noise Ratio (SNR)",
            "Low contrast",
            "Low resolution",
            color=BLACK,
            fill_color=BLACK,
            stroke_color=BLACK
        )

Additional media files

Images/GIFs

image

Logs

Terminal output https://pastebin.com/KtKbizHt

System specifications

System Details
  • OS: macOS 14.0 (Sonoma)
  • RAM: 16GB
  • Python version (python/py/python3 --version): Python 3.11
  • Installed modules (provide output from pip list):
Package                Version
---------------------- -----------
annotated-types        0.7.0
asttokens              2.4.1
av                     12.2.0
certifi                2024.7.4
charset-normalizer     3.3.2
click                  8.1.7
click-default-group    1.2.4
cloup                  3.0.5
Cython                 3.0.10
decorator              5.1.1
docutils               0.21.2
executing              2.0.1
glcontext              2.5.0
idna                   3.7
ipython                8.26.0
isosurfaces            0.1.2
jedi                   0.19.1
Jinja2                 3.1.4
lxml                   5.2.2
manim                  0.18.1
manim-slides           5.1.7
ManimPango             0.5.0
mapbox-earcut          1.0.1
markdown-it-py         3.0.0
MarkupSafe             2.1.5
matplotlib-inline      0.1.7
mdurl                  0.1.2
moderngl               5.10.0
moderngl-window        2.4.6
multipledispatch       1.0.0
networkx               3.3
numpy                  1.26.4
packaging              24.1
parso                  0.8.4
pexpect                4.9.0
pillow                 10.4.0
pip                    24.0
prompt_toolkit         3.0.47
ptyprocess             0.7.0
pure-eval              0.2.2
pycairo                1.26.1
pydantic               2.8.2
pydantic_core          2.20.1
pydantic-extra-types   2.9.0
pydub                  0.25.1
pyglet                 2.0.15
Pygments               2.18.0
pyobjc-core            10.3.1
pyobjc-framework-Cocoa 10.3.1
pyrr                   0.10.3
PySide6                6.5.2
PySide6-Addons         6.5.2
PySide6-Essentials     6.5.2
python-pptx            0.6.23
QtPy                   2.4.1
requests               2.32.3
rich                   13.7.1
rtoml                  0.11.0
scipy                  1.14.0
screeninfo             0.8.1
setuptools             69.5.1
shiboken6              6.5.2
six                    1.16.0
skia-pathops           0.8.0.post1
srt                    3.5.3
stack-data             0.6.3
svgelements            1.9.6
tqdm                   4.66.4
traitlets              5.14.3
typing_extensions      4.12.2
urllib3                2.2.2
watchdog               4.0.1
wcwidth                0.2.13
wheel                  0.43.0
XlsxWriter             3.2.0
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020): mactex-basictex-20210325
  • Installed LaTeX packages:

Additional comments

kjczarne avatar Jul 06 '24 15:07 kjczarne

For now I have worked around the issue as follows:

        tex_template = TexTemplate()
        tex_template.add_to_preamble(r"\usepackage{enumitem,xcolor}")
        t3 = Tex(r"\begin{itemize}[label=\textcolor{black}{\textbullet}] \item Low Signal-to-Noise Ratio (SNR)"
                 r"\item Low contrast \item Low resolution"
                 r"\end{itemize}",
                 color=BLACK,
                 tex_template=tex_template)

kjczarne avatar Jul 06 '24 15:07 kjczarne

alternatively you can just set the color for the object afterwards:

class bullets(Scene):
    def construct(self):
        t3 = BulletedList(
            "Low Signal-to-Noise Ratio (SNR)",
            "Low contrast",
            "Low resolution",
            color=BLUE,
            fill_color=BLUE,
            stroke_color=BLUE
        ).set_color(RED)
        self.add(t3)

uwezi avatar Jul 06 '24 19:07 uwezi

The reason for this behavior is that Manim does not typeset the bulleted list as an itemize in LaTeX, but rather makes individual rows out of the items and places separately generated dots in front of each line - where the dot itself is typeset without passing any **kwargs on to the MathTex object:

        line_separated_items = [s + "\\\\" for s in items]
        super().__init__(
            *line_separated_items, tex_environment=tex_environment, **kwargs
        )
        for part in self:
            dot = MathTex("\\cdot").scale(self.dot_scale_factor)
            dot.next_to(part[0], LEFT, SMALL_BUFF)
            part.add_to_back(dot)
        self.arrange(DOWN, aligned_edge=LEFT, buff=self.buff)

uwezi avatar Jul 06 '24 19:07 uwezi

Gotcha, the workaround you suggested is so much cleaner, thank you!!

kjczarne avatar Jul 08 '24 17:07 kjczarne