This commit is contained in:
Colin Belhomme 2026-06-21 07:00:34 +08:00 committed by GitHub
commit bf0aa04cef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -206,7 +206,9 @@ class Code(VMobject, metaclass=ConvertToOpenGL):
from manim.mobject.text.text_mobject import Paragraph
height_line = "A" # The "height_line" is used to make sure the Paragraph bounding box has the same height as the line number bounding box
self.code_lines = Paragraph(
height_line,
*code_lines,
**base_paragraph_config,
)
@ -220,7 +222,8 @@ class Code(VMobject, metaclass=ConvertToOpenGL):
*[
str(i)
for i in range(
line_numbers_from, line_numbers_from + len(self.code_lines)
line_numbers_from - 1,
line_numbers_from + len(self.code_lines) - 1,
)
],
**base_paragraph_config,
@ -234,6 +237,11 @@ class Code(VMobject, metaclass=ConvertToOpenGL):
line.submobjects = [c for c in line if not isinstance(c, Dot)]
self.add(self.code_lines)
self.code_lines.submobjects.pop(
0
) # The "height_line" should not be displayed, neither does its line number
self.line_numbers.submobjects.pop(0)
if background_config is None:
background_config = {}
background_config_base = self.default_background_config.copy()