from manim import *
import numpy as np
from os import system
import os
from colour import Color
import math
import random
config.media_dir = "E:\PythonMedia\media"
config.frame_width = 9#9#16
config.frame_height = 16#16#
config.frame_size = (360,640)#(720,1280)#(2160,3840)##(3840,2160)##(3840,2160)#(1280,720)#(1080, 1920) #(1920, 1080) 426 x , 640 x 360,
config.frame_rate = 50
config.background_color = BLUE_B
class No87(Scene):
index = 1
FPSArray = [50, 102, 200, 208, 252, 260, 350, 358, 366, 402, 410, 419, 500, 508, 516, 525, 552, 560, 569, 577, 650]
ballPlay = [[0], [0], [0], [1], [0], [1], [0], [1], [2], [0], [1], [2], [0], [1], [2], [3], [0], [1], [2], [3], [0]]
def construct(self):
###初始化声音素材
sounds = ['0.wav','1.wav', '2.wav', '3.wav', '4.wav', '5.wav', '6.wav', '7.wav', '8.wav', '9.wav', '10.wav',
'11.wav', '12.wav', '13.wav', '14.wav', '15.wav', '16.wav','17.wav']
soundPath = '..\\sound'
dirname = os.path.dirname(__file__)
sounds = [os.path.join(dirname, soundPath, s) for s in sounds]
def draw_collection():
for frameIndex in range(len(self.FPSArray)):
if self.FPSArray[frameIndex] == self.index:
self.add_sound(sounds[self.ballPlay[frameIndex][0]])
self.index = self.index + 1
return Circle(radius=0.1)
vg_mobject = always_redraw(draw_collection)
self.add(vg_mobject)
self.play(
Create(Text("text test").move_to(LEFT * 10), run_time=60))
if __name__ == '__main__':
system("manim -ql {} No87 --disable_caching".format(__file__))