コード例 #1
0
ファイル: Lab11Proj3.py プロジェクト: jawaff/CollegeCS
def main():
    """Gathering input and making the computer do stuff."""
    paul = Turtle(1024, 768)
    level = raw_input("Please enter a level for the fractals: ")
    distance = raw_input("Please enter a distance for your lines: ")
    gewd = False
    while not gewd:
        if not level.isalpha() and int(level) >= 0:
            if not distance.isalpha() and int(distance) >= 0:
                print "Thanks for the correct input, bro."
                gewd = True
            else:
                distance = raw_input(
                    "Enter a NUMBER that is greater than or equal to zero(talking about distance here): "
                )
        else:
            level = raw_input(
                "Enter a NUMBER that is greater than or equal to zero(talking about level here): "
            )

    distance = float(distance)
    paul.setWidth(1)

    x = distance / 2.0
    y = -1 * ((distance * (math.sin(60))) /
              (math.sin(90)) - distance / 1.9) / 2.0

    fractal(paul, -1 * x, y, distance, 0, int(level))
    fractal(paul, (-1 * x) + distance, y, distance, -120, int(level))
    fractal(paul, 0, -1 * y, distance, 120, int(level))

    raw_input("Press enter to exit!")
コード例 #2
0
ファイル: Lab11Proj2.py プロジェクト: jawaff/CollegeCS
def main():
    paul = Turtle(1024, 768)
    level = raw_input("Please enter a level for the fractals: ")
    gewd = False
    while not gewd:
        if not level.isalpha() and int(level) >= 0:
            print "Thanks for the correct input, bro."
            gewd = True
        else:
            level = raw_input(
                "Enter a NUMBER that is greater than or equal to zero: ")
    xy1 = raw_input(
        "Please enter an x and y coordinate with ONLY a space inbetween them: "
    )
    xy2 = raw_input("Now do the same thing for another coordinate: ")
    gewd = False
    while not gewd:
        xy1L = xy1.split()
        xy2L = xy2.split()
        if len(xy1L) == 2 and len(xy2L) == 2:
            gewd = True
        else:
            xy1 = raw_input(
                "Please enter correct coordinates with a space inbetween: ")
            xy2 = raw_input("Now do the same thing for another coordinate: ")

    paul.setWidth(1)

    fractal(paul, int(xy1L[0]), int(xy1L[1]), int(xy2L[0]), int(xy2L[1]),
            int(level))
    raw_input("Press enter to exit!")
コード例 #3
0
ファイル: lab11proj1.py プロジェクト: jawaff/CollegeCS
def main():

    #inputs
    radius1 = "alpha"
    centX1 = "alpha"
    centY1 = "alpha"

    #input error checking
    while radius1.isalpha() == True:
        radius1 = raw_input("Radius of the circle: ")
        if radius1.isdigit() == True:
            radius = int(radius1)

        elif radius1.isalpha() != True and radius1.isdigit != True:
            radius1 = "alpha"  #catches the non-alpha, non-digit characters

    while centX1.isalpha() == True:
        centX1 = raw_input("X-coordinate of the center point.")
        if centX1.isdigit() == True:
            centX = int(centX1)

        elif centX1.isalpha() != True and centX1.isdigit != True:
            centX1 = "alpha"

    while centY1.isalpha() == True:
        centY1 = raw_input("Y-coordinate of the center point.")
        if centY1.isdigit() == True:
            centY = int(centY1)

        elif centY1.isalpha() != True and centY1.isdigit != True:
            centY1 = "alpha"

    #assign Turtle to t and set the the window to 500X600
    t = Turtle(500, 600)
    t.setWidth(1)
    drawCircle(t, radius, centX, centY)
    # just to keep the window open
    raw_input("enter to continue")
コード例 #4
0
def main():
   level = input("Enter the level (0 or greater): ")
   turtle = Turtle(400, 500)
   turtle.setWidth(1)
   cCurve(turtle, 50, -100, 50, 100, level)
コード例 #5
0
def main():
    turtle = Turtle(300, 350)
    turtle.setWidth(1)
    ccurve(turtle, 75, -75, 75, 75, 14)
コード例 #6
0
def main():
    house = [
    ]  #A list containing all the primitives needed for drawing a house
    person = [
    ]  #A list containing all the primitives needed for drawing a person

    #Initialize the turtle
    paul = Turtle(900, 700)

    #Initializaing and appending objects that make up the house that we want to store into one list.
    #Initialize house1 and put into the according list
    house1 = Rectangle(paul,
                       (randint(0, 255), randint(0, 255), randint(0, 255)),
                       -400, -200, 200, 200)  #House frame
    house.append(house1)  #Throw house1 into that list

    #Initialize house2 and put into the according list
    house2 = Rectangle(paul,
                       (randint(0, 255), randint(0, 255), randint(0, 255)),
                       -350, -200, 40, 100)  #Door
    house.append(house2)

    house3 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                  -400, 0, -300, 50)  #roof left diag
    house.append(house3)

    house4 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                  -200, 0, -300, 50)  #roof right diag
    house.append(house4)

    #We don't need the list of coords returned by this func
    #Draw all the trees!!!!!!!!!!!!!!!!!!!!!!!!
    growTree(paul, -150, -200, 90, 9, 30, 300, 0, 0.5, 0)
    growTree(paul, 50, -200, 90, 9, 30, 300, 0, 0.5, 0)
    growTree(paul, 150, -200, 90, 9, 30, 300, 0, 0.5, 0)
    growTree(paul, 250, -200, 90, 9, 30, 300, 0, 0.5, 0)
    growTree(paul, 350, -200, 90, 9, 30, 300, 0, 0.5, 0)

    paul.setWidth(5)
    #Iterate through the house list
    for primitive in house:
        #Draw the current primitive
        primitive.draw()

    pers1 = Circle(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                   100, -130, 10)  #The head
    person.append(pers1)
    pers2 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                 100, -140, 100, -180)  #The body line
    person.append(pers2)
    pers3 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)), 80,
                 -160, 100, -145)  #larm
    person.append(pers3)
    pers4 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                 100, -145, 120, -160)  #rarm
    person.append(pers4)
    pers5 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)), 80,
                 -200, 100, -180)  #Left leg line
    person.append(pers5)
    pers6 = Line(paul, (randint(0, 255), randint(0, 255), randint(0, 255)),
                 120, -200, 100, -180)  #Right leg line
    person.append(pers6)

    #Iterate through the person list
    for primitive in person:
        #Draw the current Primitive
        primitive.draw()