示例#1
0
def main():
    turtle.left(90)
    turtle.up()
    turtle.backward(120)
    turtle.down()
    drawTree(60)
    turtle.exitonclick()
示例#2
0
def turtle_init():
	turtle.ht()
	turtle.up()
	turtle.speed(0)
	turtle.left(90)
	turtle.backward(350)
	turtle.down()
def basaDon():
    turtle.penup()
    turtle.backward(200)
    turtle.right(90)
    turtle.forward(100)
    turtle.left(90)
    turtle.pendown()
示例#4
0
def backward(seconds):
    turtle.backward(seconds * 100)
    motor_on(LEFT_BACKWARD)
    motor_on(RIGHT_BACKWARD)
    sleep(seconds)
    motor_off(LEFT_BACKWARD)
    motor_off(RIGHT_BACKWARD)
def tscheme_backward(n):
    """Move the turtle backward a distance N units on the current heading,
    without changing direction."""
    _check_nums(n)
    _tscheme_prep()
    turtle.backward(n)
    return okay
示例#6
0
def house(length):
    """
    Draw a nice house where the base is length long and put the turtle
    back to its original position at the end.
    """
    inside = SQRT2 * length
    roof = inside / 2.

    turtle.forward(length)
    turtle.left(90)
    turtle.forward(length)

    # roof
    turtle.left(45)
    turtle.forward(roof)
    turtle.left(90)
    turtle.forward(roof)
    turtle.left(45)

    # interior
    turtle.forward(length)
    turtle.left(135)
    turtle.forward(inside)
    turtle.left(135)
    turtle.forward(length)
    turtle.left(135)
    turtle.forward(inside)

    # back into position
    turtle.left(45)
    turtle.backward(length)
def y_tree(length = 200):
    """
    This function receives a length and draws a tree according to the length
    in an angle 60 between the branches always reducing the next length by
    0.6. The drawing ends when the length is smaller than 10
    :param length: The length of the branch to draw, default 200
    :return: None
    """
    ANGLE_BETWEEN_BRANCHES = 60
    LENGTH_REDUCTION = 0.6
    MIN_LENGTH = 10


    if length <= MIN_LENGTH:
        return
    else:
        turtle.forward(length)                  # draws the branch
        turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
        y_tree(LENGTH_REDUCTION * length)       # draws the left branch

        turtle.right(ANGLE_BETWEEN_BRANCHES)
        y_tree(LENGTH_REDUCTION * length)       # draws the right branch

        turtle.left(ANGLE_BETWEEN_BRANCHES / 2)
        turtle.backward(length)                 # returns back to draw next
示例#8
0
def draw_tree(depth, height, branches, leafs, angle):
    """
    Draws the tree using recursion
    :pre: pos(0,0), heading east, up
    :post: pos(0,0), heading east, up
    :param depth: number of layers of sub branches (recursion depth)
    :param height: height of tree
    :param branches: number of branches
    :param leafs: number of leafs
    :param angle: angle between branches
    :return: None
    """
    if depth == 0:
        leafs = random.randint(0, leafs)
        draw_leaf(leafs)
        t.down()
        pass

    else:
        t.color('brown')
        t.forward(height)
        for i in range(1, branches+1):
            t.left(90 - i * angle)
            #random branches
            branches = random.randint(branches-1,branches+5)
            draw_tree(depth - 1, height * HEIGHT_FACTOR, branches, leafs, angle)
            t.right(90 - i * angle)
            #random angle
            angle = random.randint(angle-1, angle+1)
            if depth == 1:
                break
        t.color('brown')
        t.backward(height)
def drawTree(tree, angle, length, width):
    turtle.width(width)

    if tree[0] == "ancestor":
        # left branch
        turtle.left(angle)
        turtle.forward(length)
        turtle.right(angle)
        drawTree(tree[1], angle - 0.2 * angle, length - 0.2 * length, width - 0.3 * width)
        turtle.width(width)
        turtle.left(angle)
        turtle.backward(length)
        turtle.right(angle)
        
        # right branch
        turtle.right(angle)
        turtle.forward(length)
        turtle.left(angle)
        drawTree(tree[2], angle - 0.2 * angle, length - 0.2 * length, width - 0.3 * width)
        turtle.width(width)
        turtle.right(angle)
        turtle.backward(length)
        turtle.left(angle)
    else:
        # draw the ending node
        turtle.pencolor("red")
        turtle.write(tree[0], font=("Monospace", 14, "bold"))
        turtle.pencolor("black")
示例#10
0
文件: y_tree.py 项目: yochze/intro2cs
def draw_tree(length=200):
    """
    A recursive function that uses the turtle external library to
    draw a binary tree in the size of the user input (or default: 200).

    The flow of the function that it first draw a straight line,
    the right side branches and then left side branches.
    """
    # length is number of pixel 
    deg = 30 # degrees of each branch (left, right)

    if not length < 10:
        # Base is when the length is lower then 10,
        # otherwise, continue with the iteration.

        turtle.forward(length)  # Draw straight line forward size length 
        turtle.right(deg)       # Turn right 30 degrees
        draw_tree(length*0.6)   # Call the recursion to draw the right
                                # side branches

        turtle.left(deg*2)      # Then turn left (30 degrees center,
                                # 30 degrees more to the left)
        draw_tree(length*0.6)   # Draw inner left side branches

        turtle.right(deg)       # Turn to center
        turtle.backward(length) # Go backwards length size
def tscm_backward(n):
    """Move the turtle backward a distance N units on the current heading,
    without changing direction."""
    _check_nums(n)
    _tscm_prep()
    turtle.backward(n.num_val)
    return UNSPEC
def pythagoras_tree(size, n):
    turtle.begin_fill()
    for _ in range(4):
        turtle.forward(size)
        turtle.left(90)

    turtle.end_fill()
    if n > 0:
        roof = .5 * math.sqrt(2) * size

        turtle.left(90)
        turtle.forward(size)
        turtle.right(45)

        pythagoras_tree(roof, n - 1)

        turtle.forward(roof)
        turtle.right(90)

        pythagoras_tree(roof, n - 1)

        turtle.left(90)
        turtle.backward(roof)
        turtle.left(45)
        turtle.backward(size)
        turtle.right(90)
示例#13
0
		def plot_a_face(angle, pencolor, fillcolors, dimension):
			t.down()
			
			def plot_a_row(angle, pencolor, fillcolors,dimension):
				for i in range(len(fillcolors)):
					t.color(pencolor, fillcolors[i])
					t.begin_fill()
					t.forward(50*3/dimension)
					t.right(angle)
					t.forward(50*3/dimension)
					t.right(180 - angle)
					t.forward(50*3/dimension)
					t.right(angle)
					t.forward(50*3/dimension)
					t.right(180 - angle)
					t.end_fill()
					t.forward(50*3/dimension)
			
			n = int(len(fillcolors)/dimension)
			for i in range(n):
				plot_a_row(angle,pencolor,fillcolors[dimension*i:dimension*(i+1)],dimension)
				t.up()
				t.backward(150)
				t.right(angle)
				t.forward(50*3/dimension)
				t.left(angle)
				t.down()
示例#14
0
def player1_symbol(jogada):
    if jogada == 1:
        go_to(-200,200,45)
    elif jogada==2:
        go_to(0,200,45)
    elif jogada==3:
        go_to(200,200,45)
    elif jogada==4:
        go_to(-200,0,45)
    elif jogada==5:
        go_to(0,0,45)
    elif jogada==6:
        go_to(200,0,45)
    elif jogada==7:
        go_to(-200,-200,45)
    elif jogada==8:
        go_to(0,-200,45)
    elif jogada==9:
        go_to(200,-200,45)
        
    turtle.pencolor('green')
    for i in range(4):
        turtle.forward(75)
        turtle.backward(75)
        turtle.right(90)
示例#15
0
文件: fieldpic.py 项目: xerebus/nedm
def draw_arrow():
    '''Draw an arrow toward the turtle's current heading, then return to
    position and heading.'''

    arrow_length = 7 # pixels
    arrow_width = 10 # pixels
    arrow_end = tt.position()
    old_heading = tt.heading()

    # move to back end of upper line
    tt.penup()
    tt.backward(arrow_length)
    tt.left(90)
    tt.forward(arrow_width)
    # draw upper line
    tt.pendown()
    tt.setposition(arrow_end)
    tt.setheading(old_heading)
    # move to back end of lower line
    tt.penup()
    tt.backward(arrow_length)
    tt.right(90)
    tt.forward(arrow_width)
    # draw lower line
    tt.pendown()
    tt.setposition(arrow_end)
    tt.setheading(old_heading)
    tt.penup()
示例#16
0
def pezzo(color, colors = colors, unit = unit, alfa = alfa, depth = depth):
    turtle.pencolor(colors[color])
    turtle.fillcolor(color)
    turtle.begin_fill()
    for i in range(2):
        turtle.forward(unit)
        turtle.left(90)
        turtle.forward(unit)
        turtle.left(90)
    turtle.forward(unit)
    for i in range(2):
        turtle.left(alfa)
        turtle.forward(depth)
        turtle.left(alfa)
        turtle.forward(unit)
        turtle.left(90)
    turtle.backward(unit)
    turtle.left(90)
    turtle.forward(unit)
    turtle.right(90)
    for i in range(2):
        turtle.forward(unit)
        turtle.left(alfa)
        turtle.forward(depth)
        turtle.left(180-alfa)
    turtle.end_fill()
    turtle.right(90)
    turtle.forward(unit)
    turtle.left(90)
示例#17
0
def render(tree, length, width):
    "Draws a given phylogenetic tree constrained by dimensions of" 
    "length and width."
    root = tree[0]
    leftTree = tree[1]
    rightTree = tree[2]
    if leftTree == (): 
        turtle.dot(10)
        turtle.write(root , font=("Arial", 20, "normal"))
        return
    else:
        turtle.dot(10)
        turtle.write(root, font=("Arial", 20, "normal"))
        turtle.left(90)
        turtle.forward(width)
        turtle.right(90)
        turtle.forward(length)
        render(leftTree, 0.5*length, 0.5*width) 
        turtle.back(length)
        turtle.left(90)
        turtle.backward(2*width)
        turtle.right(90)
        turtle.forward(length)
        render(rightTree, 0.5*length, 0.5*width)
        turtle.back(length)
        turtle.right(90)
        turtle.back(width)
        turtle.left(90)
        return
示例#18
0
    def test_same_function_names_work(self):
        # draw some things using the english commands in tortuga
        tortuga.forward(50)
        tortuga.left(90)
        tortuga.forward(50)
        tortuga.right(45)
        tortuga.backward(50)
        tortuga.left(45)
        tortuga.pensize(5)
        for c in (english_colors):
            tortuga.color(c)
            tortuga.forward(10)

        # now draw the same things using turtle
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(50)
        turtle.right(45)
        turtle.backward(50)
        turtle.left(45)
        turtle.pensize(5)
        for c in (english_colors):
            turtle.color(c)
            turtle.forward(10)

        # and make sure they both resulted in the same output
        self.assert_same()
示例#19
0
    def test_equivalent_spanish_names_work(self):
        # draw some things using the english commands in tortuga
        tortuga.adelante(50)
        tortuga.izquierda(90)
        tortuga.adelante(50)
        tortuga.derecho(45)
        tortuga.atras(50)
        tortuga.izquierda(45)
        tortuga.tamano_lapiz(5)
        for c in (english_colors):
            tortuga.color(c)
            tortuga.adelante(10)
        for c in (spanish_colors):
            tortuga.color(c)
            tortuga.adelante(10)

        # now draw the same things using turtle
        turtle.forward(50)
        turtle.left(90)
        turtle.forward(50)
        turtle.right(45)
        turtle.backward(50)
        turtle.left(45)
        turtle.pensize(5)
        for c in (english_colors):
            turtle.color(c)
            turtle.forward(10)
        for c in (english_colors):
            turtle.color(c)
            turtle.forward(10)

        # and make sure they both resulted in the same output
        self.assert_same()
示例#20
0
def serpinski_draw(length, depth):
        t.forward(length)
        print("forward {}".format(length))
        serpinski(length/2, depth-1)
        t.backward(length)
        print("backward {}".format(length))
        t.left(120)
        print("left 120")
示例#21
0
def tree(trunkLength,height):
    turtle.speed(1)
    turtle.reset()
    turtle.left(90)
    turtle.pu()
    turtle.backward(200)
    turtle.pd()
    grow(trunkLength,height)
示例#22
0
def backward(quantity):
    """Turtle animation function.

    Moves the turtle backwards by the amount of the passed quantity (converted
    from a string to a floating-point value).
    """
    convertedQuantity = convertfloat(quantity)
    turtle.backward(convertedQuantity)
示例#23
0
def drawArrows():
    turtle.pendown()
    turtle.right(135)
    turtle.forward(5)
    turtle.backward(5)
    turtle.right(90)
    turtle.forward(5)
    turtle.penup()
示例#24
0
def draw_A():
    turtle.left(60)
    turtle.forward(100)
    turtle.right(120)
    turtle.forward(100)
    turtle.backward(55)
    turtle.right(120)
    turtle.forward(45)
示例#25
0
def axis():
        turtle.backward(400)
        turtle.left(90)
        turtle.forward(90)
        turtle.left(180)
        turtle.forward(180)
        turtle.left(180)
        turtle.forward(90)
示例#26
0
def on_backward():
    val = t.textinput('Backward', "How much: ")
    if val:
        try:
            val = int(val)
            t.backward(val)
        except ValueError:
            messagebox.showinfo('Error', 'Wrong value')
    t.listen()
示例#27
0
def drawSprite(turtle, legs, legLength):
    angle = 360/legs
    for leg in range(legs):
        turtle.forward(legLength)
        stampTriangle(turtle)
        turtle.penup()
        turtle.backward(legLength)
        turtle.left(angle)
        turtle.pendown()
示例#28
0
def drawTree(length):
    if length > 10:
        turtle.forward(length)
        turtle.right(30)
        drawTree(length - 10)
        turtle.left(60)
        drawTree(length - 10)
        turtle.right(30)
        turtle.backward(length)
示例#29
0
def drawtree(turtle,distance):
    if distance>5:
        turtle.forward(distance)
        turtle.right(20)
        drawtree(turtle,distance-15)
        turtle.left(40)
        drawtree(turtle,distance-10)
        turtle.right(20)
        turtle.backward(distance)
def star(longestTrunk):
    starLocAdjust(longestTrunk)
    turtle.pencolor("purple")
    for i in range(0,8):
        turtle.forward(10)
        turtle.backward(10)
        turtle.right(45)
    turtle.pencolor("black")
    turtle.hideturtle()
示例#31
0
def draw_single_tree(ygr_code):
    turtle.forward(4)
    tree.draw_tree(6, 50, 1, ygr_code)
    turtle.backward(4)
    grass.draw_grass_patch(100, 9, 2, ygr_code)
示例#32
0
import turtle as t

print("Inserire una sequenza contenete solo le lettere f, b, r, l")
sequenza = input()

t.color("red", "red")
t.speed(1)

distanza = 50

k = 0

for k in range(len(sequenza)):
    if (sequenza[k] == "f"):
        t.forward(distanza)
    elif (sequenza[k] == "b"):
        t.backward(distanza)
    elif (sequenza[k] == "r"):
        t.right(90)
    elif (sequenza[k] == "l"):
        t.left(90)
    else:
        print("La sequenza contiene una lettera non supportata")
t.done()
示例#33
0
def curve5():
    for i in range(100):
        t.right(0.8)
        t.backward(1)
示例#34
0
def mainLoop():
    # draw hanger
    global state
    state = 'drawing'
    turtle.penup()
    turtle.pensize(4)
    turtle.setposition(-50, 100)
    turtle.pendown()
    turtle.forward(100)
    turtle.backward(50)
    turtle.left(90)
    turtle.forward(220)
    turtle.right(90)
    turtle.forward(50)
    turtle.right(90)
    turtle.forward(20)
    turtle.left(90)
    turtle.penup()
    turtle.setposition(-300, -100)

    # alphabetic characters
    top_line = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P']
    mid_line = ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L']
    btm_line = ['Z', 'X', 'C', 'V', 'B', 'N', 'M']

    # top line
    for i in range(10):
        turtle.pendown()
        turtle.begin_fill()

        turtle.fillcolor('light blue')
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)

        turtle.penup()
        turtle.setposition(-290 + 50 * i, -130)
        turtle.pendown()
        turtle.write(top_line[i], font=("Arial", 14, "bold"))
        turtle.penup()
        turtle.setposition(-300 + 50 * i, -100)
        turtle.pendown()

        turtle.end_fill()
        turtle.penup()
        turtle.forward(50)

    # mid line
    turtle.setposition(-280, -165)
    for i in range(9):
        turtle.pendown()
        turtle.begin_fill()

        turtle.fillcolor('light green')
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)

        turtle.penup()
        turtle.setposition(-270 + 50 * i, -195)
        turtle.pendown()
        turtle.write(mid_line[i], font=("Arial", 14, "bold"))
        turtle.penup()
        turtle.setposition(-280 + 50 * i, -165)
        turtle.pendown()

        turtle.end_fill()
        turtle.penup()
        turtle.forward(50)

    # bottom line
    turtle.setposition(-260, -230)
    for i in range(7):
        turtle.pendown()
        turtle.begin_fill()

        turtle.fillcolor('light blue')
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)
        turtle.forward(40)
        turtle.right(90)

        turtle.penup()
        turtle.setposition(-250 + 50 * i, -260)
        turtle.pendown()
        turtle.write(btm_line[i], font=("Arial", 14, "bold"))
        turtle.penup()
        turtle.setposition(-260 + 50 * i, -230)
        turtle.pendown()

        turtle.end_fill()
        turtle.penup()
        turtle.forward(50)

    # button press-call
    state = 'running'
    turtle.onscreenclick(btnClk, 1)
    turtle.listen()
示例#35
0
turtle.left(55)
turtle.forward(10)
#turtle.circle(4)

#mouth
turtle.pu()
turtle.goto(-15, -35)
turtle.pd()
turtle.left(55)
turtle.forward(20)
#turtle.backward(8)
turtle.pu()
turtle.goto(-15, -35)
turtle.pd()
turtle.forward(40)
turtle.backward(20)
turtle.right(90)
turtle.forward(10)
turtle.circle(5, 180)
turtle.forward(10)
turtle.left(90)
turtle.forward(4)
turtle.left(90)
turtle.pu()
turtle.forward(2)
turtle.pd()
turtle.forward(7)
turtle.pu()
turtle.home()

print(turtle.position())
示例#36
0
 def backward(self,distance):
     super(TurtleGui,self).backward(distance)
     std_turtle.backward(distance)
示例#37
0
def Letter_L():
    turtle.left(90)
    turtle.forward(100)
    turtle.backward(100)
    turtle.right(90)
    turtle.forward(30)
示例#38
0
文件: 4_9_10.py 项目: kamit17/Python
def star(side):
    t.pendown()

    for i in range(5):  #Draws pentagram
        t.forward(side)
        t.right(144)
    t.penup()

    #t.penup()


wn = t.Screen()
wn.bgcolor("Hot Pink")

t = t.Turtle()
t.penup()
t.hideturtle()

t.backward(175)  # Position t at a convenient spot.
t.left(90)
t.forward(60)
t.right(90)

for a in range(5):
    star(100)
    t.forward(350)
    t.right(144)
#star(100)
wn.mainloop()
示例#39
0
import turtle

turtle.shape('turtle')

for i in range(12):
    turtle.forward(100)
    turtle.stamp()
    turtle.backward(100)
    turtle.left(-30)
示例#40
0
rows = eval(input("Enter the number of rows: "))
line = 1
n = 1
while line <= rows:
	print(" " * (rows - line) + type * (line * 2 - 1) + " " * (rows - line))
	line += 1
while line > 2*rows: # line의 마지막을 정해서 무한 루프 없애기
        if n <= rows:
                print(" " * (line - rows)  + type * ((line - 2 * n) * 2 - 1) + " " * (line - rows))
                line += 1
                n += 1


#lab 4-5
#점점 작아지는 사각형 그림그리기
import turtle
x = -100
y = 100
while x < 0 and y > 0 :
        turtle.penup()
        turtle.goto(x, y)
        turtle.pendown()
        for side in range(4):
                turtle.backward(2 * x)
                turtle.right(90)
        x += 10
        y -= 10
        continue
turtle.hideturtle()
turtle.done()
import turtle as t
t.Turtle()
t.shape("turtle")
t.forward(100)
t.left(90)
t.forward(100)
t.right(45)
t.forward(50)
t.backward(200)
t.circle(50)
t.circle(100)
t.color("red")
t.circle(150)
t.color("blue")
t.circle(110)
t.turtlesize(40, 40)
t.turtlesize(5, 5)
t.turtlesize(15, 30)
t.turtlesize(1, 1)
t.clear()
t.dot(1, "red")
t.forward(100)
t.dot(10, "red")
t.dot(30, "green")
示例#42
0
turtle.pencolor("purple")
turtle.seth(-40)
turtle.circle(40, 80)
turtle.pencolor("red")
turtle.circle(-40, 80)
turtle.pencolor("blue")
turtle.circle(40, 80)
turtle.pencolor("orange")
turtle.circle(-40, 80)
turtle.pencolor("green")
turtle.circle(40, 80)
turtle.pencolor("yellow")
turtle.circle(-40, 80)
turtle.pencolor("pink")
turtle.circle(-16, 180)
turtle.pencolor("black")
turtle.circle(-16, 180)
turtle.fd(40)
turtle.backward(6)
turtle.pencolor("white")
turtle.pensize(2)
turtle.circle(2, 360)
turtle.circle(6, 360)
turtle.penup()
turtle.fd(20)
turtle.pendown()
turtle.pencolor("red")
turtle.circle(20, 50)
turtle.backward(10)
turtle.circle(-20, 50)
# (Turtle: draw shapes) Write a program that draws a triangle, square, pentagon,
# hexagon, and octagon, as shown in Figure 3.6b. Note that the bottom edges of
# these shapes are parallel to the x-axis. (Hint: For a triangle with a bottom line
# parallel to the x-axis, set the turtle’s heading to 60 degrees.)

import turtle

turtle.penup()
turtle.backward(150)

# triangle
turtle.pendown()
turtle.left(60)
turtle.begin_fill()
turtle.color("red")
turtle.circle(70, steps=3)
turtle.end_fill()

turtle.penup()
turtle.setheading(0)
turtle.forward(130)

# square
turtle.pendown()
turtle.left(45)
turtle.begin_fill()
turtle.color("green")
turtle.circle(70, steps=4)
turtle.end_fill()

turtle.penup()
def drawSprite(turtle, legs, length):
    angle = (360 / legs)
    for i in range (legs):
        turtle.forward(length)
        turtle.backward(length)
        turtle.right(angle)
# (Turtle: draw the Olympic symbol ) Write a program that prompts the user to
# enter the radius of the rings and draws an Olympic symbol of five rings of the
# same size with the colors blue, black, red, yellow, and green, as shown in
# Figure 3.5c.
import turtle as t

r = eval(input("Enetr radius: "))
t.speed(10)
x = t.xcor()

t.penup()
t.backward(200)
t.pendown()
t.pensize(15)

t.color("blue")
t.circle(r)

t.penup()
t.forward(x + r * 2.5)
t.pendown()

t.color("black")
t.circle(r)

t.penup()
t.forward(x + r * 2.5)
t.pendown()

t.color("red")
t.circle(r)
示例#46
0
import turtle

turtle.shape("turtle")
turtle.bgcolor("lightcyan")
turtle.pensize(2)
turtle.shapesize(1)
turtle.speed(2)
turtle.forward(100)
turtle.color("limegreen")
turtle.right(75)
turtle.backward(85)
turtle.left(73)
turtle.color("red")
turtle.circle(100)
turtle.right(100)
turtle.forward(600)

turtle.backward(600)
turtle.left(60)
turtle.forward(300)
turtle.backward(300)
turtle.right(100)
turtle.forward(300)
turtle.backward(300)
turtle.left(67)
turtle.forward(600)
turtle.backward(600)

turtle.penup()
turtle.backward(75)
turtle.pendown()
示例#47
0
    turtle.speed(0)
    turtle.pensize(1.5)

    #zelva kresli celou sit smerem dolů... Aby mela dostatek prostoru a co nejvice ho vyuzila, tak ji
    #na zacatku posunu o 350 pixelu nahoru. Pak se zda byt tak akorat. Testovano na 4K a FullHD monitorech,
    # pri roztazeni okna s zelvi grafikou na celou obrazovku s mercatorem, meritkem 1: 50 000 000 a r = 6371.11.
    # pri tomto nastaveni se cela sit krasne vejde na monitor.
    penup()
    left(90)
    forward(350)
    left(180)
    pendown()
    #nakreslí nultý poledník alias greenwich
    forward(pol_delka)
    backward(pol_delka)
    right(90)

    turtle.pensize(1)

    ### funkce na kresleni poledniku i rovnobezek. Je rozdelena na dve casti, pouzije se podle toho ktera polokoule se zrovna kresli
    ## vstupem je vzdalenost od pocatecni cary (rovnik nebo greenwich), delka poledniku nebo rovnobezky a cislo charakterizujici polokouli
    def jedna_cara(vzdalenost, delka, polokoule):
        if polokoule == 0:
            penup()
            forward(vzdalenost)
            left(90)
            pendown()
            forward(delka)
            backward(delka)
            left(90)
示例#48
0
import turtle

i = 0
j = 0
for j in range(10):
    for i in range(4):
        turtle.forward(j * 10)
        turtle.left(90)
    turtle.penup()
    turtle.right(90)
    turtle.forward(5)
    turtle.left(90)
    turtle.backward(5)
    turtle.pendown()
示例#49
0
def spider(corner_legs):
    turtle.forward(90)
    turtle.stamp()
    turtle.backward(90)
    turtle.left(-corner_legs)
示例#50
0
def backward():
  turtle.backward(move_speed)
示例#51
0
def draw_alphabets():
    ## ---> Make “ABCDE”
    scale = 10
    print(turtle.pos())
    turtle.penup()
    turtle.setpos((-180.0, 0.0))

    ## Letter A
    turtle.pendown()
    # Point upwards to begin
    turtle.left(turtle.heading() + 90)
    turtle.right(20)
    turtle.forward(10 * scale)
    turtle.right(70)
    turtle.forward(1 * scale)
    turtle.right(70)
    turtle.forward(10 * scale)
    turtle.backward(5 * scale)
    turtle.right(90 + 20)
    turtle.forward(4.5 * scale)
    #Move to right of letter and over 1 * scale turtle.up ( )
    turtle.backward(4.5 * scale)
    turtle.left(110)
    turtle.forward(5 * scale)
    turtle.left(70)
    # Shift position
    turtle.penup()
    turtle.forward(2 * scale)
    turtle.pendown()

    ## Letter B
    # Point upwards to begin
    turtle.left(turtle.heading() + 90)
    turtle.forward(10 * scale)
    turtle.right(90)
    turtle.forward(4 * scale)
    turtle.right(90)
    turtle.forward(4 * scale)
    turtle.left(90)
    turtle.backward(1 * scale)
    turtle.forward(3 * scale)
    turtle.right(90)
    turtle.forward(6 * scale)
    turtle.right(90)
    turtle.forward(6 * scale)
    # Move to right of letter turtle.up ( )
    turtle.right(180)
    turtle.forward(6 * scale)
    # Shift position
    turtle.penup()
    turtle.forward(2 * scale)
    turtle.pendown()

    ## Letter C
    # Point upwards to begin
    turtle.left(turtle.heading() + 90)
    turtle.forward(10 * scale)
    turtle.right(90)
    turtle.forward(4 * scale)
    turtle.backward(4 * scale)
    turtle.right(90)
    ## Start
    turtle.forward(10 * scale)
    turtle.left(90)
    turtle.forward(4 * scale)
    # Shift position
    turtle.penup()
    turtle.forward(2 * scale)
    turtle.pendown()

    # Letter D
    turtle.left(90)
    turtle.forward(10 * scale)
    turtle.right(90)
    turtle.forward(4 * scale)
    turtle.right(30)
    turtle.forward(1 * scale)
    turtle.right(60)
    turtle.forward(8.5 * scale)
    turtle.right(30)
    turtle.forward(1.15 * scale)
    turtle.right(60)
    turtle.forward(4.4 * scale)
    turtle.backward(4.4 * scale)
    turtle.right(180)
    # Shift position
    turtle.penup()
    turtle.forward(2 * scale)
    turtle.pendown()

    # Letter E
    turtle.left(90)
    turtle.forward(10 * scale)
    turtle.right(90)
    turtle.forward(5 * scale)
    turtle.backward(5 * scale)
    turtle.right(90)
    turtle.forward(5 * scale)
    turtle.left(90)
    turtle.forward(5 * scale)
    turtle.backward(5 * scale)
    turtle.right(90)
    turtle.forward(5 * scale)
    turtle.left(90)
    turtle.forward(5 * scale)
    turtle.forward(1 * scale)

    turtle.penup()
    print(turtle.pos())
示例#52
0
def peeche():
    turtle.backward(move_speed)
示例#53
0
def curve4():
    for i in range(200):
        t.right(0.8)
        t.backward(1)
示例#54
0
def pra_tras(distancia):
    '''Mover a tartaruga pra trás pela distância dada'''
    turtle.backward(distancia)
示例#55
0
        t.right(0.8)
        t.forward(1)


def curve3():
    for i in range(100):
        t.left(1)
        t.forward(1)


t.penup()
t.goto(0, 50)
t.pendown()
t.begin_fill()
t.fillcolor("#306998")
t.backward(80)
t.left(90)
t.forward(35)
curve()
t.right(19.5)
t.forward(80)
curve2()
t.right(10)
t.forward(50)
curve3()
t.right(100)
t.forward(50)
curve()
t.right(19.5)
t.forward(181)
t.left(90)
示例#56
0
row = int(input('please, Enter no of row: '))
column = int(input('please, Enter no of column: '))
import turtle
turtle.speed(3)
turtle.penup()
for i in range(column):
    for j in range(row):
        turtle.dot()
        turtle.forward(20)
    turtle.backward(20 * row)
    if i == column - 1:
        break
    turtle.right(90)
    turtle.forward(20)
    turtle.left(90)
turtle.exitonclick()
示例#57
0
def to_center():
    turtle.right(360)
    turtle.backward(50)
    turtle.left(90)
    turtle.backward(50)
示例#58
0
def curve6():
    for i in range(100):
        t.left(1)
        t.backward(1)
示例#59
0
t.down()
for x in range(3):
    t.forward(100)
    t.left(120)

t.up()
t.goto(-200,-200)
t.down()
for x in range(5):
    t.forward(100)
    t.left(72)

t.up()
t.goto(200,-200)
t.down()
for x in range(5):
    t.forward(100)
    t.left(144)

t.up()
t.goto(0,0)
t.down()
for x in range(360):
    t.forward(100)
    t.left(1)
    t.backward(100)




示例#60
0
# step 1 : Making Track
turtle.speed(6)
turtle.penup()
turtle.goto(-140, 140)
for step in range(14):
    if step < 13:
        turtle.write(step + 1, align='center')
    else:
        turtle.write("Finish Line")
    turtle.right(90)
    turtle.forward(10)
    turtle.pendown()
    turtle.forward(150)
    turtle.penup()
    turtle.backward(160)
    turtle.left(90)
    turtle.forward(20)
turtle.goto(-190, -50)

# step 2 : Making Turtle

# for red turtle
red = turtle.Turtle()  # turtle.red.color('red') wrong
red.color('red')
red.shape('turtle')

red.penup()
red.goto(-190, 100)
red.pendown()
red.write("Raju")