Skip to content

Commit

Permalink
测试进行到五边形分型部分
Browse files Browse the repository at this point in the history
  • Loading branch information
pointm committed Sep 15, 2023
1 parent 2369509 commit 19e7e41
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 43 deletions.
Binary file modified __pycache__/fractalsBY3B1B.cpython-311.pyc
Binary file not shown.
Binary file modified __pycache__/testslice.cpython-311.pyc
Binary file not shown.
47 changes: 39 additions & 8 deletions fractalsBY3B1B.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ def sierpinsk_ita(self, vgroup):#函数默认应该加上一个self函数
Sierpinski().arrange_subparts(*var)#这时候就把三个三角形的位置放到位了
#不需要设置任何的原函数参数返回
# 把原先的列表转化为VGroup,不然的话列表不好调用后面的move_to和scale等方法
sierpinskistage = VGroup()
sierpinskistage.add(*var)
vgroup = VGroup()
vgroup.add(*var)
# 把VGroup移动到原点
sierpinskistage.move_to(ORIGIN)
vgroup.move_to(ORIGIN)
# 返回VGroup对象
return sierpinskistage
return vgroup

def construct(self):
sierpinskistage = VGroup()
Expand Down Expand Up @@ -268,12 +268,12 @@ def diamond_ita(self, vgroup):#函数默认应该加上一个self函数
DiamondFractal().arrange_subparts(*var)#这时候就把四个四边形的位置放到位了
#不需要设置任何的原函数参数返回
# 把原先的列表转化为VGroup,不然的话不好调用后面的move_to和scale等方法
diamondstage = VGroup()
diamondstage.add(*var)
vgroup = VGroup()
vgroup.add(*var)
# 把VGroup移动到原点
diamondstage.move_to(ORIGIN)
vgroup.move_to(ORIGIN)
# 返回VGroup对象
return diamondstage
return vgroup

def construct(self):

Expand Down Expand Up @@ -306,6 +306,37 @@ def arrange_subparts(self, *subparts):
part.rotate(2 * np.pi * x / 5, about_point=ORIGIN)


class TestPentagonal(Scene):
'''
测试五边形分型的可行性,,代码还是照抄上面的
'''
# 定义一个函数,接受一个vgroup对象作为参数
def pent_ita(self, vgroup, num):#函数默认应该加上一个self函数
# 将原先的vgroup复制四份,装入列表中
var = [vgroup.copy() for i in range(num)]
# 把四个迭代的vgroup的位置放到位
PentagonalFractal().arrange_subparts(*var)#这时候就把四个四边形的位置放到位了
#不需要设置任何的原函数参数返回
# 把原先的列表转化为VGroup,不然的话不好调用后面的move_to和scale等方法
vgroup = VGroup()
vgroup.add(*var)
# 把VGroup移动到原点
vgroup.move_to(ORIGIN)
# 返回VGroup对象
return vgroup

def construct(self):
penstage = VGroup()
var = PentagonalFractal.get_seed_shape(self)
penstage.add(var)


for i in range(3):
self.play(Transform(penstage,
TestPentagonal.pent_ita(self, penstage, 5)
.scale(0.575)))


class PentagonalPiCreatureFractal(PentagonalFractal):
def init_colors(self):
SelfSimilarFractal.init_colors(self)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/videos/fractalsBY3B1B/1080p60/TestDiamondFractal.mp4
Binary file not shown.
Binary file modified media/videos/fractalsBY3B1B/1080p60/TestSierpinski.mp4
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is used internally by FFMPEG.
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1413466013_2232421320_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_542162603_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_1207454126_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_3167884030_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_3954914540_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_387122659_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1413466013_2232421320_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_542162603_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_1207454126_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_3167884030_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_3954914540_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestDiamondFractal/1672018281_387122659_235106377.mp4'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is used internally by FFMPEG.
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1413466013_1780946920_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_1005114363_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_1186249936_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_3931754471_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_2448395564_235106377.mp4'
file 'file:C:/Users/Feynman/Documents/00课件-2023春-2023秋/GitGubStatus/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_3767877036_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1413466013_1780946920_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_1005114363_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_1186249936_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_3931754471_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_2448395564_235106377.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/fractalsBY3B1B/1080p60/partial_movie_files/TestSierpinski/1672018281_3767877036_235106377.mp4'
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used internally by FFMPEG.
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/testslice/1080p60/partial_movie_files/TestPentagonal/1413466013_1352096113_359913990.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/testslice/1080p60/partial_movie_files/TestPentagonal/1672018281_395309259_359913990.mp4'
file 'file:C:/Users/PointM2001/Desktop/朝花夕拾/GitHubProjekt/JuliaSetinManim/media/videos/testslice/1080p60/partial_movie_files/TestPentagonal/1672018281_467120810_359913990.mp4'
69 changes: 46 additions & 23 deletions testslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,60 @@ def arrange_subparts(self, *subparts):
part.next_to(ORIGIN, vect, buff=0)
VGroup(*subparts).rotate(np.pi / 4, about_point=ORIGIN)

def construct(self):
sierpinskistage = VGroup()
sierpinskistage.add(Sierpinski().get_seed_shape())#得到种子图像
sierpinskistage.set_opacity(0.5).set_color([RED, YELLOW, BLUE])#顺便调整种子图像的透明度与颜色

# 调用sierpinsk_ita开始迭代
# 不写一整个循环的主要原因是要手动调整三角形的大小,,,
# 如果一直只缩放0.75倍的话,后面迭代的话就会超出屏幕
for i in range(3):
self.play(Transform(sierpinskistage, self.sierpinsk_ita(sierpinskistage).scale(0.75)))
for i in range(3):
self.play(Transform(sierpinskistage, self.sierpinsk_ita(sierpinskistage).scale(0.55)))

class TestDiamondFractal(Scene):
'''
没错,这个测试代码是按照上面的谢尔宾斯基三角形的测试代码改过来的
'''
# 定义一个函数,接受一个vgroup对象作为参数
def diamond_ita(self, vgroup):#函数默认应该加上一个self函数

class PentagonalFractal(SelfSimilarFractal):
num_subparts = 5
colors = [MAROON_B, YELLOW, RED]
height = 6

def get_seed_shape(self):
return RegularPolygon(n=5, start_angle=np.pi / 2)

def arrange_subparts(self, *subparts):
for x, part in enumerate(subparts):
part.shift(0.95 * part.get_height() * UP)
part.rotate(2 * np.pi * x / 5, about_point=ORIGIN)

class TestPentagonal(Scene):
# 定义一个函数,接受一个vgroup对象作为参数
def pent_ita(self, vgroup, num):#函数默认应该加上一个self函数
# 将原先的vgroup复制四份,装入列表中
var = [vgroup.copy() for i in range(4)]
var = [vgroup.copy() for i in range(num)]
# 把四个迭代的vgroup的位置放到位
DiamondFractal().arrange_subparts(*var)#这时候就把四个四边形的位置放到位了
PentagonalFractal().arrange_subparts(*var)#这时候就把四个四边形的位置放到位了
#不需要设置任何的原函数参数返回
# 把原先的列表转化为VGroup,不然的话不好调用后面的move_to和scale等方法
diamondstage = VGroup()
diamondstage.add(*var)
vgroup = VGroup()
vgroup.add(*var)
# 把VGroup移动到原点
diamondstage.move_to(ORIGIN)
vgroup.move_to(ORIGIN)
# 返回VGroup对象
return diamondstage

return vgroup
def construct(self):
penstage = VGroup()
var = PentagonalFractal.get_seed_shape(self)
penstage.add(var)

diamondstage = VGroup()
diamondstage.add(DiamondFractal().get_seed_shape())#得到种子图像
diamondstage.set_opacity(0.5).set_color([RED, YELLOW, BLUE])#顺便调整种子图像的透明度与颜色


#调用diamond_ita开始迭代
#不写一整个循环的主要原因是要手动调整四边形的大小,,,
#如果一直只缩放0.65倍的话,后面迭代的话就会超出屏幕
for i in range(3):
self.play(Transform(diamondstage, self.diamond_ita(diamondstage).scale(0.65)))
for i in range(3):
self.play(Transform(diamondstage, self.diamond_ita(diamondstage).scale(0.45)))
self.play(Transform(penstage,
TestPentagonal.pent_ita(self, penstage, 5)
.scale(0.575)))




0 comments on commit 19e7e41

Please sign in to comment.