fix: call align_to AFTER move_to so bars follow rect positions

This commit is contained in:
ViperEkura 2026-05-06 22:13:11 +08:00
parent f6ccefb34e
commit b2ff243447
1 changed files with 6 additions and 6 deletions

View File

@ -284,23 +284,23 @@ class ContinuousBatching(Scene):
s_label = Text("Static Batching", font_size=24, color=RED)
s_rect = Rectangle(width=bar_max_w, height=bar_h, color=RED, stroke_width=1.5)
s_bar = Rectangle(width=bar_max_w * ratio, height=bar_h,
color=RED, fill_opacity=0.55, stroke_width=0) \
.align_to(s_rect, LEFT).align_to(s_rect, UP)
color=RED, fill_opacity=0.55, stroke_width=0)
s_num = Text("1.0x", font_size=24, color=RED)
# ---- Continuous Batching row ----
c_label = Text("Continuous Batching", font_size=24, color=GREEN)
c_rect = Rectangle(width=bar_max_w, height=bar_h, color=GREEN, stroke_width=1.5)
c_bar = Rectangle(width=bar_max_w, height=bar_h,
color=GREEN, fill_opacity=0.55, stroke_width=0) \
.align_to(c_rect, LEFT).align_to(c_rect, UP)
color=GREEN, fill_opacity=0.55, stroke_width=0)
c_num = Text("3.4x", font_size=24, color=GREEN)
# position rects vertically stacked, same x
# position rects first, then align bars
s_rect.move_to(ORIGIN + UP * (row_gap / 2 + bar_h / 2))
c_rect.move_to(ORIGIN + DOWN * (row_gap / 2 + bar_h / 2))
s_bar.align_to(s_rect, LEFT).align_to(s_rect, UP)
c_bar.align_to(c_rect, LEFT).align_to(c_rect, UP)
# labels left, nums right, bars follow rects
# labels left, nums right
s_label.next_to(s_rect, LEFT, buff=0.4)
c_label.next_to(c_rect, LEFT, buff=0.4)
s_num.next_to(s_rect, RIGHT, buff=0.4)