Exemplo n.º 1
1
def main():
    turtle.setup(1300, 800, 0, 0)   # 启动图形窗口
    pythonsize = 10
    turtle.pensize(pythonsize)
    turtle.pencolor("blue")
    turtle.seth(-40)        # 启动时运动的方向(角度)
    drawSnake(40, 80, 5, pythonsize/2)
Exemplo n.º 2
0
def tree2(iters, xpos, ypos):
	'''Creates lsystem from filename and then creates an arrangement'''
	# creates object from lsystem
	l2 = ls.Lsystem('lsystemextension2.txt')
	
	#number of iterations
	# for growth effect in task 3, made iters a parameter
	num_iter2 = iters
	
	# creates buildstring function
	s2 = l2.buildString(num_iter2)
	
	#specific angle
	angle2 = 30
	
	#creates an object from TI class
	ti = it.TurtleInterpreter()
	
	# sets the colors of the tracer and calls the drawstring function
	# orients the trees  with parameters xpos and ypos
	# My Tree 2 (mylsystem2.txt)
	turtle.pencolor('SandyBrown')
	'''tree with stem color of coral'''
	turtle.up()
	turtle.setposition(xpos,ypos)
	turtle.setheading(90)
	turtle.down()
	ti.drawString(s2,50,angle2)
Exemplo n.º 3
0
def tree1(iters, xpos, ypos):
	'''Creates lsystem from filename and then creates an arrangement'''
	# creates object from lsystem
	l1 = ls.Lsystem('lsystemextension1.txt')
	
	#number of iterations
	# for growth effect in task 3, made iters a parameter
	num_iter1 = iters
	
	#creates buildstring function
	s1 = l1.buildString(num_iter1)
	
	#specific angle
	angle = 15
	
	#creates an object from TI class
	ti = it.TurtleInterpreter()
	
	# sets the colors of the tracer and calls the drawstring function
	# orients the trees with parameters xpos and ypos
	# My Tree 1 (mylsystem1.txt)
	turtle.pencolor('DarkOliveGreen')
	turtle.pensize(2)
	'''tree with stem color of olivedrab'''
	turtle.up()
	turtle.setposition(xpos,ypos)
	turtle.setheading(90)
	turtle.down()
	ti.drawString(s1,7,angle)
Exemplo n.º 4
0
    def drawLine(self,color,coord1,coord2): 
        """
        dessine une ligne entre deux coordonné sur la grille

        :param color: La couleur de la ligne
        :param coord1: La première coordonné en tuple (i,j,"joueur")
        :param coord2: La deuxième coordonné en tuple (i,j,"joueur")
        """
        if coord1[2] == coord2[2] and coord2[2] == "you":
            turtle.goto(38+coord1[1]*25,87-25*coord1[0])
        elif coord1[2] == coord2[2] and coord2[2] == "enemy":
            turtle.goto(-262+(25*coord1[1]),87-25*coord1[0])
        else:
            print('wrong player')
            return 0
        turtle.pensize(20)
        turtle.pencolor(color)
        if coord1[1] == coord2[1]: #Vertical
            turtle.pendown()
            turtle.setheading(270)
            turtle.fd((coord2[0]-coord1[0])*25)
        elif coord1[0] == coord2[0]: #horizontal
            turtle.pendown()
            turtle.setheading(0)
            turtle.fd((coord2[1]-coord1[1])*25)
        else:
            print('Ligne non Hori ou Vert')
            return 0
        turtle.penup()
        return 1
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")
Exemplo n.º 6
0
def main():
	'''Creates lsystem from filename and then creates an arrangement'''
	# creates object from lsystem
	l = ls.Lsystem('lsystemextension2.txt')
	
	#number of iterations
	# for growth effect in task 3, made iters a parameter
	num_iter = 4
	
	
	# creates buildstring function
	s = l.buildString(num_iter)
	
	#specific angle
	angle = 30
	
	#creates an object from TI class
	ti = it.TurtleInterpreter()
	
	# sets the colors of the tracer and calls the drawstring function
	turtle.pencolor('ForestGreen')
	'''tree with stem color of forestgreen'''
	turtle.up()
	turtle.setposition(0,0)
	turtle.setheading(90)
	turtle.down()
	ti.drawString(s, 50 ,angle)
	
	
	
	ti.hold()
Exemplo n.º 7
0
def main():  
    turtle.setup(1300,800,0,0)  
    pythonsize=1  
    turtle.pensize(pythonsize)  
    turtle.pencolor("black")  
    turtle.seth(-40)  
    drawSnack(40,80,5,pythonsize/2)  
Exemplo n.º 8
0
def ejes():
    ####################################
    # Ejes Coordenados                 #
    # los ejes x e y van de -150 a 150 #
    ####################################
    turtle.delay(0)
    turtle.ht()
    turtle.speed(0)
    turtle.pencolor('red')
    turtle.down()
    turtle.fd(301)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.lt(90)
    turtle.fd(300)
    turtle.rt(90)
    turtle.fd(1)
    turtle.rt(90)
    turtle.fd(300)
    turtle.up()
    turtle.pencolor('blue')
Exemplo n.º 9
0
def main():
    turtle.setup(1300, 800, 0, 0)
    pythonsize = 30
    turtle.pensize(pythonsize)
    turtle.pencolor("blue")
    turtle.seth(-40)
    drawSnake(40, 80, 5, pythonsize / 2)
Exemplo n.º 10
0
def drawCircle(x = 0, y = 0, radius = 10, mycolor = (0.49, 0.99, 0.00)): # Lawn Green
    turtle.pencolor(mycolor[0], mycolor[1], mycolor[2])
    turtle.pensize(4)
    turtle.penup()
    turtle.goto(x, y - radius)
    turtle.pendown()
    turtle.circle(radius)
Exemplo n.º 11
0
def tree2(argv, x, y):
	lsys_filename2 = argv[2]
	lsys2 = ls.createLsystemFromFile( lsys_filename2 )
	print lsys2
	num_iter2 = int( 3 )
	dist = float( 5 )
	angle2 = float( 30 )
	
	s2 = ls.buildString( lsys2, num_iter2 )
	
	#draw lsystem2
	'''this is my second lsystem
		with filename mysystem2.txt
		with 5 iterations and
		with angle = 120 dist = 10'''
	turtle.up()
	turtle.goto(0,0)
	turtle.goto(x,y)
	turtle.down()
	turtle.setheading(0)
	turtle.left(90)
	turtle.pencolor('White')
	it.drawString( s2, dist, angle2 )
	
	# wait and update
	turtle.update()
Exemplo n.º 12
0
def skidMark(lineLength):
    turtle.pensize(2)
    turtle.pencolor(0, 0, 0)
    for x in range(lineLength):
        turtle.pencolor(x,x,x)
        turtle.fd(x)
        turtle.right(90)
Exemplo n.º 13
0
def triangle_recursive(n, r,g,b):
    color = (r,g,b)
    turtle.pencolor(color)
    turtle.left(120 + n)
    turtle.forward(600)
    turtle.left(120 + n)
    turtle.forward(600)
    turtle.left(120 + n)
    turtle.forward(600)
    #Change how much n must be less than to change how many times run.
    #Change what adds to n to change the angle change.
    #if n <= .64:
        #triangle_recursive(n + .01)
    if (r > 0 and g > 0) or (r > 0 and b > 0):
        if 255 > g > 0:
            r -= 1
            b += 1
        if 255 > b > 0:
            r -= 1
            g += 1
    elif g > 0 and b > 0:
        if g > 0 and r < 255:
            g -=1
            r +=1
    elif r > 0:
        g += 1
        r -= 1
    triangle_recursive(n + .0001, r, g, b )   
Exemplo n.º 14
0
def sun(argv):
	lsys_filename3 = argv[3]
	lsys3 = ls.createLsystemFromFile( lsys_filename3 )
	print lsys3
	num_iter3 = int( 3 )
	dist = 5
	angle3 = float( 120 )
	
	s3 = ls.buildString( lsys3, num_iter3 )
	
	#draw lsystem3
	'''this is my third lsystem
		with filename mysystem3.txt
		with 3 iterations and
		with angle = 45 dist = 10'''
	turtle.up()
	turtle.goto(0,0)
	turtle.goto(300, 200)
	turtle.down()
	turtle.setheading(0)
	turtle.left(90)
	turtle.pencolor('Red')
	it.drawString( s3, dist, angle3 )
	

	# wait and update
	turtle.update()
Exemplo n.º 15
0
    def draw_path(self, positions):
        '''
        Draws the path given by a position list
        '''

        def position_to_turtle(pos):
            '''Converts a maze position to a turtle position'''
            return (home_x + _DRAW_SIZE * pos[0], home_y - _DRAW_SIZE * pos[1])

        # Get maze size
        width, height = self.size

        # Prepare turtle
        home_x = (-(_DRAW_SIZE * width) / 2) + (_DRAW_SIZE / 2)
        home_y = ((_DRAW_SIZE * height) / 2) - (_DRAW_SIZE / 2)

        turtle.showturtle()
        turtle.pencolor(_DRAW_PATH)

        # Move to star
        turtle.penup()
        turtle.goto(home_x, home_y)
        turtle.pendown()

        # Draw the path
        for pos in positions:
            turtle.goto(position_to_turtle(pos))
Exemplo n.º 16
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)
Exemplo n.º 17
0
 def drawIt(backAgain):
     turtle.penup()
     turtle.setpos(0,vertHeight)
     turtle.pendown()
     upDown = True
     start = turtle.xcor()
     for i in range(iterLength):
         randomyUpDownVariance = randint(1,55)
         randomyBetweenLineVariance = randint(1,25)
         randPenSize = randint(2,10)
         randPenColor1 = randint(1,187)
         randPenColor2 = randint(1,193)
         randPenColor3 = randint(1,182)
         turtle.pensize(randPenSize)
         print turtle.xcor()
         tup = (randPenColor1, randPenColor2, randPenColor3)
         turtle.pencolor(tup)
         if upDown == True:
             upDown = False
             turtle.goto(start, (vertHeight + randomyUpDownVariance))
         elif upDown == False:
             upDown = True
             turtle.goto(start, -(vertHeight + randomyUpDownVariance))
         if backAgain == True:
             start -= randomyBetweenLineVariance
         elif backAgain == False:
             start += randomyBetweenLineVariance
     if (backAgain == True):
         drawIt(False)
Exemplo n.º 18
0
def tree1(argv, x, y):
	lsys_filename1 = argv[1]
	lsys1 = ls.createLsystemFromFile( lsys_filename1 )
	print lsys1
	num_iter1 = int( 3 )
	dist = float( 5 )
	angle1 = float( 22 )
	
	s1 = ls.buildString( lsys1, num_iter1 )
	
	#draw lsystem1
	'''this is my first lsystem
		with filename mysystem1.txt
		with 3 iterations and
		with angle = 45 dist = 10'''
	turtle.tracer(False)
	turtle.speed(50000000)
	turtle.up()
	turtle.goto(0,0)
	turtle.goto(x, y)
	turtle.down()
	turtle.pencolor('White')
	it.drawString( s1, dist, angle1 )
	
	# wait and update
	turtle.update()
Exemplo n.º 19
0
def turmandel(step, zoom, xres, yres, xthresh, ythresh):
  turtle.setheading(0)
  for y in range(yres):
    turtle.pu()
    turtle.setpos(0, y)
    turtle.pd()
    for x in range(xres):
      x = float(x)
      y = float(y)
      u = float(x)/float((xres/zoom))-xthresh
      v = float(y)/float((yres/zoom))-ythresh
      x0 = float(u)
      y0 = float(v)
      a = 0.0
      b = 0.0
      i = step
      while ((i>0) and (a+b<=4.0)):
        a = float(x0*x0)
        b = float(y0*y0)
        y0 = float(2.0*x0*y0+v)
        x0 = float(a-b+u)
        i = i - 1
      color = i % 255
      turtle.pencolor((color, color, color))
      if i < 1:
        turtle.pencolor((0,0,0))
      turtle.fd(1)
Exemplo n.º 20
0
def random_col():
    x=r.randint(100,250)
    y=r.randint(180,250)
    z=r.randint(200,255)
    t.pencolor(x,y,z)
    t.fillcolor(z,x,y)
    return
Exemplo n.º 21
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)
Exemplo n.º 22
0
def base(color = 'blue',colors = colors, lato = lato, unit = unit, alfa = alfa, depth = depth, height = height):
    turtle.pencolor(colors[color])
    turtle.fillcolor(color)
    turtle.begin_fill()
    turtle.forward(unit*lato)
    turtle.left(alfa)
    turtle.forward(depth*lato)
    turtle.left(alfa)
    turtle.forward(height)
    turtle.left(90+alfa)
    turtle.forward(depth*lato)
    turtle.left(alfa)
    turtle.forward(height)
    turtle.backward(height)
    turtle.right(90)
    turtle.forward(lato*unit)
    turtle.left(90)
    turtle.forward(height)
    turtle.right(180)
    turtle.forward(height)
    turtle.right(alfa)
    turtle.forward(depth*lato)
    turtle.right(alfa)
    turtle.forward(lato*unit)
    turtle.left(alfa)
    turtle.backward(depth*lato)
    turtle.right(alfa)
    turtle.backward(unit*lato)
    turtle.end_fill()
    line_base()
Exemplo n.º 23
0
def drawFace(x=200, y=200, face=500):
    turtle.pendown()
    colour = random.choice(faceColors)
    drawHead(face, colour)    # Instruct python to use or method "drawSquare"
    turtle.penup()            # space things out before drawing the next Square
    turtle.setposition(x-face/18,y-face/9)

    turtle.pendown()
    turtle.pencolor("black")
    if(colour == "green"):
        drawCrossEye(face/8)
    else:
        drawRoundEye(face/16) 
    
    turtle.penup()            # space things out before drawing the next Square
    turtle.setposition(x+face/18,y-face/9)

    turtle.pendown()
    if(colour == "green"):
        drawCrossEye(face/8)
    else:
        drawRoundEye(face/16) 
    

    turtle.penup()            # space things out before drawing the next Square
    turtle.setposition(x+face/11,y-face/5.5)

    turtle.pendown()
    turtle.setheading(270)
    drawMouth(face/4)
    turtle.penup()
Exemplo n.º 24
0
def draw_move(turtle, cell_size, offset, domino, dx, dy, move_num, step_count):
    shade = (move_num-1) * 1.0/step_count
    rgb = (0, 1-shade, shade)
    turtle.forward((domino.head.x-offset[0]) * cell_size)
    turtle.left(90)
    turtle.forward((domino.head.y-offset[1]) * cell_size)
    turtle.right(90)
    turtle.setheading(domino.degrees)
    turtle.forward(cell_size*.5)
    turtle.setheading(math.atan2(dy, dx) * 180/math.pi)
    pen = turtle.pen()
    turtle.pencolor(rgb)
    circle_pos = turtle.pos()
    turtle.width(4)
    turtle.forward(cell_size*0.05)
    turtle.down()
    turtle.forward(cell_size*0.4)
    turtle.up()
    turtle.pen(pen)
    turtle.setpos(circle_pos)
    turtle.forward(8)
    turtle.setheading(270)
    turtle.forward(8)
    turtle.left(90)
    turtle.down()
    turtle.pencolor(rgb)
    turtle.fillcolor('white')
    turtle.begin_fill()
    turtle.circle(8)
    turtle.end_fill()
    turtle.pen(pen)
    turtle.write(move_num, align='center')
    turtle.up()
def drawTree(x,t,Max,houseLoc):
    global count
    if(t=='Maple'):
        trunkLen=random.uniform(50,150)
        trunk(trunkLen)
        turtle.pencolor("green")
        turtle.circle(20,360)
        turtle.pencolor("black")
        turtle.right(90)
        netHeight=trunkLen+60
        Max.append(netHeight)
        if(count<x):
            InitPos(trunkLen)
        else:
            turtle.penup()
            turtle.forward(trunkLen)
            turtle.left(90)
        if(count==houseLoc):
            buildHouse()
            count=count+1
        else:
            count=count+1
            return count

    elif(t=='Pine'):
        trunkLen=random.uniform(50,200)
        trunk(trunkLen)
        triangle()
        turtle.right(90)
        netHeight=trunkLen+17.3
        Max.append(netHeight)
        if(count<x):
            InitPos(trunkLen)
        else:
            turtle.penup()
            turtle.forward(trunkLen)
            turtle.left(90)
        if(count==houseLoc):
            buildHouse()
            count=count+1
        else:
            count=count+1

    else:
        trunkLen=random.uniform(50,200)
        trunk(trunkLen)
        DifferentShape()
        netHeight=trunkLen+20
        Max.append(netHeight)
        if(count<x):
            InitPos(trunkLen)
        else:
            turtle.penup()
            turtle.forward(trunkLen)
            turtle.left(90)
        if(count==houseLoc):
            buildHouse()
            count=count+1
        else:
            count=count+1
Exemplo n.º 26
0
def main():
	turtle.setup(1300, 800, 0, 0)
	pythonsize = 30
	turtle.pensize(pythonsize)
	turtle.pencolor('blue')
	turtle.seth(-40)
	drawSnake(rad = 40, angle = 80, len = 5, neckrad = pythonsize/2 )
Exemplo n.º 27
0
def main():
    """
    Tous les phase du battleship passe par le main()
    et il sert de boucle principal car il est appelé à
    tous les 0.5 secondes
    """
    if i.phase == "PlaceShip":
        i.placeShip()
    elif i.phase == "Attack": # Nom fictif
        i.attack()
    elif i.phase == "win":
        print('Vous avez gagné!')
        turtle.goto(0,0)
        turtle.pencolor('black')
        turtle.write('Vous avez gagné!',align="center",font=("Arial",70, "normal"))
        i.phase = "exit"
    elif i.phase == "lose":
        print('Vous avez perdu!')
        turtle.goto(0,0)
        turtle.pencolor('black')
        turtle.write('Vous avez perdu!',align="center",font=("Arial",70, "normal"))
        i.phase = "exit"
    elif i.phase == "exit":
        turtle.exitonclick()
        return None
    else:
        print('out')

    turtle.ontimer(main,500)
Exemplo n.º 28
0
	def choix_couleur(self):
		#choix d'une couleur pour le triangle
		self.choix = random.randint(0, len(COULEURS)-1)
		self.couleur1 = COULEURS[self.choix]
		self.choix = random.randint(0, len(COULEURS)-1)
		self.couleur2 = COULEURS[self.choix]
		tt.pencolor(self.couleur1)
		tt.fillcolor(self.couleur2)
Exemplo n.º 29
0
def changeColor():
	global currentColor
	turtle.pencolor(colorList[currentColor])
	turtle.fillcolor(colorList[currentColor])
	if(currentColor >= len(colorList)-1):
		currentColor = 0
	else:
		currentColor += 1
Exemplo n.º 30
0
def nUhelnik(strana=100, n=6, barva="#000000"):
    aktual = t.pencolor()
    t.pencolor(barva)
    uhel = 360.0 / n
    for _ in range(n):
        t.forward(strana)
        t.right(uhel)
    t.pencolor(aktual)
Exemplo n.º 31
0
'''描述
使用turtle库,绘制一个正方形。‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬'''

import turtle
turtle.penup()
turtle.bk(100)
turtle.pendown()
turtle.width(3)
turtle.pencolor("blue")
for i in range(4):
    turtle.fd(100)
    turtle.left(90)
turtle.done()
Exemplo n.º 32
0
turtle.left(90)
turtle.forward(75)
turtle.left(90)
turtle.forward(75)
turtle.left(90)
turtle.forward(75)
turtle.left(90)
turtle.penup()
turtle.goto(25, 0)
turtle.write("s= 75")
turtle.penup()
turtle.goto(80, 35)
turtle.write("s= 75")

turtle.color("blue")
turtle.pencolor("black")
turtle.begin_fill()
turtle.pen()
turtle.penup()
turtle.goto(200, -5)
turtle.pendown()
turtle.circle(45)
turtle.left(90)
turtle.forward(45)
turtle.write("r=45")

d = turtle
d.bgcolor("silver")
d.color("dark blue")
d.pencolor("white")
d.begin_fill()
Exemplo n.º 33
0
import turtle  # 引入海龟库
from typing import List
screenLocation: List[int] = [1000, 550, 480, 300]  #定义海归画布参数
penColor: List[int] = [212, 222, 2]  #定义画笔颜色

turtle.setup(screenLocation[0], screenLocation[1], screenLocation[2],
             screenLocation[3])  # 宽度、高度、相对屏幕左上角X坐标,相对屏幕左上角Y坐标
turtle.penup()  # 画笔抬起
turtle.forward(-450)
turtle.pendown()  # 落笔,开始绘制
turtle.pensize(15)  # 设置画笔宽度 别名width
turtle.colormode(255)  # 改变GRB模式为255制
turtle.pencolor(penColor)  # 颜色名称,或者RGB数值
turtle.setheading(-40)  # 改变爬行角度  为绝对角度别名seth
for i in range(5):  #循环4次  如果是M,N则是从产生从M,到N-1个数值
    turtle.circle(
        50, 90
    )  #根据半径r绘制extent角度的弧形  正数为海龟左侧半径r处为原点,负数为海龟右侧半径r为原点;如果有角度参数则右转参数角度,默认360度。
    turtle.circle(-40, 90)
turtle.circle(40, 80 / 2)
turtle.forward(40)  # 前进  别名fd  如果是负数,则为倒退
turtle.circle(16, 180)
turtle.forward(40 * 2 / 3)
turtle.done()  #完成后窗体不退出
Exemplo n.º 34
0
import turtle

turtle.screensize(800,600,"green")#设置画布宽,高,背景色
turtle.pencolor("white")#画笔颜色
turtle.circle(50)#画圆,50表示半径,且圆心在画笔左边
turtle.done()

Exemplo n.º 35
0
'''
自动轨迹绘制
1、定义数据文件格式(接口)
2、编写程序,根据文件接口解析参数绘制图形
3、编制数据文件
'''
#autotracedraw.py
import turtle as t
t.title('自动绘制')
t.setup(800, 600, 0, 0)  #绘制窗口的大小
t.pencolor("red")  #画笔的初始颜色
t.pensize(5)  #画笔的大小
#数据文件的读取
datals = []
f = open("data.txt")
for line in f:
    line = line.replace("\n", "")
    datals.append(list(map(eval, line.split(","))))
    #list map eval 作用是去掉字符串中的引号
    #f.close()

#自动绘制
for i in range(len(datals)):
    t.pencolor(datals[i][3], datals[i][4], datals[i][5])
    t.fd(datals[i][0])  #表示一行的第一个元素表示行进距离
    if datals[i][1]:
        t.right(datals[i][2])
    else:
        t.left(datals[i][2])
f.close()
Exemplo n.º 36
0
import turtle
meep = turtle.clone()
turtle.bgcolor('purple')
turtle.pencolor('yellow')
turtle.width(4)
turtle.shape('circle')
turtle.left(90)
turtle.goto(0, 150)
turtle.left(90)
turtle.forward(75)
turtle.color('white')
turtle.left(90)
turtle.forward(150)
meep.pencolor('green')
meep.shape('arrow')
meep.width(7)
meep.right(90)
meep.forward(150)
meep.left(90)
meep.forward(75)
meep.color('blue')
meep.left(90)
meep.forward(150)

turtle.mainloop()
Exemplo n.º 37
0
def drow():

    t.screensize(400, 300, "#fff")
    t.pensize(4)  # 设置画笔的大小
    t.colormode(255)  # 设置GBK颜色范围为0-255
    t.color((255, 155, 192), "pink")  # 设置画笔颜色和填充颜色(pink)
    t.setup(840, 500)  # 设置主窗口的大小为840*500
    t.speed(20)  # 设置画笔速度为10
    # 鼻子
    t.pu()  # 提笔
    t.goto(-100, 100)  # 画笔前往坐标(-100,100)
    t.pd()  # 下笔
    t.seth(-30)  # 笔的角度为-30°
    t.begin_fill()  # 外形填充的开始标志
    a = 0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            a = a + 0.08
            t.lt(3)  # 向左转3度
            t.fd(a)  # 向前走a的步长
        else:
            a = a - 0.08
            t.lt(3)
            t.fd(a)
    t.end_fill()  # 依据轮廓填充
    t.pu()  # 提笔
    t.seth(90)  # 笔的角度为90度
    t.fd(25)  # 向前移动25
    t.seth(0)  # 转换画笔的角度为0
    t.fd(10)
    t.pd()
    t.pencolor(255, 155, 192)  # 设置画笔颜色
    t.seth(10)
    t.begin_fill()
    t.circle(5)  # 画一个半径为5的圆
    t.color(160, 82, 45)  # 设置画笔和填充颜色
    t.end_fill()
    t.pu()
    t.seth(0)
    t.fd(20)
    t.pd()
    t.pencolor(255, 155, 192)
    t.seth(10)
    t.begin_fill()
    t.circle(5)
    t.color(160, 82, 45)
    t.end_fill()
    # 头
    t.color((255, 155, 192), "pink")
    t.pu()
    t.seth(90)
    t.fd(41)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.begin_fill()
    t.seth(180)
    t.circle(300, -30)  # 顺时针画一个半径为300,圆心角为30°的园
    t.circle(100, -60)
    t.circle(80, -100)
    t.circle(150, -20)
    t.circle(60, -95)
    t.seth(161)
    t.circle(-300, 15)
    t.pu()
    t.goto(-100, 100)
    t.pd()
    t.seth(-30)
    a = 0.4
    for i in range(60):
        if 0 <= i < 30 or 60 <= i < 90:
            a = a + 0.08
            t.lt(3)  # 向左转3度
            t.fd(a)  # 向前走a的步长
        else:
            a = a - 0.08
            t.lt(3)
            t.fd(a)
    t.end_fill()
    # 耳朵
    t.color((255, 155, 192), "pink")
    t.pu()
    t.seth(90)
    t.fd(-7)
    t.seth(0)
    t.fd(70)
    t.pd()
    t.begin_fill()
    t.seth(100)
    t.circle(-50, 50)
    t.circle(-10, 120)
    t.circle(-50, 54)
    t.end_fill()
    t.pu()
    t.seth(90)
    t.fd(-12)
    t.seth(0)
    t.fd(30)
    t.pd()
    t.begin_fill()
    t.seth(100)
    t.circle(-50, 50)
    t.circle(-10, 120)
    t.circle(-50, 56)
    t.end_fill()
    # 眼睛
    t.color((255, 155, 192), "white")
    t.pu()
    t.seth(90)
    t.fd(-20)
    t.seth(0)
    t.fd(-95)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill()
    t.color((255, 155, 192), "white")
    t.pu()
    t.seth(90)
    t.fd(-25)
    t.seth(0)
    t.fd(40)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill()
    # 腮
    t.color((255, 155, 192))
    t.pu()
    t.seth(90)
    t.fd(-95)
    t.seth(0)
    t.fd(65)
    t.pd()
    t.begin_fill()
    t.circle(30)
    t.end_fill()
    # 嘴
    t.color(239, 69, 19)
    t.pu()
    t.seth(90)
    t.fd(15)
    t.seth(0)
    t.fd(-100)
    t.pd()
    t.seth(-80)
    t.circle(30, 40)
    t.circle(40, 80)
    # 身体
    t.color("red", (255, 99, 71))
    t.pu()
    t.seth(90)
    t.fd(-20)
    t.seth(0)
    t.fd(-78)
    t.pd()
    t.begin_fill()
    t.seth(-130)
    t.circle(100, 10)
    t.circle(300, 30)
    t.seth(0)
    t.fd(230)
    t.seth(90)
    t.circle(300, 30)
    t.circle(100, 3)
    t.color((255, 155, 192), (255, 100, 100))
    t.seth(-135)
    t.circle(-80, 63)
    t.circle(-150, 24)
    t.end_fill()
    # 手
    t.color((255, 155, 192))
    t.pu()
    t.seth(90)
    t.fd(-40)
    t.seth(0)
    t.fd(-27)
    t.pd()
    t.seth(-160)
    t.circle(300, 15)
    t.pu()
    t.seth(90)
    t.fd(15)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.seth(-10)
    t.circle(-20, 90)
    t.pu()
    t.seth(90)
    t.fd(30)
    t.seth(0)
    t.fd(237)
    t.pd()
    t.seth(-20)
    t.circle(-300, 15)
    t.pu()
    t.seth(90)
    t.fd(20)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.seth(-170)
    t.circle(20, 90)
    # 脚
    t.pensize(10)
    t.color((240, 128, 128))
    t.pu()
    t.seth(90)
    t.fd(-75)
    t.seth(0)
    t.fd(-180)
    t.pd()
    t.seth(-90)
    t.fd(40)
    t.seth(-180)
    t.color("black")
    t.pensize(15)
    t.fd(20)
    t.pensize(10)
    t.color((240, 128, 128))
    t.pu()
    t.seth(90)
    t.fd(40)
    t.seth(0)
    t.fd(90)
    t.pd()
    t.seth(-90)
    t.fd(40)
    t.seth(-180)
    t.color("black")
    t.pensize(15)
    t.fd(20)
    # 尾巴
    t.pensize(4)
    t.color((255, 155, 192))
    t.pu()
    t.seth(90)
    t.fd(70)
    t.seth(0)
    t.fd(95)
    t.pd()
    t.seth(0)
    t.circle(70, 20)
    t.circle(10, 330)
    t.circle(70, 30)
    t.done()
Exemplo n.º 38
0
from turtle import penup, dot, forward, exitonclick, backward, left, right
from turtle import pencolor, home, setposition, heading, circle, speed, pendown

speed(0)

vzdalenost_tecek = 30  # vzdalenost tecek od sebe
sirka = 10  # pocet tecek na radku/sloupci
pencolor('red')
penup()

for i in range(sirka):
    for j in range(sirka):
        dot()
        forward(vzdalenost_tecek)
    backward(vzdalenost_tecek * sirka)
    right(90)
    forward(vzdalenost_tecek)
    left(90)

home()
pendown()
pencolor('green')
for k in range(50):
    forward(100)
    left(123)
pencolor('blue')
for l in range(70):
    forward(80)
    left(100)
penup()
Exemplo n.º 39
0
import turtle as tt
from random import randint

tt.TurtleScreen._RUNNING = True
tt.speed(0)
tt.bgcolor("black")
tt.setpos(-25, 25)
tt.colormode(255)
cnt = 0
while cnt < 1000:
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    tt.pencolor(r, g, b)
    tt.forward(50 + cnt)
    tt.right(91)
    cnt += 1
tt.done()
Exemplo n.º 40
0
    drawSnakeHead(lengths[0])
    for i in range(1, len(lengths) - 1, 2):
        drawTwistUpSegment(lengths[i])
        drawTwistDownSegment(lengths[i + 1])

turtle.pensize(4)
# Draw the snakes:
for i in range(10):
    # Go to the starting position:
    turtle.penup()
    turtle.goto(random.randint(-400, 400), random.randint(-400, 400))
    turtle.pendown()
    turtle.setheading(random.randint(0, 360))

    # Set up the snake coloration:
    turtle.pencolor(random.choice(SNAKE_COLORS))

    redAmount = random.randint(0, 100) / 100.0
    greenAmount = random.randint(0, 100) / 100.0
    blueAmount = random.randint(0, 100) / 100.0
    # (!) Uncomment the following line to use random colors.
    #turtle.pencolor(redAmount, greenAmount, blueAmount)

    turtle.fillcolor(turtle.pencolor())

    # Draw the snake:
    lengths = []
    # Each snake has a random amount of segments:
    for j in range(random.randint(6, 12)):
        # Each segment has random lengths:
        lengths.append(random.randint(40, 150))
Exemplo n.º 41
0
 def set_pencolor(self, color):
     from turtle import pencolor
     pencolor(color)
Exemplo n.º 42
0
# 使用turtle库画出一条蟒蛇

# 引入turtle标准库
import turtle

# setup(width, height, startx, starty)确定绘图窗体宽高和初始位置
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize()
turtle.pencolor('purple')
turtle.seth(-40)
for i in range(4):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.circle(40, 80 / 2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
turtle.down()
Exemplo n.º 43
0
import  turtle
#中国国旗
turtle.up()
turtle.goto(-200,200)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("red")
turtle.pencolor("red")
for i in range(2):
    turtle.forward(280)
    turtle.right(90)
    turtle.forward(200)
    turtle.right(90)
turtle.end_fill()
 
turtle.up()
turtle.goto(-170,145)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
turtle.pencolor("yellow")
for x in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
 
turtle.up()
turtle.goto(-100,180)
turtle.down()
turtle.begin_fill()
turtle.fillcolor("yellow")
Exemplo n.º 44
0
#e2.1drawpython.py
import turtle
turtle.setup(650, 300, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pencolor("green")
turtle.pendown()
turtle.pensize(25)
turtle.pencolor('blue')
turtle.seth(-40)
for i in range(4):
    turtle.circle(40, 80)
    turtle.pencolor("pink")
    turtle.circle(-40, 80)
    turtle.pencolor("yellow")
turtle.circle(40, 80 / 2)
turtle.fd(40)
turtle.pencolor("red")
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
Exemplo n.º 45
0
import turtle

turtle.bgcolor('black')
colors = ['blue', 'yellow', 'red', 'white', 'orange']
turtle.speed(0)
for i in range(280):
    turtle.pencolor(colors[i % 5])
    turtle.pensize(i / 88 + 1)
    turtle.forward(i)
    turtle.left(59)
turtle.done()
Exemplo n.º 46
0
def line(startX, startY, endX, endY, color):
    turtle.penup()  # Поднять перо.
    turtle.goto(startX, startY)  # Переместить в начальную точку.
    turtle.pendown()  # Опустить перо.
    turtle.pencolor(color)  # Задать цвет заливки.
    turtle.goto(endX, endY)  # Нарисовать треугольник.
tu.hideturtle()
tu.speed(0)
tu.screensize(500, 500)
tu.penup()

def erasableWrite(tortoise, name, font, align, reuse=None):
    eraser = tu.Turtle() if reuse is None else reuse
    eraser.hideturtle()
    eraser.up()
    eraser.setposition(tortoise.position())
    eraser.write(name, font=font, align=align)
    return eraser


tu.goto(-250, -250)
tu.pencolor(0.9, 0.9, 0.9)
tu.pendown()
for i in range(4): 
    tu.forward(500) 
    tu.left(90)


tu.penup()
shifts = 250
while shifts > 0:
    x, y = rand.randint(-250, 250), rand.randint(-250, 250)
    tu.goto(x,y)
    tu.pencolor('blue')
    tu.dot(3)
    shifts -= 1
Exemplo n.º 48
0
import turtle

swidth, sheight = 500, 500

turtle.title('무지개색 원그리기')
turtle.shape('turtle')
turtle.setup(width=swidth + 50, height=sheight + 50)
turtle.screensize(swidth, sheight)
turtle.penup()
turtle.goto(0, -sheight / 2)
turtle.pendown()
turtle.speed(10)

for radius in range(1, 250):
    if radius % 7 == 1:
        turtle.pencolor('red')
    elif radius % 7 == 2:
        turtle.pencolor('orange')
    elif radius % 7 == 3:
        turtle.pencolor('yellow')
    elif radius % 7 == 4:
        turtle.pencolor('green')
    elif radius % 7 == 5:
        turtle.pencolor('blue')
    elif radius % 7 == 6:
        turtle.pencolor('navyblue')
    else:
        turtle.pencolor('purple')

    turtle.circle(radius)
Exemplo n.º 49
0
#전역 변수 선언 부분
swidth, sheight, pSize, exitCount = 300, 300, 3, 0
r,g,b,angle, dist, curX, curY = [0]*7

#메인 코드 부분
turtle.title('거북이가 맘대로 다니기')
turtle.shape('turtle')
turtle.pensize(pSize)
turtle.setup(width=swidth + 30, height=sheight + 30)
turtle.screensize(swidth, sheight)

while True :
    r=random.random()
    g=random.random()
    b=random.random()
    turtle.pencolor((r,g,b))
    
    angle = random.randrange(0,360)
    dist = random.randrange(1,100)
    turtle.left(angle)
    turtle.forward(dist)
    curX=turtle.xcor()
    curY=turtle.ycor()
    
    if(-swidth/2<=curX and curX <= swidth/2) and (-sheight/2 <= curY and curY<=sheight/2):
        pass
    else:
        turtle.penup()
        turtle.goto(0,0)
        turtle.pendown()
        
Exemplo n.º 50
0
#画蟒蛇
import turtle
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.circle(40, 80 / 2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2 / 3)
Exemplo n.º 51
0
   if 0<=i<30 or 60<=i<90:
       a=a+0.08
       t.lt(3) #向左转3度
       t.fd(a) #向前走a的步长
   else:
       a=a-0.08
       t.lt(3)
       t.fd(a)
t.end_fill() # 依据轮廓填充
t.pu() # 提笔
t.seth(90) # 笔的角度为90度
t.fd(25) # 向前移动25
t.seth(0) # 转换画笔的角度为0
t.fd(10)
t.pd()
t.pencolor(255,155,192) # 设置画笔颜色
t.seth(10)
t.begin_fill()
t.circle(5) # 画一个半径为5的圆
t.color(160,82,45) # 设置画笔和填充颜色
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
Exemplo n.º 52
0
OUTPUT_FILE = 'picture.h'  # modify this line
TEMP_FILE = 'temp'
drawing = svgwrite.Drawing(TEMP_FILE + '.svg', size=("500px", "500px"))
drawing.add(drawing.rect(fill='white', size=("100%", "100%")))
t = SvgTurtle(drawing)
tt.Turtle._screen = t.screen
tt.Turtle._pen = t

############################
# draw your picture below  #
############################

tt.fillcolor('blue')
tt.begin_fill()
for i in range(20):
    d = 50 + i * i * 1.5
    tt.pencolor(0, 0.05 * i, 0)
    tt.width(i)
    tt.forward(d)
    tt.right(144)
tt.end_fill()

############################
# draw your picture above  #
############################
drawing.save()
drawing = svg2rlg(TEMP_FILE + ".svg")
renderPM.drawToFile(drawing, TEMP_FILE + ".png", fmt="PNG")
#cairosvg.svg2png(url=TEMP_FILE + '.svg', write_to=TEMP_FILE + '.png')
stripe.picture2Lines(TEMP_FILE + '.png', OUTPUT_FILE, 64)
Exemplo n.º 53
0
#e2.1DrawPython.py
import turtle

turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("red")
turtle.seth(-40)
for i in range(1):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
turtle.pencolor("orange")
turtle.seth(-40)
for i in range(1):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)

turtle.pencolor("yellow")
turtle.seth(-40)
for i in range(1):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)

turtle.pencolor("green")
turtle.seth(-40)
for i in range(1):
    turtle.circle(40, 80)
    turtle.circle(-40, 80)
Exemplo n.º 54
0
def main():
    turtle.pensize(2)
    turtle.pencolor("black")
    turtle.up()
    turtle.left(180)
    turtle.fd(50)
    turtle.left(90)
    turtle.fd(200)
    turtle.right(180)
    turtle.down() #all getting into starting position to draw card
    drawCard() #draws first card
    turtle.fd(140)
    turtle.left(90)
    turtle.fd(140)
    turtle.right(90) #centers turtle in order to write letter or number in center
    turtle.down()
    turtle.pencolor("red")
    turtle.write("K", align="center", font=( "Arial", 100, "bold")) #writes K
    turtle.up()
    turtle.fd(200)
    turtle.left(90)
    turtle.fd(120)
    turtle.right(90) #moves to top right corner to draw first diamond
    turtle.fillcolor("red")
    drawDiamond() #draws first diamond
    turtle.right(90)
    turtle.fd(240)
    turtle.right(90)
    turtle.fd(330)
    turtle.right(180)#moves to bottom left corner to draw second diamond
    drawDiamond() #draws second diamond
    turtle.right(180)
    turtle.fd(10)
    turtle.left(90)
    turtle.fd(390)
    turtle.left(90)#moves into position to draw second card
    turtle.down()
    turtle.pencolor("black") #change pen back to black
    drawCard() #draws second card
    turtle.fd(140)
    turtle.left(90)
    turtle.fd(140)
    turtle.right(90)  # centers turtle in order to write letter or number in center
    turtle.down()
    turtle.write("8", align="center", font=("Arial", 100, "bold"))  # writes 8
    turtle.up()
    turtle.fd(190)
    turtle.left(90)
    turtle.fd(100)
    turtle.right(90) #moves turtle to top right to draw first heart
    turtle.fillcolor("black")
    drawTriangle() #draws bottom of heart
    turtle.fd(40)
    drawCircle() #draws left bump of heart
    turtle.right(90)
    turtle.fd(20)
    turtle.left(90) #moves to right to do second bump on heart
    drawCircle() #draws second bump of heart
    turtle.right(90)
    turtle.fd(180)
    turtle.right(90)
    turtle.fd(350)
    turtle.right(180)
    drawTriangle()  # draws bottom of heart
    turtle.fd(40)
    drawCircle()  # draws left bump of heart
    turtle.right(90)
    turtle.fd(20)
    turtle.left(90)  # moves to right to do second bump on heart
    drawCircle()  # draws second bump of heart
    turtle.done()
Exemplo n.º 55
0
turtle.circle(35, steps=3)

# input("Wait")

turtle.colormode(255)
turtle.penup()
turtle.goto(0, 150)
turtle.pensize(12)
turtle.pendown()
# Ignore this line
for _ in range(36):
    turtle.forward(35)
    turtle.right(10)
    turtle.pensize(randrange(100))
    turtle.pencolor(randrange(255), randrange(255), randrange(255))

turtle.done()

# Math with dates in datetime - https://docs.python.org/3/library/datetime.html
from datetime import datetime

currentTime = datetime.now()
hour = currentTime.hour

print(hour + 9 % 12, ':', currentTime.minute, ':', currentTime.second)
"""
	Case Study
	- Compute the Distance between two points.with Turtle
"""
Exemplo n.º 56
0
def draw_pen(width, height, startX, startY, pen_size):
    turtle.setup(width, height, startX, startY)
    turtle.penup()
    turtle.pendown()
    turtle.pensize(pen_size)
    turtle.pencolor("red")
Exemplo n.º 57
0
"""

用turtle模塊繪圖
這是一個非常有趣的模塊 它模擬一隻烏龜在窗口上爬行的方式來進行繪圖

Version: 0.1
Author: 駱昊
Date: 2018-03-14

"""

import turtle

turtle.pensize(3)
turtle.penup()
turtle.goto(-180, 150)
turtle.pencolor('red')
turtle.fillcolor('yellow')
turtle.pendown()
turtle.begin_fill()
for _ in range(36):
    turtle.forward(200)
    turtle.right(170)
turtle.end_fill()
turtle.mainloop()
Exemplo n.º 58
0
#RoseDraw.py
import turtle as t


# 定义一个曲线绘制函数
def DegreeCurve(n, r, d=1):
    for i in range(n):
        t.left(d)
        t.circle(r, abs(d))


# 初始位置设定
s = 0.2  # size
t.setup(450 * 5 * s, 750 * 5 * s)
t.pencolor("black")
t.fillcolor("red")
t.speed(10000)
t.penup()
t.goto(0, 900 * s)
t.pendown()
# 绘制花朵形状
t.begin_fill()
t.circle(200 * s, 30)
DegreeCurve(60, 50 * s)
t.circle(200 * s, 30)
DegreeCurve(4, 100 * s)
t.circle(200 * s, 50)
DegreeCurve(50, 50 * s)
t.circle(350 * s, 65)
DegreeCurve(40, 70 * s)
t.circle(150 * s, 50)
# coding: utf-8

# In[1]:

import turtle
turtle.setup(1000, 600, 100, 100)
turtle.penup()
turtle.fd(-300)
turtle.pendown()
turtle.pensize(28)
turtle.pencolor("silver")
turtle.seth(-50)
for i in range(6):
    turtle.circle(50, 60)
    turtle.pencolor("azure")
    turtle.circle(-50, 60)
    turtle.pencolor("pink")
turtle.circle(50, 60 / 2)
turtle.fd(50)
turtle.circle(25, 180)
turtle.pencolor("rubine")
turtle.fd(50 * 2 / 3)
Exemplo n.º 60
0
inicioB = 10
inicio2B =10
inicioBien = 10

turtle.title('ADN')
turtle.setup(1530, 1000, 0, 0)
turtle.screensize(20,8000)
turtle.hideturtle()
turtle.penup()
turtle.goto(-10,-40)
turtle.write("Arreglo 5'",False,"left",("arial", 20, "bold italic"))
turtle.goto(-200,-40)
turtle.write("Errores",False,"left",("arial", 20, "bold italic"))
turtle.goto(-500,300)
turtle.pencolor('red')
turtle.write("Adenina",False,"left",("arial", 18, "bold italic"))
turtle.goto(-500,250)
turtle.pencolor('blue')
turtle.write("Guanina",False,"left",("arial", 18, "bold italic"))
turtle.goto(-500,200)
turtle.pencolor('green')
turtle.write("Timina",False,"left",("arial", 18, "bold italic"))
turtle.goto(-500,150)
turtle.pencolor('yellow')
turtle.write("Citocina",False,"left",("arial", 18, "bold italic"))

#Simulo el ADN
for x in range(5):
#Creo el 5' 
    n1 = posiAT[randrange(10)]