Mobject 屏幕顺序
下一个场景与previous 部分中的场景完全相同,只是只有一行。MobjectStyling
class MobjectZOrder(Scene):
def construct(self):
circle = Circle().shift(LEFT)
square = Square().shift(UP)
triangle = Triangle().shift(RIGHT)
circle.set_stroke(color=GREEN, width=20)
square.set_fill(YELLOW, opacity=1.0)
triangle.set_fill(PINK, opacity=0.5)
self.add(triangle, square, circle)
self.wait(1)
这里唯一的区别(除了场景名称之外)是m对象添加到场景中的顺序。在MobjectStyling
中,我们将它们添加为add(circle, square, triangle)
,而在MobjectZOrder
中,我们将它们添加为add(triangle, square, circle)
。
如你所见,:meth:'~.Scene.add' 的参数顺序决定了对象在屏幕上的显示顺序,最左边的参数放在后面。
Last updated