class Example(MainScene):
def construct(self):
RYTHM_1 = 4
RYTHM_2 = 6
RYTHM_3 = 3
RYTHM_4 = 8
N = 1
rp_config = {"start_angle": 0}
paths = [
RegularPolygon(RYTHM_1, color=RED, **rp_config).scale(3),
RegularPolygon(RYTHM_2, color=TEAL, **rp_config).scale(3.5),
RegularPolygon(RYTHM_3, color=PURPLE, **rp_config).scale(2.6),
RegularPolygon(RYTHM_4, color=YELLOW, **rp_config).scale(3.2)
]
right_point = VGroup(*paths).get_right()
for path in paths: path.next_to(right_point, LEFT, buff=0)
configs = [
# rythm, sound, gain
[RYTHM_1, "block", -10],
[RYTHM_2, "snare"],
[RYTHM_3, "cowbell", 7],
[RYTHM_4, "kick"],
]
rythms = [
MRythm(path, self, *c)
for path, c in zip(paths, configs)
]
self.polyrythm_animation(N, rythms[0], rythms[1])
self.polyrythm_animation(N, rythms[0], rythms[1])
self.polyrythm_animation(N, rythms[0], rythms[1])
self.remove_rythm(rythms[0], rythms[1])
self.polyrythm_animation(N, rythms[2], rythms[3])
self.polyrythm_animation(N, rythms[2], rythms[3])
self.remove_rythm(rythms[2], rythms[3])
self.polyrythm_animation(N, *rythms)
self.polyrythm_animation(N, *rythms)
self.wait(2)
# render(Example)
%manim $_RV