예제 #1
0
파일: curve.py 프로젝트: geekmiester/panim
def spiral():
    """
        Generate spirals using L-System rules
    """
    rule = {
        'X': 'XF',
        'Y': 'Y+XF+XF'
    }
    axiom = '-Y'
    # change angle to generate non-square spirals
    # 90 -> Square
    angle = 90
    iteration = 75
    n = 40

    animator = LSystemAnimator(
        interval=1,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        # start_position=(-n//2+10, -10),
        nlimit=n,
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/spiral.mp4", fps=60)
예제 #2
0
def test2():
    # http://www.motionesque.com/beautyoffractals/#!
    angle = 45
    iteration = 4

    rule = {'F': 'F- – -F+F+F+F+F+F+F- – -F'}
    axiom = 'F-F-F-F-F-F-F-F'

    rule = {'F': 'F+F- -F+F'}
    axiom = 'F++F++F'

    # 2
    angle = 40
    iteration = 2
    rule = {'F': 'F---F+F+F+F+F+F+F---F'}
    axiom = 'F+F+F+F+F+F+F+F+F'

    # 6
    angle = 72
    iteration = 3
    rule = {'F': 'F-F+F+F+F--F'}
    axiom = 'F+F+F+F+F'

    animator = LSystemAnimator(interval=20,
                               iteration=iteration,
                               rule=rule,
                               axiom=axiom,
                               turn_angle=angle,
                               start_position=(-25, 0))
    animator.animate(len(animator.coords))
    animator.save("out/test.mp4")
예제 #3
0
def main():
    symbols = "Ff+-"
    axiom = "F"
    N = 5
    # rule = generate_branched(N)
    rule = generate_continuous(N)
    print(rule)
    angle = random.choice(range(0, 181, 1))
    iteration = 8
    n = 50

    animator = LSystemAnimator(
        interval=1,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        # start_position=(-n//2+10, -10),
        nlimit=n,
        line_width=1,
    )

    contd = bool(input("Want to generate?(y/n)").strip().lower() == "y")
    if not contd:
        print("See ya sucker...")
        sys.exit(0)

    animator.animate(len(animator.coords))
    animator.save(f"out/curves/random-{int(time.time())}.mp4", fps=25, dpi=150)
예제 #4
0
파일: curve.py 프로젝트: geekmiester/panim
def pentaplexity():
    # http://paulbourke.net/fractals/lsys/
    angle = 35
    iteration = 3
    rule = {
        'F' : 'F[+FF][-FF]F[-F][+F]F'
    }
    axiom = 'F'

    rule = {
        'F' : 'F++F++F|F-F++F'
    }
    axiom = 'F++F++F++F++F'
    angle = 36
    iteration = 4
    n = 50

    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n//2, -n//2),
        nlimit=n,
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/pentaplexity.mp4")
예제 #5
0
파일: rand.py 프로젝트: geekmiester/panim
def main():
    symbols = 'Ff+-'
    axiom = 'F'
    N = 4
    # rule = generate_random(N)
    rule = generate_branched(N)
    print(rule)
    # return
    angle = random.choice(range(10, 91, 5))
    # angle = 90
    iteration = 5
    n = 50

    animator = LSystemAnimator(
        interval=1,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        # start_position=(-n//2+10, -10),
        nlimit=n,
    )

    contd = bool(input("Want to generate?(y/n)").strip().lower() == 'y')
    if not contd:
        print("See ya sucker...")
        sys.exit(0)

    animator.animate(len(animator.coords))
    animator.save("out/curves/random.mp4", fps=30)
예제 #6
0
def main():
    axiom = 'L'
    rule = {
        'L': '-RF+LFL+FR-',
        'R': '+LF-RFR-FL+'
    }
    angle = 90

    animator = LSystemAnimator(interval=50, iteration=5, rule=rule, axiom=axiom, turn_angle=angle)
    animator.animate(len(animator.coords))
    # animator.animate(500)
    animator.save("out/hilbert.mp4")
예제 #7
0
def hilbert():
    angle = 90
    axiom = "L"
    rule = {"L": "-RF+LFL+FR-", "R": "+LF-RFR-FL+"}
    iteration = 5
    n = 40
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(n // 2, -n // 2),
        nlimit=n,
    )

    zoomer = ZoomTransformer(animobj=animator, factor=500)
    zoomer.animate(len(animator.coords))
    zoomer.save("out/hilbert.mp4")
예제 #8
0
파일: curve.py 프로젝트: geekmiester/panim
def sierpinski_square():
    angle = 90
    iteration = 5
    rule = {
        'X': 'XF-F+F-XF+F+XF-F+F-X'
    }
    axiom = 'F+XF+F+XF'
    n = 80
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n+10, 0),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/sierpinski-square.mp4")
예제 #9
0
파일: curve.py 프로젝트: geekmiester/panim
def sierpinski():
    angle = 60
    iteration = 7
    rule = {
        'B' : 'F+B+F',
        'F' : 'B−F−B',
    }
    axiom = 'F'
    animator = LSystemAnimator(
        interval=20,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        # start_position=(-20, 0),
        nlimit=30
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/sierpinski.mp4")
예제 #10
0
파일: curve.py 프로젝트: geekmiester/panim
def board():
    angle = 90
    iteration = 4
    rule = {
        'F': 'FF+F+F+F+FF'
    }
    axiom = 'F+F+F+F'
    n = 60
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n+15, -n//2),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/board.mp4")
예제 #11
0
파일: curve.py 프로젝트: geekmiester/panim
def snowflake2():
    angle = 90
    iteration = 4
    rule = {
        'F': 'F+F-F-F+F'
    }
    axiom = 'FF+FF+FF+FF'
    n = 100
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n+10, -n+15),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/snoflake2.mp4")
예제 #12
0
파일: curve.py 프로젝트: geekmiester/panim
def sierpinski_arrowhead():
    angle = 60
    iteration = 5
    rule = {
        'X': 'YF+XF+Y',
        'Y': 'XF-YF-X'
    }
    axiom = 'YF+XF+YF-XF-YF-XF-YF+XF+YF'
    n = 80
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(40, -n+10),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/sierpinski-arrowhead.mp4")
예제 #13
0
파일: curve.py 프로젝트: geekmiester/panim
def dragoncurve():
    angle = 90
    iteration = 12
    rule = {
        'X': 'X+YF+',
        'Y': '-FX-Y'
    }
    axiom = 'FX'
    n = 60
    animator = LSystemAnimator(
        interval=20,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-20, 20),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/dragoncurve.mp4")
예제 #14
0
파일: curve.py 프로젝트: geekmiester/panim
def tiles():
    rule = {
        'F': 'FF+F-F+F+FF'
    }
    axiom = 'F+F+F+F'
    angle = 90
    iteration = 4
    n = 50

    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n//2+10, -10),
        nlimit=n,
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/tiles.mp4")
예제 #15
0
파일: curve.py 프로젝트: geekmiester/panim
def quadratic_koch():
    angle = 45
    iteration = 3
    rule = {
        'X': 'X+YF++YF-FX--FXFX-YF+X',
        'Y': '-FX+YFYF++YF+FX--FX-YF'
    }
    axiom = 'X+X+X+X+X+X+X+X'
    n = 150
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(-n+40, n//2+15),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/koch-quadratic.mp4")
예제 #16
0
파일: curve.py 프로젝트: geekmiester/panim
def hilbert():
    angle = 90
    axiom = 'L'
    rule = {
        'L': '-RF+LFL+FR-',
        'R': '+LF-RFR-FL+'
    }
    iteration = 6
    n = 50
    animator = LSystemAnimator(
        interval=5,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        start_position=(n//2, -n//2),
        nlimit=n
    )
    animator.animate(len(animator.coords))
    animator.save("out/curves/hilbert.mp4")
예제 #17
0
def test3():
    # http://paulbourke.net/fractals/lsys/
    angle = 35
    iteration = 3
    rule = {'F': 'F[+FF][-FF]F[-F][+F]F'}
    axiom = 'F'

    rule = {'F': 'F++F++F|F-F++F'}
    axiom = 'F++F++F++F++F'
    angle = 36
    iteration = 4

    animator = LSystemAnimator(
        interval=20,
        iteration=iteration,
        rule=rule,
        axiom=axiom,
        turn_angle=angle,
        # start_position=(5, 0)
    )
    animator.animate(len(animator.coords))
    animator.save("out/test.mp4")