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

Python turtle.shape函数代码示例

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

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



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

示例1: show_goal_posts

 def show_goal_posts(self, goal_posts):
     for p in goal_posts:
         turtle.color("#FFFF00")
         turtle.setposition(p[0], p[1])
         turtle.shape("circle")
         turtle.stamp()
         turtle.update()
开发者ID:hendrikvgl,项目名称:RoboCup-Spielererkennung,代码行数:7,代码来源:draw.py


示例2: show_particles

    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        turtle.shape('tri')

        # Particle weights are shown using color variation
        show_color_weights = 1 #len(weights) == len(particles)
        draw_cnt = 0
        px = {}
        for i, p in enumerate(particles):
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(p.x * self.one_px)
                scaled_y = int(p.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition([p.x + self.width / 2, p.y + self.height / 2])
                    turtle.setheading(p.theta / pi * 180.0)
                    if(show_color_weights):
                        weight = p.w
                    else:
                        weight = 0.0
                    turtle.color(self.weight_to_color(weight))
                    turtle.stamp()
开发者ID:shreeshga,项目名称:gaussian_particlefilter,代码行数:30,代码来源:draw.py


示例3: show_sharks

    def show_sharks(self, sharks):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        turtle.clearstamps()
        draw_cnt = 0
        px = {}
        for shark in sharks:
            draw_cnt += 1
            shark_shape = 'classic' if shark.tracked else 'classic'
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 0:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x = int(shark.x * self.one_px)
                scaled_y = int(shark.y * self.one_px)
                scaled_xy = scaled_x * 10000 + scaled_y
                turtle.color(shark.color)
                turtle.shape(shark_shape)
                turtle.resizemode("user")
                turtle.shapesize(1.5,1.5,1)
                if not scaled_xy in px:
                    px[scaled_xy] = 1
                    turtle.setposition(*shark.xy)
                    turtle.setheading(math.degrees(shark.h))
                    turtle.stamp()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:26,代码来源:draw.py


示例4: show_shark

 def show_shark(self, shark):
     turtle.color(shark.color)
     turtle.shape('turtle')
     turtle.setposition(*shark.xy)
     turtle.setheading(math.degrees(shark.h))
     turtle.stamp()
     turtle.update()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:7,代码来源:draw.py


示例5: show_robot

 def show_robot(self, robot):
     turtle.color("blue")
     turtle.shape('square')
     turtle.setposition(*robot.xy)
     turtle.setheading(math.degrees(robot.h))
     turtle.stamp()
     turtle.update()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:7,代码来源:draw.py


示例6: show_robot

 def show_robot(self, robot):
     turtle.color("green")
     turtle.shape('turtle')
     turtle.setposition([robot.x + self.width / 2, robot.y + self.height / 2])
     turtle.setheading(robot.theta / pi * 180.0)
     turtle.stamp()
     turtle.update()
开发者ID:shreeshga,项目名称:gaussian_particlefilter,代码行数:7,代码来源:draw.py


示例7: drawCurr

def drawCurr(currX, currY, nextX, nextY, state):
	if state == 1:
		turtle.color("red")
	else:
		turtle.color("blue")
	turtle.shape("turtle")
	startX = 0 
	startY = 0
	if(state == 1):
		startX = initX1
		startY = initY2
	else:
		startX = initX2
		startY = initY2
	prev_x_coord = startX + square_len * currY + square_len/2
	prev_y_coord = startY - square_len * currX - square_len/2

	turtle.penup()
	turtle.goto(prev_x_coord, prev_y_coord)
	
	next_x_coord = startX + square_len * nextY + square_len/2
	next_y_coord = startY - square_len * nextX - square_len/2
	
	turtle.pendown()
	if next_x_coord > prev_x_coord:
		# move right
		turtle.goto(next_x_coord, prev_y_coord)
		# move down
		turtle.goto(next_x_coord, next_y_coord)
	else:
		# move down
		turtle.goto(prev_x_coord, next_y_coord)
		# move left
		turtle.goto(next_x_coord, next_y_coord)
	turtle.penup()
开发者ID:krnbatra,项目名称:AI-Assignments,代码行数:35,代码来源:assign1.py


示例8: show_particles

    def show_particles(self, particles):
        self.update_cnt += 1
        if UPDATE_EVERY > 0 and self.update_cnt % UPDATE_EVERY != 1:
            return

        # turtle.clearstamps()
        turtle.shape('tri')

        draw_cnt = 0
        px = {}
        for p in particles:
            draw_cnt += 1
            if DRAW_EVERY == 0 or draw_cnt % DRAW_EVERY == 1:
                # Keep track of which positions already have something
                # drawn to speed up display rendering
                scaled_x1 = int(p.x1 * self.one_px)
                scaled_y1 = int(p.y1 * self.one_px)
                scaled_xy1 = scaled_x1 * 10000 + scaled_y1
                if not scaled_xy1 in px:
                    px[scaled_xy1] = 1
                    turtle.setposition(*p.xy1)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Red")
                    turtle.stamp()

                    turtle.setposition(*p.xy2)
                    turtle.setheading(math.degrees(p.h))
                    turtle.color("Blue")
                    turtle.stamp()
开发者ID:hmc-lair,项目名称:multitarget_state_estimator,代码行数:29,代码来源:draw.py


示例9: drawLines

def drawLines(line_arr):
    turt = turtle.Turtle()
    turtle.shape("blank")
    # draws each line in the line_arr
    for line in line_arr:
        draw_single_line(line, turt)
    turtle.done()
开发者ID:PowerCouple,项目名称:Fractals,代码行数:7,代码来源:frac.py


示例10: drawPaintBoard

def drawPaintBoard():
	turtle.shape("triangle")
	turtle.penup()
	turtle.color("red")
	fillRect(0 - width,0 + height,30 -width,30 +height)
	turtle.color("blue")
	fillRect(30-width,height,60-width,30+height)
	turtle.color("#000000")
	drawRect(width,height,width-30,30+height)
	drawRect(width-30,height,width-60,height+30)
	turtle.penup()
	turtle.goto(width-15,height)
	turtle.pendown()
	turtle.circle(15)
	fillRect(width-60,height,width-90,height+30)
	drawRect(width-90,height,width-120,height+30)
	turtle.penup()
	turtle.goto(width-105,height)
	turtle.pendown()
	turtle.begin_fill()
	turtle.circle(15)
	turtle.end_fill()
	turtle.penup()
	drawRect(-15,height,15,height+30)
	turtle.goto(0,height)
	drawCursor()
	drawEraser()
	turtle.color("blue")
开发者ID:itamar16-meet,项目名称:MEET-Conf,代码行数:28,代码来源:paint.py


示例11: main

def main():
    import turtle
    turtle.forward(0)
    turtle.shape("turtle")
    turtle.color("teal")
    turtle.forward(100)
    turtle.left(120)
    turtle.forward(100)
    turtle.left(120)
    turtle.forward(100)
    turtle.left(90)  
    
    import turtle
    turtle.forward(0)
    turtle.color("red")
    turtle.forward(50)
    turtle.left(90)
    turtle.color("orange")
    turtle.forward(50)
    turtle.left(90)
    turtle.color("yellow")
    turtle.forward(50)
    turtle.left(90)
    turtle.color("green")
    turtle.forward(50)
    turtle.left(90) 
开发者ID:bakerb0473,项目名称:cti110,代码行数:26,代码来源:m5t1_Baker.py


示例12: show_robot

 def show_robot(self, robot):
     turtle.color("green")
     turtle.shape('turtle')
     turtle.setposition(*robot.xy)
     turtle.setheading(robot.h)
     turtle.stamp()
     turtle.update()
开发者ID:wellfare,项目名称:particle_filter_demo,代码行数:7,代码来源:draw.py


示例13: changeShape

def changeShape():
	global shapeList
	global currentShape
	turtle.shape(shapeList[currentShape])
	if currentShape >= len(shapeList)-1:
		currentShape = 0
	else:
		currentShape += 1
开发者ID:nathaniel16-meet,项目名称:MEET-YL1,代码行数:8,代码来源:paint.py


示例14: show_particles

    def show_particles(self, particles):
        turtle.shape('dot')

        for p in particles:
            turtle.setposition(*p.xy)
            turtle.setheading(p.h)
            turtle.color(self.weight_to_color(p.w))
            turtle.stamp()
开发者ID:ferrix,项目名称:particle_filter_demo,代码行数:8,代码来源:draw.py


示例15: show_mean

 def show_mean(self, x, y, confident=False):
     if confident:
         turtle.color("#00AA00")
     else:
         turtle.color("#cccccc")
     turtle.setposition(x, y)
     turtle.shape("circle")
     turtle.stamp()
开发者ID:MoonMaker,项目名称:Machine-Learning,代码行数:8,代码来源:draw.py


示例16: addBodyPart

    def addBodyPart(self):
        if (self.currentBodyPart < 7) :
            self.currentBodyPart += 1

            self.image = "../hangman" + str(self.currentBodyPart) + ".gif"

            self.screen.addshape(self.image)
            turtle.shape(self.image)
开发者ID:severyourlegplease,项目名称:somestuff,代码行数:8,代码来源:HangmanGUI.py


示例17: draw

	def draw(self):
		'''
		Draws the object at its current (x, y) coordinates.
		'''
		turtle.goto(self.x, self.y)
		turtle.seth(self.heading())
		turtle.shape(self.shape)
		turtle.color(self.color)
		return turtle.stamp()
开发者ID:sbihel,项目名称:retrogames,代码行数:9,代码来源:engine.py


示例18: main

def main():
    # use sys.argv if needed
    print('generating spirograph...')
    # create parser
    descStr = """This program draws spirographs using the Turtle module. 
    When run with no arguments, this program draws random spirographs.
    
    Terminology:

    R: radius of outer circle.
    r: radius of inner circle.
    l: ratio of hole distance to r.
    """
    parser = argparse.ArgumentParser(description=descStr)
  
    # add expected arguments
    parser.add_argument('--sparams', nargs=3, dest='sparams', required=False, 
                        help="The three arguments in sparams: R, r, l.")
                        

    # parse args
    args = parser.parse_args()

    # set to 80% screen width
    turtle.setup(width=0.8)

    # set cursor shape
    turtle.shape('turtle')

    # set title
    turtle.title("Spirographs!")
    # add key handler for saving images
    turtle.onkey(saveDrawing, "s")
    # start listening 
    turtle.listen()

    # hide main turtle cursor
    turtle.hideturtle()

    # checks args and draw
    if args.sparams:
        params = [float(x) for x in args.sparams]
        # draw spirograph with given parameters
        # black by default
        col = (0.0, 0.0, 0.0)
        spiro = Spiro(0, 0, col, *params)
        spiro.draw()
    else:
        # create animator object
        spiroAnim = SpiroAnimator(4)
        # add key handler to toggle turtle cursor
        turtle.onkey(spiroAnim.toggleTurtles, "t")
        # add key handler to restart animation
        turtle.onkey(spiroAnim.restart, "space")

    # start turtle main loop
    turtle.mainloop()
开发者ID:diopib,项目名称:pp,代码行数:57,代码来源:spiro.py


示例19: draw_square

def draw_square(turtle, size):
	turtle.shape("triangle");
	turtle.speed(10);
	turtle.color("white");

	for i in range(0, 4):
		turtle.forward(size);
		turtle.right(90);

	turtle.right(10);
开发者ID:matarrubia,项目名称:matarrubia,代码行数:10,代码来源:draw_square.py


示例20: render

 def render(self):
     turtle.up()
     w=turtle.window_width()
     self.dist=w/len(self.string)
     turtle.back(w/2)
     turtle.shape("turtle")
     for c in self.string:
         self.draw(c)
     turtle.hideturtle()
     turtle.exitonclick()        
开发者ID:weka511,项目名称:fractals,代码行数:10,代码来源:Lindenmayer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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