from manim import *
from manim import Broadcast as sfn
class Circle(Scene):
def construct(self):
#Changes background color to clearly visualize changes in fill_opacity.
self.camera.background_color = PURE_BLUE
t=Text("Program to Find Out Circumference and Area of a Circle in Python ", font_size=25,color=RED)
self.play(SpinInFromNothing(t),run_time=5)
self.wait(5)
self.play(FadeOut(t))
mrc= ("import math\n" \
"radius = float(input('Enter radius of the circle:'))\n" \
"circum = 2 * math.pi * radius\n"\
"area = math.pi * radius * radius\n"
"print('Circumference of the circle is: ', circum)\n"\
"print('Area of the circle is: ', area)")
mdesc= ("This line includes math library in the program.\n"\
"This line is used to take value of radius of circle from user using input() function.\n"\
"Circumference is calculated and reffered by variable circum.\n"\
"Area is calculated and reffered by area area.\n"
"Value of circumference is printed.\n"
"Value of area is printed.\n")
mrc= Code(code=mrc, tab_width=4,style=Code.styles_list[10],language="C",font_size=13,line_spacing=3.25,font="georgia")
mdesc= Code(code=mdesc, tab_width=4,style=Code.styles_list[10],language="C",font_size=13,line_spacing=3.25,font="georgia")
self.add(mrc[0])
self.add(mrc[1])
self.add(mdesc[0])
self.add(mdesc[1])
mdesc.move_to(2.50*RIGHT+0.25*UP)
mrc.move_to(4.50*LEFT+0.25*UP)
################
self.wait(5)
self.add(mrc[2][0])
self.play(Circumscribe(mrc[2][0],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.add(mdesc[2][0])
ar1=[Arrow(mrc[2][0],mdesc[1][0],color=RED,)]
self.play(GrowArrow(ar1[0]))
self.play(Circumscribe(mdesc[2][0],buff=0.01,time_width=5))
self.remove(*ar1)
self.wait(5)
#######################################
self.add(mrc[2][1])
self.play(Circumscribe(mrc[2][1],buff=0.01,time_width=5))
self.wait(5)
self.add(mdesc[2][1])
ar2=[Arrow(mrc[2][1],mdesc[1][1],color=RED,)]
self.play(GrowArrow(ar2[0]))
self.play(Circumscribe(mdesc[2][1],buff=0.01,time_width=5),run_time=5)
self.remove(*ar2)
self.wait(5)
#######################################
self.add(mrc[2][2])
self.play(Circumscribe(mrc[2][2],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.add(mdesc[2][2])
ar3=[Arrow(mrc[2][2],mdesc[1][2],color=RED)]
self.play(GrowArrow(ar3[0]))
self.play(Circumscribe(mdesc[2][2],buff=0.01,time_width=5),run_time=5)
self.remove(*ar3)
self.wait(5)
#######################################
#######################################
self.add(mrc[2][3])
self.play(Create(mrc[2][3]),Circumscribe(mrc[2][3],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.add(mdesc[2][3])
ar4=[Arrow(mrc[2][3],mdesc[1][3],color=RED)]
self.play(GrowArrow(ar4[0]))
self.play(Circumscribe(mdesc[2][3],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.remove(*ar4)
#######################################
self.add(mrc[2][4])
self.play(Circumscribe(mrc[2][4],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.add(mdesc[2][4])
ar5=[Arrow(mrc[2][4],mdesc[1][4],color=RED)]
self.play(GrowArrow(ar5[0]))
self.play(Circumscribe(mdesc[2][4],buff=0.01,time_width=5),run_time=5)
self.wait(5)
self.remove(*ar5)
self.wait(2)
#######################################
self.add(mrc[2][5])
self.play(Circumscribe(mrc[2][5],buff=0.01,time_width=15),run_time=5)
self.wait(5)
self.add(mdesc[2][5])
ar6=[Arrow(mrc[2][5],mdesc[1][5],color=RED)]
self.play(GrowArrow(ar6[0]))
self.play(Circumscribe(mdesc[2][5],buff=0.01,time_width=15),run_time=5)
self.wait(5)
self.remove(*ar6)
self.wait(5)
#####################################
self.play(FadeOut(mrc))
self.play(FadeOut(mdesc))
t=Text("Thanks for Watching ", font_size=45,color=RED)
self.play(SpinInFromNothing(t),run_time=5)
self.wait(2)
Video output of the above code-