• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.pencolor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.pencolor函数的典型用法代码示例。如果您正苦于以下问题:Python pencolor函数的具体用法?Python pencolor怎么用?Python pencolor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pencolor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

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)
开发者ID:xzlxiao,项目名称:Test,代码行数:7,代码来源:蟒蛇绘制.py


示例2: tree1

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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:project7extension.py


示例3: drawIt

 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)
开发者ID:ericdorsey,项目名称:TurtleArt,代码行数:29,代码来源:turtleArt.py


示例4: player1_symbol

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)
开发者ID:joaomiguelsa,项目名称:Jogo-do-Galo,代码行数:25,代码来源:3+em+linha.py


示例5: drawTree

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
开发者ID:towardsRevolution,项目名称:Aditya-s-Python-Codes,代码行数:60,代码来源:forest.py


示例6: sun

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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:27,代码来源:scene.py


示例7: skidMark

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)
开发者ID:KrbAlmryde,项目名称:Homework,代码行数:7,代码来源:Lab3.py


示例8: tree2

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()
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:26,代码来源:scene.py


示例9: draw_move

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()
开发者ID:donkirkby,项目名称:donimoes,代码行数:33,代码来源:diagram.py


示例10: drawCircle

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)
开发者ID:mbernadette,项目名称:Designs,代码行数:7,代码来源:LoveKnots.Maria.Johnson.py


示例11: main

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 )
开发者ID:Andor-Z,项目名称:My-Learning-Note,代码行数:7,代码来源:week2.py


示例12: tree2

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)
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:28,代码来源:project8extension3.py


示例13: tree1

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)
开发者ID:akaralekas,项目名称:cs151-colby,代码行数:29,代码来源:project8extension3.py


示例14: turmandel

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)
开发者ID:lgaff,项目名称:snippets,代码行数:27,代码来源:turtlestuff.py


示例15: random_col

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
开发者ID:QKid1412,项目名称:python-turtle,代码行数:7,代码来源:turtle_.py


示例16: drawLine

    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
开发者ID:etiennedub,项目名称:battleship,代码行数:30,代码来源:interface.py


示例17: main

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)
开发者ID:16348104,项目名称:Python,代码行数:7,代码来源:python.py


示例18: drawTree

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")
开发者ID:gorgitko,项目名称:bioinformatics-chemoinformatics,代码行数:28,代码来源:phylogenetic-tree.py


示例19: main

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)
开发者ID:etiennedub,项目名称:battleship,代码行数:29,代码来源:main.py


示例20: main

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)  
开发者ID:lovexleif,项目名称:python,代码行数:7,代码来源:snake.py



注:本文中的turtle.pencolor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.pendown函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.pd函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap