Example #1
0
def kochSnowflakeExecute():
    snowFlake = IV122Graphics.Turtle("output/fractal/koch.svg", 1000, 1000,
                                     400, 500)
    for i in range(3):
        kochSnowFlake(snowFlake, 400, 5)
        snowFlake.left(120)
    snowFlake.close()
Example #2
0
def drawNpolygon(name, n, length):
    turtle = IV122Graphics.Turtle(name, length * n, length * n, length * n / 2,
                                  length * (n - 1))
    for i in range(n):
        turtle.forward(length)
        turtle.left(360.0 / n)
    turtle.close()
Example #3
0
def squareInception(size=200.0, percent=20.0, nesting=10.0):
    turtle = IV122Graphics.Turtle("output/squareInception.svg", 400, 400, 50,
                                  300)
    curSize = size
    for level in range(nesting):
        for i in range(4):
            turtle.forward(curSize)
            turtle.left(90)
        turtle.forward(curSize * percent / 100.0)
        a = (curSize * percent / 100.0)
        b = (curSize * (1 - percent / 100.0))
        angle = Commons.radToDeg(math.atan(a / b))
        turtle.left(angle)
        curSize = math.sqrt(a**2 + b**2)
    turtle.close()
Example #4
0
def pentagramRelative():
    turtle = IV122Graphics.Turtle("output/pentaInPenta.svg", 400, 400, 50, 200)
    n = 5
    length = 100
    for i in range(n):
        turtle.forward(length)
        turtle.left(360.0 / n)
    turtle.left(360.0 / n + 180 + (180 - 360.0 / (2 * n)))
    a = length * math.sin(Commons.degToRad(360.0 / n))
    b = length * math.cos(Commons.degToRad(360.0 / n))
    length = math.sqrt((100 + b)**2 + a**2)
    for i in range(n):
        turtle.forward(length)
        turtle.left(180 - (360.0 / n) / 2)
    turtle.close()
Example #5
0
def triangleInception(size=200, d=10):
    turtle = IV122Graphics.Turtle("output/triangleInception.svg", 400, 400, 50,
                                  300)
    curSize = size
    for i in range(size / (d * 2)):
        for i in range(3):
            turtle.forward(curSize)
            turtle.left(120)
        turtle.penUp()
        turtle.forward(d)
        turtle.left(90)
        turtle.forward(d * (2.0 / 3) *
                       (math.sqrt(3.0) / 2.0))  #deserves comment
        turtle.right(90)
        turtle.penDown()
        curSize = curSize - 2 * d
    turtle.close()
Example #6
0
def drawStar(name, n, length):  #some n work better then other n
    turtle = IV122Graphics.Turtle(name, 400, 400, 50, 200)

    if (n % 2 == 0 and (n / 2) % 2 == 1):  #should be
        upperLim = n * 2
        x = 1
        div = n
    elif (n % 4 == 0):  #commented what
        upperLim = 2 * n
        x = 2
        div = n
    else:  #each branch does
        upperLim = n
        x = 2
        div = n
    for i in range(upperLim):
        turtle.forward(length)
        turtle.left(180 - (360.0 / n) / x)
    turtle.close()
Example #7
0
def turtleCreativityExecute():
    triangleFractal = IV122Graphics.Turtle(
        "output/fractal/creativeTriangle.svg", 10000, 10000, 5000, 5000)
    turtleCreativity(triangleFractal, 800, 8)
    triangleFractal.close()
Example #8
0
def creativity2Execute():
    somethign = IV122Graphics.Turtle("output/fractal/creative2.svg", 400, 400,
                                     200, 200)
    creativity2(somethign, 800, 4)
    somethign.close()
Example #9
0
def pentagonIncpetionExecute():
    pentaDrawer = IV122Graphics.Turtle("output/fractal/pentagon.svg", 1000,
                                       1000, 400, 500)
    pentagonIncpetion(pentaDrawer, 100, 2)
    pentaDrawer.close()
Example #10
0
def sierpinskiTriangleExecute():
    sierp = IV122Graphics.Turtle("output/fractal/sierp.svg", 1000, 1000, 400,
                                 500)
    sierpinskiTriangle(sierp, 200, 5)
    sierp.close()
Example #11
0
def fractalBushExecute():
    bushTurtle = IV122Graphics.Turtle("output/fractal/bush.svg", 400, 400, 200,
                                      300)
    bushTurtle.left(90)
    fractalBush(bushTurtle, 128, 8)
    bushTurtle.close()
Example #12
0
def drawImage(name, inputString, rulesInterpretation):
    size = 800
    turtle = IV122Graphics.Turtle(name, size, size, 20, size * 3 / 4)
    for c in inputString:
        eval("turtle." + rulesInterpretation[c])
    turtle.close()