Opaque white stroke is drawn on shapes with `stroke="none"`
Description of bug / unexpected behavior
Currently, if a shape with stroke="none" has a stroke width that is not zero, an opaque white outline of that width is drawn.
To show it, I attached an image below, it is the black knight from the Lichess "cburnett" chess pieces, as used by manim-chess. The knight's white mane stripe is a stroke="none" path inside a <g stroke="#000" stroke-width="1.5">.
- The SVG as rendered by ImageMagick, as designed. The stripe sits inside the knight's black outline.
- Manim 0.21.0. The stripe gets a white outline, 1.5 wide, so it covers the black edge and pokes out past the bottom of the knight.
- The same as 2, with only the stripe's stroke width set to 0. It now matches 1.
- The same as 3, with the black outline's width also scaled to the piece. This is a separate, known behaviour (stroke widths don't scale with the SVG, see #4836) and isn't part of this report.
Expected behavior
A shape with stroke="none" should have no outline, as in 1 and 3.
How to reproduce the issue
Code for reproducing the problemstroke_none.svg:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<g stroke="#000" stroke-width="4">
<rect x="10" y="10" width="80" height="80" fill="#000"/>
<rect x="30" y="30" width="40" height="40" fill="#00f" stroke="none"/>
</g>
</svg>from manim import *
class StrokeNone(Scene):
def construct(self):
self.camera.background_color = GREY
svg = SVGMobject("stroke_none.svg", height=6)
self.add(svg)
for i, sub in enumerate(svg.submobjects):
print(i, "stroke", sub.get_stroke_color().to_hex(),
"width", sub.get_stroke_width(), "opacity", sub.get_stroke_opacity())manim -ql -s -v DEBUG repro.py StrokeNone
Additional media files
Images/GIFsLogs
Terminal outputManim Community v0.21.0
0 stroke #000000 width 4.0 opacity 1.0
1 stroke #FFFFFF width 4.0 opacity 1.0
[09/27/26 01:50:47] INFO scene_file_writer.py:1103
File ready at '/tmp/claude-1000/manim_issue/media/images/repro/StrokeNone_ManimCE_v0.21.0.png'
INFO Rendered StrokeNone scene.py:290
Played 0 animations System specifications
System Details- OS: Fedora Linux 44 (Workstation Edition)
- RAM: 16.0 GiB
- Python version: 3.14.7
- Installed modules (provide output from
pip list):
Package Version
----------------- -------
audioop-lts 0.2.2
av 18.1.0
beautifulsoup4 4.15.0
chess 1.11.2
click 8.5.0
cloup 4.0.0
decorator 5.3.1
glcontext 3.0.0
isosurfaces 0.1.2
manim 0.21.0
manim-chess 0.0.38
manimpango 0.6.1
mapbox-earcut 2.1.0
markdown-it-py 4.2.0
mdurl 0.1.2
moderngl 5.12.0
moderngl-window 3.1.1
networkx 3.7
numpy 2.5.3
pillow 12.3.0
pycairo 1.29.1
pydub 0.25.1
pyglet 2.1.16
pyglm 2.8.3
pygments 2.21.0
rich 15.0.0
scipy 1.18.1
screeninfo 0.8.1
skia-pathops 0.9.2
soupsieve 2.9.2
srt 3.5.3
svgelements 1.9.6
tqdm 4.70.1
typing-extensions 4.16.0
watchdog 6.0.0- Not installed (not needed to reproduce)
Additional comments
The cause is in SVGMobject.apply_style_to_mobject:
mob.set_style(
stroke_width=shape.stroke_width,
stroke_color=shape.stroke.hexrgb,
stroke_opacity=shape.stroke.opacity,
...
)svgelements parses stroke="none" as a Color whose hexrgb and opacity are both None, while stroke_width is still the inherited value. set_style ignores None arguments, so the mobject keeps the default stroke colour (white, fully opaque) at that width.
fill="none" doesn't have this problem because the default fill opacity is 0.
A possible fix, which produces the image below:
mob.set_style(...) # unchanged
if shape.stroke is None or shape.stroke.value is None:
mob.set_stroke(width=0)Source: ManimCommunity/manim