Example #1
0
 def run(self, fnprovider: AbstractFilenameProvider):
     plt.clf()
     random.seed(433308)
     iters = 100000
     drawResults(20, iters).savefig(
         fnprovider.get_filename(".png", "test_20", "Test 20"))
     drawResults(50, iters).savefig(
         fnprovider.get_filename(".png", "test_50", "Test 50"))
     drawResults(100, iters).savefig(
         fnprovider.get_filename(".png", "test_100", "Test 100"))
     return fnprovider.format_files()
Example #2
0
File: PartB.py Project: jksdf/IV122
    def run(self, fnprovider: AbstractFilenameProvider):
        random.seed(433308)

        colors = list(matplotlib.colors.TABLEAU_COLORS.values())
        animate(
            5, 3,
            sum([
                generate_circle_gauss(50, (200, 200), 20),
                generate_circle_gauss(80, (300, 200), 30),
                generate_circle_gauss(50, (380, 350), 50)
            ], []), colors,
            500).saveas(fnprovider.get_filename(".svg", "example1",
                                                "Distinct clusters"),
                        pretty=True)

        animate(
            5, 3,
            sum([
                generate_circle_gauss(100, (200, 200), 50),
                generate_circle_gauss(100, (300, 200), 50),
                generate_circle_gauss(50, (380, 350), 50)
            ], []), colors,
            500).saveas(fnprovider.get_filename(".svg", "example2",
                                                "2 merged clusters"),
                        pretty=True)

        animate(13,
                3,
                sum([
                    generate_circle_gauss(200, (200, 200), 50),
                    generate_circle_gauss(200, (250, 200), 50),
                    generate_circle_gauss(50, (380, 350), 50)
                ], []),
                colors,
                500,
                init_idxs=[0, 1, 2]).saveas(fnprovider.get_filename(
                    ".svg", "example3", "2 merged clusters (very close)"),
                                            pretty=True)

        animate(6,
                2,
                load_points('../resources/w11/faithful.txt'),
                colors,
                150,
                x_scale=10,
                scale=5,
                init_idxs=[54, 222]).saveas(fnprovider.get_filename(
                    ".svg", "faithful", "Faithful"),
                                            pretty=True)

        return fnprovider.format_files()
Example #3
0
File: PartA.py Project: jksdf/IV122
 def run(self, fnprovider: AbstractFilenameProvider):
     save_gif(
         chaos_game(3, 10000, 10, 1 / 2),
         fnprovider.get_filename('.gif', 'chaos_triangle',
                                 'Chaos triangle (n=3, r=1/2)'))
     save_gif(chaos_game(5, 10000, 50, 1 / 2),
              fnprovider.get_filename('.gif', 'chaos_pentagon',
                                      'Chaos pentagon (n=3, r=1/2)'),
              duration=100)
     save_gif(chaos_game(5, 10000, 50, 1 / 3),
              fnprovider.get_filename('.gif', 'chaos_pentagon_third',
                                      'Chaos pentagon (n=3, r=1/3)'),
              duration=100)
     return fnprovider.format_files()
Example #4
0
File: PartB.py Project: jksdf/IV122
    def run(self, fnprovider: AbstractFilenameProvider):
        draw_mrcm(5,
                  square(25), [
                      mult(translation(25, 0), scale(0.5, 0.5)),
                      mult(translation(0, 50), scale(0.5, 0.5)),
                      mult(translation(50, 50), scale(0.5, 0.5))
                  ],
                  viewbox=(-10, -10, 70, 70),
                  stroke=0.5).saveas(
                      fnprovider.get_filename('.svg', 'square_sierpinsky',
                                              'Square Sierpinsky'))

        draw_mrcm(5,
                  square(25), [
                      mult(scale(0.5, 0.5)),
                      mult(translation(0, 50), scale(0.5, 0.5)),
                      mult(translation(50, 50), scale(0.5, 0.5))
                  ],
                  viewbox=(-10, -10, 70, 70),
                  stroke=0.5).saveas(
                      fnprovider.get_filename('.svg',
                                              'square_tilted_sierpinsky',
                                              'Square tilted Sierpinsky'))

        draw_mrcm(7,
                  apply(translation(25, 25), square(25)), [
                      mult(translation(0, -50), scale(0.5, -0.5)),
                      mult(translation(50, 0), scale(0.5, 0.5)),
                      mult(translation(-50, 50), scale(-0.5, 0.5))
                  ],
                  viewbox=(-10, -10, 70, 70),
                  stroke=0.1).saveas(
                      fnprovider.get_filename('.svg', 'sierpinsky_var1',
                                              'Sierpinsky variant 1'))

        draw_mrcm(1,
                  apply(translation(25, 25), square_with_corner(25)), [
                      mult(translation(0, -50), scale(0.5, -0.5)),
                      mult(translation(50, 0), scale(0.5, 0.5)),
                      mult(translation(-50, 50), scale(-0.5, 0.5))
                  ],
                  viewbox=(-10, -10, 70, 70),
                  stroke=0.1).saveas(
                      fnprovider.get_filename('.svg', 'sierpinsky_var1_1step',
                                              'Sierpinsky variant 1 (1 step)'))

        return fnprovider.format_files()
Example #5
0
    def run(self, fnprovider: AbstractFilenameProvider):
        weed(fnprovider.get_filename('.svg', 'weed_growth', 'Weed growth'))
        koch(fnprovider.get_filename('.svg', 'koch', 'Koch'))
        sierpinsky(fnprovider.get_filename('.svg', 'sierpinsky', "Sierpinsky"))
        sierpinsky(fnprovider.get_filename('.svg', 'sierpinsky_twisted',
                                           "Sierpinsky twisted"),
                   angle=56,
                   step=4)
        paprad(fnprovider.get_filename('.svg', 'paprad', 'Paprad'))
        pentaplexity(
            fnprovider.get_filename('.svg', 'pentaplexity', "Pentaplexity"))

        return fnprovider.format_files()
Example #6
0
 def run(self, fnprovider: AbstractFilenameProvider):
     fn = fnprovider.get_filename(".svg", "fractals")
     turtle = Turtle(fn, (50, 250))
     turtle.left(90)
     self.ker(turtle, 9, size=0.2)
     turtle.resetpos(position=(200, -150))
     turtle.right(60)
     self.sierpinsky(turtle, 5, 9)
     turtle.resetpos(position=(350, -120))
     self.koch(turtle, 5, 0.8)
     turtle.resetpos(position=(600, -150))
     self.hilbert(turtle, 4, 2)
     turtle.resetpos(position=(900, -200))
     self.pentagon(turtle, 3, 10)
     turtle.resetpos(position=(1200, -200))
     self.square_sierpinsky(turtle, 4, 3)
     turtle.save(frame=(1500, 500))
     return fn