• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Manim/Help6

TheoremOfBeethoven May 25th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from manimlib.imports import *
2.
3. class ClockOrganization(VGroup):
4.   CONFIG = {
5.     "numbers" : 4,
7.     "color" : WHITE
8.   }
9.
10.   def __init__(self, **kwargs):
11.     digest_config(self, kwargs, locals())
12.     self.generate_nodes()
13.     VGroup.__init__(self, *self.node_list,**kwargs)
14.
15.   def generate_nodes(self):
16.     self.node_list = []
17.     for i in range(self.numbers):
18.       mobject = VMobject()
19.       number = TexMobject(str(i+1))
23.       mobject.move_to(
24.         self.radius * np.cos((-TAU / self.numbers) * i + 17*TAU / 84) * RIGHT
25.         + self.radius * np.sin((-TAU / self.numbers) * i + 17*TAU / 84) * UP
26.       )
27.       self.node_list.append(mobject)
28.
29.   def color_node(self, node, color):
30.     selected_node=self.node_list[node].copy()
31.     selected_node.set_color(color)
32.     return selected_node
33.
34. COLOR_LIST = ["#3b661a",
35.               "#ea0099",
36.               "#00dc82",
37.               "#6047b8",
38.               "#c788ff",
39.               "#65b000",
40.               "#ffcd34",
41.               "#8b3798",
42.               "#d29800",
43.               "#535593",
44.               "#d85e00",
45.               "#6debff",
46.               "#a62370",
47.               "#01b9a3",
48.               "#f5b5ff",
49.               "#806700",
50.               "#efd1ff",
51.               "#844e28",
52.               "#c3d9ff",
53.               "#3b6355",
54.               "#ffe6f4"]
55.
56. COORDINATE_LIST = [0.818*UP,1*RIGHT+0.241*UP]
57.
58. class TestingWithReplacementTransform(Scene):
59.   def construct(self):
60.     test = ClockOrganization(numbers=21)
61.     self.play(Write(test), run_time=1.5)
62.     self.wait(2)
63.     test_with_colors=VGroup(*[test.color_node(group,COLOR_LIST[group]) for group in range(test.numbers)])
64.     for group in range(test.numbers):
65.       self.play(ReplacementTransform(
66.         test.node_list[group],
67.         test_with_colors[group]
68.       ))
69.     for i in range(len(COORDINATE_LIST)):
70.       replacement_node = test_with_colors[i].copy()
71.       replacement_node.move_to(COORDINATE_LIST[i])
72.       self.play(ReplacementTransform(
73.         test_with_colors[i],
74.         replacement_node
75.       ))
76.     self.wait()
77.
78. class TestingWithTransform(Scene):
79.   def construct(self):
80.     test = ClockOrganization(numbers=21)
81.     self.play(Write(test), run_time=1.5)
82.     self.wait(2)
83.     for group in range(test.numbers):
84.       self.play(Transform(
85.         test.node_list[group],
86.         test.color_node(group,COLOR_LIST[group])
87.       ))
88.     for i in range(len(COORDINATE_LIST)):
89.       replacement_node = test[i].copy()
90.       replacement_node.move_to(COORDINATE_LIST[i])
91.       self.play(ReplacementTransform(
92.         test[i],
93.         replacement_node
94.       ))
95.     self.wait()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top