Manim:在现有对象后面创建对象(在创建时强制 z-index)
Manim: creating objects behind existing objects (force z-index at creation time)
我正在使用 Manim CE 0.8.0,我正在尝试使场景中现有对象后面的轴淡入淡出;我找不到办法做到这一点。这是一个 POC:
from manim import *
class FadeBehind(Scene):
def construct(self):
myDot = Dot(
point = [0, 0, 0],
radius = 3,
color = RED,
)
self.play(
FadeIn(myDot),
)
myLine = Line(
start = [-5, 0, 0],
end = [5, 0, 0],
stroke_color = BLUE,
stroke_width = 30,
)
myLine.z_index = myDot.z_index - 1
self.play(
FadeIn(myLine) # works as expected (the blue line is shown behind the dot)
)
self.wait()
ax = Axes(
x_range=[-7, 7, 1],
y_range=[-5, 5, 1],
)
ax.z_index = myLine.z_index - 1
self.play(
FadeIn(ax) # doesn't work as expected (the axes are overlayed on top of everything in the scene)
)
问题是,默认的 z_index 是 0:print(myDot.z_index)
给出 0。
z_index 必须为正数。
这是有效的脚本:
class FadeBehind(Scene):
def construct(self):
myDot = Dot(
point = [0, 0, 0],
radius = 2,
color = RED,
)
self.play(
FadeIn(myDot),
)
myDot.z_index=1
myLine = Line(
start = [-5, 0, 0],
end = [5, 0, 0],
stroke_color = BLUE,
stroke_width = 30,
)
myLine.z_index = 0
self.play(
FadeIn(myLine) # works as expected (the blue line is shown behind the dot)
)
ax = Axes(
x_range=[-7, 7, 1],
y_range=[-5, 5, 1],
)
ax.z_index = 0
self.play(
FadeIn(ax) # now works as expected since lower z-index
)
我正在使用 Manim CE 0.8.0,我正在尝试使场景中现有对象后面的轴淡入淡出;我找不到办法做到这一点。这是一个 POC:
from manim import *
class FadeBehind(Scene):
def construct(self):
myDot = Dot(
point = [0, 0, 0],
radius = 3,
color = RED,
)
self.play(
FadeIn(myDot),
)
myLine = Line(
start = [-5, 0, 0],
end = [5, 0, 0],
stroke_color = BLUE,
stroke_width = 30,
)
myLine.z_index = myDot.z_index - 1
self.play(
FadeIn(myLine) # works as expected (the blue line is shown behind the dot)
)
self.wait()
ax = Axes(
x_range=[-7, 7, 1],
y_range=[-5, 5, 1],
)
ax.z_index = myLine.z_index - 1
self.play(
FadeIn(ax) # doesn't work as expected (the axes are overlayed on top of everything in the scene)
)
问题是,默认的 z_index 是 0:print(myDot.z_index)
给出 0。
z_index 必须为正数。
这是有效的脚本:
class FadeBehind(Scene):
def construct(self):
myDot = Dot(
point = [0, 0, 0],
radius = 2,
color = RED,
)
self.play(
FadeIn(myDot),
)
myDot.z_index=1
myLine = Line(
start = [-5, 0, 0],
end = [5, 0, 0],
stroke_color = BLUE,
stroke_width = 30,
)
myLine.z_index = 0
self.play(
FadeIn(myLine) # works as expected (the blue line is shown behind the dot)
)
ax = Axes(
x_range=[-7, 7, 1],
y_range=[-5, 5, 1],
)
ax.z_index = 0
self.play(
FadeIn(ax) # now works as expected since lower z-index
)