Rendering transparent png graphics edges will blend the background color
Description of bug / unexpected behavior
I drew a circle in the scene, added the -t parameter when rendering, and then added a background to the picture. I found that the edge of the graphic was mixed with the background color.
Expected behavior
Graphic edges should not blend with the background color
How to reproduce the issue
Code for reproducing the problem
from manim import *
config.pixel_width = 400
config.pixel_height = 400
config.frame_height = 400.0
config.frame_width = 400.0
# 传入一个像素宽度,返回Manim单位的线条粗细
def calculate_stroke_width(pixelWidth):
# 先计算Manim单位的像素宽度
unitPixel = config.pixel_width / config.frame_width
# 然后计算线条的Manim单位粗细,线条粗细单位是Manim单位的0.01
strokeWidth = pixelWidth / unitPixel * 100
return strokeWidth
# 创建一个主场景继承至场景类
class MainScene(Scene):
# 定义构造方法
def construct(self):
# 绘制圆形
circle = Circle(radius=100, stroke_width=calculate_stroke_width(4), color=WHITE)
self.add(circle)
Additional media files
Images/GIFs
System specifications
System Details
- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (
python/py/python3 --version): - Installed modules (provide output from
pip list):
OS: Windows10 Home 22H2
RAM: 48GB
Python version: 3.12.0
Additional comments
I noticed that some users have reported this issue before, and you have fixed it. #2273
Actually I believe that this "blending" or "bleeding" is an unavoidable part of anti-aliasing which makes it possible to have smooth outlines rather than pixelated edges. It will be less pronounced if you render your scene at a significantly higher resolution, because the affected edge will become much thinner in relation to the size of your objects. Well not in your current code since you seem to put some effort into making your stroke just 4 pixels wide independent on the pixel resolution of your scene - for whatever reason...
And as far as I know there is no option in Manim to disable anti-aliasing during rendering. But it would result in quite some pixelated objects instead.