ManimCommunity / ManimCommunity/manim

Rendering transparent png graphics edges will blend the background color

Open
#4,451 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## 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

```py
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

Image

## 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with the Scene, Circle, and -t transparent-rendering settings, then compare the PNG edge pixels before and after adding a background. Trace the rendering and alpha-compositing path involved in transparent output; done means graphic edges remain independent of the later background color.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.