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

Python turtle.write函数代码示例

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

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



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

示例1: lose

def lose():
	s.playing = False
	mesg = 'Score %d - press space to play again' % s.score
	turtle.goto(0, 0)
	turtle.color(TEXTCOLOR)
	turtle.write(mesg, True, align='center', font=('Arial', 24, 'italic'))
	engine.del_obj(s.me)
开发者ID:sbihel,项目名称:retrogames,代码行数:7,代码来源:nightdriver.py


示例2: makeSquare

def makeSquare(size, person=None, fill=False):
    origPosition = turtle.pos()
    origHead = turtle.heading()
    turtle.penup()
    goDown(size)
    if(person != None or fill == True):
        if(fill==True or person.affected):
            turtle.begin_fill()
    turtle.pendown()
    goLeft(size)
    goUp(2*size)
    goRight(2*size)
    goDown(2*size)
    goLeft(size)
    if(person != None or fill==True):
        if(fill==True or person.affected):
            turtle.end_fill()
    turtle.penup()
    turtle.goto(origPosition)
    turtle.setheading(origHead)
    if(person != None or fill==True):
        if(fill==True or person.affected):
            turtle.color('black')
        if(person.multipleNotShown == 0):
            turtle.write(str(person.name())+"\n"+probString(person), align="center")
        else:
            turtle.write(str(person.name())+"\n"+probString(person)+"\n\n"+str(person.multipleNotShown), align="center")
    turtle.color('blue')
    turtle.penup()
开发者ID:EddieCunningham,项目名称:PedigreeDataCollection,代码行数:29,代码来源:pedigreeDraw.py


示例3: play

def play():           # 게임을 실제로 플레이 하는 함수.
    global score
    global playing
    t.forward(10)       # 주인공 거북이 10만큼 앞으로 이동합니다.
    if random.randint(1, 5) == 3: # 1~5사이에서 뽑은 수가 3이면(20%확률)
        ang = te.towards(t.pos())
        te.sethading(ang)        # 악당 거북이가 주인공 거북이를 바라봅니다
    speed = score + 5            # 점수에 5를 더해서 속도를 올립니다.
                                 # 점수가 올라가면 빨라집니다.
                                 
    if speed > 15:               # 속도가 15를 넘지는 않도록 합니다
        speed = 15
    te.forward(speed)
    
    if t.distance(te) < 12:      # 주인공과 악당의 거리가 12보다 작으면
                                 # 게임을 종료합니다.  
        
        text = "Score : " + str(score)
        message("Game Over", text)
        playing = False
        score = 0
    
    
    if t.distance(ts) < 12:      # 주인공과 먹이의 거리가 12보다 작으면(가까우면)
        score = score + 1        # 점수를 올립니다.
        t.write(score)           # 점수를 화면에 표시합니다.
        star_x = random.randint(-230, 230)
        star_y = random.randint(-230, 230)
        ts.goto(star_x, star_y)  # 먹이를 다른 곳으로 옮깁니다.
        
    if playing:
        t.ontimer(play, 100)     # 게임 플레이 중이면 0.1초후
开发者ID:hubls,项目名称:p2_201611092,代码行数:32,代码来源:Turtle+Run+Game.py


示例4: 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


示例5: turtleProgram

def turtleProgram():
    import turtle
    import random
    global length
    turtle.title("CPSC 1301 Assignment 4 MBowen") #Makes the title of the graphic box
    turtle.speed(0) #Makes the turtle go rather fast
    for x in range(1,(numHex+1)): #For loop for creating the hexagons, and filling them up
        turtle.color(random.random(),random.random(),random.random()) #Defines a random color
        turtle.begin_fill()
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.end_fill()
        turtle.left(2160/(numHex))
        length = length - (length/numHex) #Shrinks the hexagons by a small ratio in order to create a more impressive shape
    turtle.penup()   
    turtle.goto(5*length1/2, 0) #Sends turtle to a blank spot
    turtle.color("Black")
    turtle.hideturtle()
    turtle.write("You have drawn %d hexagons in this pattern." %numHex) #Captions the turtle graphic
    turtle.mainloop()
开发者ID:trsman44,项目名称:Fall-2015,代码行数:30,代码来源:MatthewBowenA4.py


示例6: printwin

def printwin(turtle):
  turtle.stamp()
  turtle.hideturtle()
  turtle.penup()
  turtle.goto(0,0)
  turtle.color("green")
  turtle.write("You Win!",font=("Arial",30), align = "center")
开发者ID:LRBeaver,项目名称:PythonGameDev_Trinket,代码行数:7,代码来源:helpercode.py


示例7: eat_cells

def eat_cells(cell):
	global exit
	for cell in cells:
		for cell2 in cells:
			x1 = cell.xcor()
			x2 = cell2.xcor()
			y1 = cell.ycor()
			y2 = cell2.ycor()
			distance = ((x1 - x2)**2 + (y1 - y2)**2)**0.5
			r1 = cell.get_radius()
			r2 = cell2.get_radius()
			min_d = r1 + r2
			if distance < min_d:
				if (r1 > r2):
					cell2.goto(meet.get_random_x(),meet.get_random_y())
					r1 = r1 + r2/10
					cell.set_radius(r1)
					if cell2 == user_cell:
						exit = False
						print("game over")
						turtle.write('Game Over' , align='center', font=('ariel',50,'bold'))
					if user_cell.radius > 75:
						exit = False
						print("You Win")
						turtle.write('You Win' , align='center', font=('ariel',50,'bold'))
开发者ID:harel17-meet,项目名称:MEET-YL1,代码行数:25,代码来源:Agario.py


示例8: writeText

def writeText(s, x, y):
    turtle.pensize(1)
    turtle.color(0.28, 0.24, 0.55) # Dark Slate Blue
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    turtle.write(s, align="center", font=("Times", 15, "italic"))
开发者ID:mbernadette,项目名称:Designs,代码行数:7,代码来源:LoveKnots.Maria.Johnson.py


示例9: path

def path(individual , dat , fitness , len_dat):
    # 適応度の最大値が何番目かを出力
    print("適応度の最大の番地 -> " + str(fitness.index(max(fitness))))
    nowKame = dat.ix[individual[fitness.index(max(fitness))]]

    # 初期設定
    kame = turtle.Turtle()
    kame = turtle.shape('turtle')
    turtle.screensize(500,1000)

    for i in range(len(nowKame)):
        if i == 0:
            kame = turtle.up()
            kame = turtle.goto(nowKame.ix[i , 0] * 2 , nowKame.ix[i , 1] * 2)
            kame = turtle.down()
            kame = turtle.write("Start")
        else:
            kame = turtle.setpos(nowKame.ix[i , 0] * 2 , nowKame.ix[i , 1] * 2)
            kame = turtle.write(i + 1)

    print("exitと入力すると終了します")
    while True:
        line = input()
        if line == "exit":
            break
开发者ID:nnsnodnb,项目名称:nagareyama-tsp-ga,代码行数:25,代码来源:kame.py


示例10: draw_coordinate_systen

def draw_coordinate_systen(screen_dimension,function, input_range):
    """
    Draws Coordinate System on screen 
    @param screen_dimension 
    """
    turtle.penup()
    turtle.goto(0,screen_dimension[1])
    turtle.pendown()
    turtle.goto(0,-screen_dimension[1])
    turtle.penup()
    turtle.goto(-screen_dimension[1],0)
    turtle.pendown()
    turtle.goto(screen_dimension[1],0)
    turtle.penup()
    turtle.goto(0,0)

    #titles (equation, input_range)
    turtle.color("red")  
    turtle.penup()
    turtle.goto(-screen_dimension[0]+100,screen_dimension[1]-30)
    turtle.pendown()
    turtle.write("Wykres f(x)="+function)
    turtle.penup()
    turtle.goto(-screen_dimension[0]+100,screen_dimension[1]-40)
    turtle.pendown()
    turtle.write("input_range: "+str(input_range))
    turtle.penup()
开发者ID:KrzyKuStudio,项目名称:EquationGrapher,代码行数:27,代码来源:EquationGrapher.py


示例11: drawCloud

def drawCloud(words, num = 20):
    """ Draws a wordcloud with 20 random words, sized by frequency found in 
    the WORDS dictionary. """
    t.reset()
    t.up()
    t.hideturtle()
    topCounts = sorted([words[word] for word in list(words.keys()) if len(word) > 3])
    largest = topCounts[0]
    normalized_counts = {}
    for item in list(words.keys()):
        if len(item) > 3:
            newSize = int(float(words[item]) / largest * 24)
            normalized_counts[item] = newSize
    
    size = t.screensize()
    width_dim = (int(-1 * size[0] / 1.5), int(size[0] / 2))
    height_dim = (int(-1 * size[1] / 1.5), int(size[1] / 1.5))
    

    for item in random.sample(list(normalized_counts.keys()), num):
        t.goto(random.randint(*width_dim), random.randint(*height_dim))
        t.color(random.choice(COLORS))
        try:
            t.write(item, font = ("Arial", int(normalized_counts[item]), "normal"))
        except:
            try:
                t.write(str(item, errors = 'ignore'), font = ("Arial", int(normalized_counts[item]), "normal"))
            except:
                pass
开发者ID:cs10,项目名称:twitter,代码行数:29,代码来源:wordcloud.py


示例12: Eating

def Eating(cells):
	for cell in cells:	
		for cell2 in cells:
			if cell!=cell2:
				min_d = cell.get_radius()+cell2.get_radius()
				d = ((cell.xcor()-cell2.xcor())**2+(cell.ycor()-cell2.ycor())**2)**0.5
				if d<min_d:
					if cell.get_radius()>cell2.get_radius():
						if cell2==user_cell:
							turtle.pensize(50)
							turtle.write("Game Over!")
							meet.mainloop()
						x=meet.get_random_x()
						y=meet.get_random_y()
						cell2.goto(x,y)
						r = cell.get_radius() + 0.2 * cell2.get_radius() 
						cell.set_radius(r)
					if cell2.get_radius()>cell.get_radius():
						if cell==user_cell:
							turtle.pensize(50)
							turtle.write("Game Over!")
							meet.mainloop()
						x=meet.get_random_x()
						y=meet.get_random_y()
						cell.goto(x,y)
						r = cell2.get_radius() + 0.2 * cell.get_radius()
						cell2.set_radius(r)
开发者ID:bar17-meet,项目名称:MEET-YL1,代码行数:27,代码来源:MeetProject.py


示例13: draw_grid

def draw_grid(ll,ur):
	size = ur - ll
	for gridsize in [1, 2, 5, 10, 20, 50, 100 ,200, 500]:
		lines = (ur-ll)/gridsize
		# print('gridsize', gridsize, '->', int(lines)+1, 'lines')
		if lines <= 11: break
	turtle.color('gray')
	turtle.width(1)
	x = ll
	while x <= ur:
		if int(x/gridsize)*gridsize == x:
			turtle.penup()
			turtle.goto(x, ll-.25*gridsize)
			turtle.write(str(x),align="center",font=("Arial",12,"normal"))
			turtle.goto(x,ll)
			turtle.pendown()
			turtle.goto(x,ur)
			# print(x,ll,'to',x,ur)
		x += 1
	y = ll
	while y <= ur:
		# horizontal grid lines:
		if int(y/gridsize)*gridsize == y:
			turtle.penup()
			turtle.goto(ll-.1*gridsize, y - .06*gridsize)
			turtle.write(str(y),align="right",font=("Arial",12,"normal"))
			turtle.goto(ll,y)
			turtle.pendown()
			turtle.goto(ur,y)
			# print(ll,y,'to',ur,y)
		y += 1
开发者ID:ipmichael,项目名称:cmsc421,代码行数:31,代码来源:tdraw.py


示例14: hands

def hands( freq=166 ):
    """Draw three hands.

    :param freq: Frequency of refresh in milliseconds.
    """
    global running
    now= datetime.datetime.now()
    time= now.time()
    h, m, s, ms = time.hour, time.minute, time.second, int(time.microsecond/1000)

    # Erase old hands.
    while turtle.undobufferentries():
        turtle.undo()

    # Draw new hands.
    hand( h*5+m/60+s/3600, .6*R, 3 )
    hand( m+s/60, .8*R, 2 )
    hand( s+ms/1000, .9*R, 1 )

    # Draw date and time
    turtle.penup(); turtle.home()
    turtle.goto( 0, -120 ); turtle.write( now.strftime("%b %d %H:%M:%S"), align="center", font=("Helvetica", 24, "normal") )

    # Reschedule hands function
    if running:
        # Reset timer for next second (including microsecond tweak)
        turtle.ontimer( hands, freq-(ms%freq) )
开发者ID:slott56,项目名称:HamCalc-2.1,代码行数:27,代码来源:logoclok.py


示例15: drawLine

def drawLine():
	turtle.penup()
	turtle.goto(-50, 300)
	turtle.pendown()
	turtle.write("Base Line", font=("Arial", 14, "normal"))
	turtle.color("red")
	turtle.forward(500)
开发者ID:krnbatra,项目名称:AI-Assignments,代码行数:7,代码来源:assign2.py


示例16: message

def message(m1, m2):             # 메시지를 화면에 표시하는 함수
    t.clear()
    t.goto(0, 100)
    t.write(m1, False, "center", ("", 20))
    t.goto(0, -100)
    t.write(m2, False, "center", ("", 15))
    t.home()
开发者ID:hubls,项目名称:p2_201611092,代码行数:7,代码来源:Turtle+Run+Game.py


示例17: render

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
开发者ID:brianconroy,项目名称:Bioinformatics,代码行数:29,代码来源:parsimony.py


示例18: makeDiamond

def makeDiamond(size, person=None, fill=False):
    origPosition = turtle.pos()
    origHead = turtle.heading()
    turtle.penup()
    goDown(size)
    turtle.pendown()
    if(person != None or fill==True):
        if(fill==True or person.affected):
            turtle.begin_fill()
    goNorthEast(2*size/np.sqrt(2))
    goNorthWest(2*size/np.sqrt(2))
    goSouthWest(2*size/np.sqrt(2))
    goSouthEast(2*size/np.sqrt(2))
    if(person != None or fill==True):
        if(fill==True or person.affected):
            turtle.end_fill()
    turtle.penup()
    turtle.goto(origPosition)
    turtle.setheading(origHead)
    if(person != None or fill==True):
        if(fill==True or person.affected):
            turtle.color('black')
        if(person.multipleNotShown == 0):
            turtle.write(str(person.name())+"\n"+probString(person), align="center")
        else:
            turtle.write(str(person.name())+"\n"+probString(person)+"\n\n"+str(person.multipleNotShown), align="center")
    turtle.color('blue')
    turtle.penup()
开发者ID:EddieCunningham,项目名称:PedigreeDataCollection,代码行数:28,代码来源:pedigreeDraw.py


示例19: 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


示例20: write

def write(side):
	turtle.color("green")
	for i in range(5):
		for j in range(6):
			move(-side*5/2.+j*side, side*6/2.-(i+1)*side)
			turtle.write(table[i][j], align="center", font=("Arial", side/2, "bold"))
	return
开发者ID:jpbat,项目名称:freetime,代码行数:7,代码来源:30.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python turtle.xcor函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.width函数代码示例发布时间: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