Manim is able to create polyrhythm animation quickly, below is how I render the animation.
audio part in not included here.
from manim import *
import numpy as np
from os import system
import math
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.collections import LineCollection
import matplotlib.cm as cm
import matplotlib.colors as mcolors # Import the colors module
from colour import Color
from Tool import getGradientColors
config.media_dir = "E:\PythonMedia\media"
config.frame_width = 16#9#16
config.frame_height = 9#16#
config.frame_size = (3840,2160)#(720,1280)#(2160,3840)##(3840,2160)##(3840,2160)#(1280,720)#(1080, 1920) #(1920, 1080) 426 x , 640 x 360,
config.frame_rate = 60
config.background_color = BLACK
class NO86_Manim(Scene):
frameIndex = 0
def construct(self):
circleCount = 30
colors = getGradientColors(circleCount, 'rainbow')
#print(colors)
lastAlpha = 0.3
sCount = circleCount * 20
runTime = 6 #second
pThetas = [np.linspace(0, (sCount - _) * 360, runTime * config.frame_rate) for _ in range(circleCount)]
circleRadius = np.linspace(0.5, 4.2, circleCount)
circles = [Circle(radius=circleRadius[index], fill_opacity=0,
stroke_width=10, stroke_color=colors[index], stroke_opacity=lastAlpha)
for index in range(circleCount)]
for x in circles:
self.add(x)
def update_collection():
vg = VGroup()
for index in range(len(circleRadius)):
arc = Arc(start_angle=pThetas[index][self.frameIndex] * DEGREES, angle=DEGREES * -90,
stroke_width=10, radius=circleRadius[index], stroke_opacity=0.7)
arcCurve = CurvesAsSubmobjects(arc)
arcCurve.set_color_by_gradient(WHITE, colors[index])
vg.add(arcCurve)
self.frameIndex = self.frameIndex + 1
return vg
objects = always_redraw(update_collection)
self.add(objects)
self.play(Create(Text("Test Fake").move_to(LEFT*100), run_time=runTime - 1/config.frame_rate, rate_func=linear)) #runTime
print("over")
if __name__ == '__main__':
system("manim -ql {} NO86_Manim ".format(__file__))
