Если вы собираетесь использовать SVG в manim, рекомендуется пройти базовый курс c SVG, потому что вы наверняка будете сталкиваться с такими проблемами очень часто, вы можете найти довольно много на youtube, Я рекомендовал вам начать с this .
Решая вопрос, чтобы проанализировать, что происходит, я создал скрипт:
creature = SVGMobject('creature.svg').set_height(FRAME_HEIGHT-1)
index = VGroup()
colors = it.cycle([YELLOW,GREEN,PURPLE,PINK,GRAY,TEAL])
for i in range(len(creature)):
text = Text(f"{i}",color=WHITE,stroke=0,font="Arial").set_height(0.4)
color = next(colors)
creature[i].set_color(color)
creature[i].set_stroke(color,2)
text.next_to(creature[i],RIGHT,buff=0)
index.add(text)
![enter image description here](https://i.stack.imgur.com/q7u2x.png)
Этот скрипт показывает мне количество частей, которые имеет svg, и я размещаю индексы справа от каждой части, как вы можете видеть на рисунке, есть 8 (начиная с 0) подфигур в SVG, и мы можем интуитивно понять, что слой 0 и 7 одинаковы, поэтому, если мы скрываем слой 7, дайте нам:
class NumberCreature(Scene):
def construct(self):
creature = SVGMobject('creature.svg').set_height(FRAME_HEIGHT-1)
index = VGroup()
colors = it.cycle([YELLOW,GREEN,PURPLE,PINK,GRAY,TEAL])
for i in range(len(creature)):
text = Text(f"{i}",color=WHITE,stroke=0,font="Arial").set_height(0.4)
color = next(colors)
creature[i].set_color(color)
creature[i].set_stroke(color,2)
text.next_to(creature[i],RIGHT,buff=0)
index.add(text)
creature.set_stroke(BLUE,2)
creature[-1].fade(1)
self.add(creature,index)
self.wait()
![enter image description here](https://i.stack.imgur.com/2FWOs.png)
Знание это не сложно интуитивно понять, что происходит, и вы должны работать над дизайном.
ВАЖНО : по умолчанию manim удаляет стилей и цветов из svg, поэтому вам придется настроить их вручную следующим образом:
class NumberCreatureS(Scene):
def construct(self):
creature = SVGMobject('creature.svg').set_height(FRAME_HEIGHT-1)
creature[0].set_style(fill_opacity=1,stroke_width=0,stroke_opacity=0,fill_color=RED_A)
creature[7].set_style(fill_opacity=0,stroke_width=30,stroke_opacity=1,stroke_color=RED)
creature[3].set_stroke(RED,20)
black_rectangle = Rectangle(
width=get_norm(creature[0].get_corner(UL)-creature[0].get_corner(UR)),
height=creature[1].get_height()/2,
fill_opacity=1,
stroke_opacity=0,
fill_color=BLACK,
)
black_rectangle.next_to(creature[0],UP,buff=0.15)
self.add(creature,black_rectangle)
self.wait()
![enter image description here](https://i.stack.imgur.com/vEEFh.png)