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

Python turtle.register_shape函数代码示例

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

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



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

示例1: drawground

def drawground():
    s = turtle.Shape("compound")
    ground = (
        (-320, 120),
        (-280, 41),
        (-240, 27),
        (-200, 59),
        (-160, 25),
        (-120, 43),
        (-80, 56),
        (-40, 20),
        (0, 20),
        (40, 20),
        (80, 44),
        (120, 28),
        (160, 66),
        (200, 29),
        (240, 64),
        (280, 34),
        (320, 140),
        (320, 0),
        (-320, 0),
    )
    s.addcomponent(ground, "#8B4513", "#8B4513")
    turtle.register_shape("ground", s)
开发者ID:cferr,项目名称:projetFusee,代码行数:25,代码来源:lunarlander.py


示例2: drawfus

def drawfus(): # spaceship!
	global basesize
	B = basesize
	turtle.begin_poly()
	turtle.fd(B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.fd(2.25 * B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.rt(90)
	turtle.fd(B)
	turtle.fd(3 * B)
	turtle.rt(-90)
	turtle.fd(1.25 * B)
	
	turtle.end_poly()
	poly = turtle.get_poly() # c'est le poly... yveslemaire.poly
	turtle.register_shape('fusee', poly)
开发者ID:cferr,项目名称:projetFusee,代码行数:25,代码来源:eg-box.working.py


示例3: initialize_plot

   def initialize_plot(self, positions):
      self.positions = positions
      self.minX = minX = min(x for x,y in positions.values())
      maxX = max(x for x,y in positions.values())
      minY = min(y for x,y in positions.values())
      self.maxY = maxY = max(y for x,y in positions.values())
      
      ts = turtle.getscreen()
      if ts.window_width > ts.window_height:
          max_size = ts.window_height()
      else:
          max_size = ts.window_width()
      self.width, self.height = max_size, max_size
      
      turtle.setworldcoordinates(minX-5,minY-5,maxX+5,maxY+5)
      
      turtle.setup(width=self.width, height=self.height)
      turtle.speed("fastest") # important! turtle is intolerably slow otherwise
      turtle.tracer(False)    # This too: rendering the 'turtle' wastes time
      turtle.hideturtle()
      turtle.penup()
      
      self.colors = ["#d9684c","#3d658e","#b5c810","#ffb160","#bd42b3","#0eab6c","#1228da","#60f2b7" ]

      for color in self.colors:         
         s = turtle.Shape("compound")
         poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
         s.addcomponent(poly1, color, "#000000")
         turtle.register_shape(color, s)
      
      s = turtle.Shape("compound")
      poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
      s.addcomponent(poly1, "#000000", "#000000")
      turtle.register_shape("uncolored", s)
开发者ID:jorgenkg,项目名称:IT3105,代码行数:34,代码来源:visuals.py


示例4: makeshape

def makeshape():
	B = 25				# base unit size
	turtle.begin_poly()
	turtle.fd(B)			# roof
	turtle.rt(45)
	turtle.fd(B * 3/4)		# windshield
	turtle.lt(45)
	turtle.fd(B)			# hood
	turtle.rt(90)
	turtle.fd(B * 3/4)		# front
	turtle.rt(90)
	turtle.fd(B * 1/7)
	turtle.lt(90)
	turtle.circle(-B/2, 180)	# front tire
	turtle.lt(90)
	turtle.fd(B)
	turtle.lt(90)
	turtle.circle(-B/2, 180)	# back tire
	turtle.lt(90)
	turtle.fd(B * 1/7)
	turtle.rt(90)
	turtle.fd(B * 5/6)		# back
	turtle.end_poly()
	poly = turtle.get_poly()
	turtle.register_shape('car', poly)
开发者ID:sbihel,项目名称:retrogames,代码行数:25,代码来源:eg-poly.py


示例5: maketree

def maketree(name, scale, L):
	turtle.home()
	turtle.begin_poly()
	stack = [ (0, 0) ]
	maketree_r(stack, L, scale)
	turtle.end_poly()
	poly = turtle.get_poly()
	turtle.register_shape(name, poly)
开发者ID:sbihel,项目名称:retrogames,代码行数:8,代码来源:walking.py


示例6: makepop

def makepop(fn, *args):
	turtle.home()
	turtle.begin_poly()
	fn(*args)
	turtle.end_poly()
	name = 'pop%d' % len(POPS)
	turtle.register_shape(name, turtle.get_poly())
	POPS.append(name)
开发者ID:sbihel,项目名称:retrogames,代码行数:8,代码来源:walking.py


示例7: reg_bullet

def reg_bullet():
    turtle.home()
    turtle.setpos(0, -5)
    turtle.begin_poly()
    turtle.circle(5, None, None)
    turtle.end_poly()
    circ = turtle.get_poly()
    turtle.register_shape('bullet', circ)
开发者ID:cferr,项目名称:projetFusee,代码行数:8,代码来源:gravity.py


示例8: radar_chart

def radar_chart(data):
    # Some "typical" test data
    #print "Hello"
    length=len(data) # stores the length of the data provided
    turtle.home()   # Sets the turtle to position (0,0)
    division=360/length #what angle is needed for invidual lines
    poslist=[] #list to store current position
    valpos=[]   #list to store position
    j=0
    turtle.hideturtle() #hides the arrow
        #Draw the foundation of the Radar Chart
    for i in range(length): # Loop until all the given data is plotted
        turtle.forward(200) #move turtle forward
        turtle.dot(10,"black") # Draw the black dot at the end of each data
        nowpos=turtle.pos() # store the current position
        poslist.append(nowpos) #append the current position to list
        #turtle.hideturtle()
        turtle.setpos(nowpos[0]+10,nowpos[1]) #get the turtle to new postion to write data
        turtle.write(data[i], True, align="center") # Write the label of data
        turtle.setpos(nowpos[0],nowpos[1]) #return to the previous position
        turtle.back(200) #return home
        turtle.left(division) # rotate by the specific angle
    turtle.home()    # return to turtle home
    #Connect the ends points of the radar chart
    for i in poslist: #
        turtle.setpos(i[0],i[1])
        #turtle.setpos(i[j],i[j+1])
        #turtle.forward(100)
        #turtle.home()
        #turtle.degree(division)
        #turtle.heading()
        #turtle.forward(100)
    turtle.setpos(poslist[0][0],poslist[0][1])
    turtle.home()
    #Draw green Dots 
    for i in range(length):
        incval=data[i]
        turtle.forward(incval*2)
        turtle.dot(15,"green")
        nowpos=turtle.pos()
        valpos.append(nowpos) 
        turtle.back(incval*2)
        turtle.left(division)
    turtle.begin_poly()
    turtle.fill(True)
    #Fill the green Dots
    for i in valpos:
        turtle.setpos(int(i[0]),int(i[1]))
    turtle.setpos(valpos[0][0],valpos[0][1])
    turtle.end_poly()
    p = turtle.get_poly()
    turtle.register_shape("jpt", p)
    turtle.color("Green", "Green")
    turtle.begin_fill()
    #turtle.p(80)
    turtle.end_fill()
    turtle.fill(False)
开发者ID:aadeshnpn,项目名称:timepass,代码行数:57,代码来源:radar_chart.py


示例9: __init__

	def __init__(self, ulx, uly, lrx, lry):
		# refer to counter as class variable
		name = 'BigRect.%d' % BigRect._counter
		BigRect._counter = BigRect._counter + 1
		
		turtle.register_shape(name, (
			(ulx, uly), (lrx, uly), (lrx, lry), (ulx, lry)
		))
		super().__init__(0, 0, 0, 1, name, 'yellow')
开发者ID:sbihel,项目名称:retrogames,代码行数:9,代码来源:demo.py


示例10: reg_sun

def reg_sun():
    global sundiam
    turtle.home()
    turtle.setpos(0, -sundiam / 2)
    turtle.begin_poly()
    turtle.circle(sundiam/2, None, None)
    turtle.end_poly()
    circ = turtle.get_poly()
    turtle.register_shape('sun', circ)
开发者ID:cferr,项目名称:projetFusee,代码行数:9,代码来源:gravity.py


示例11: makeground

def makeground():
	for i in range(GROUNDLEN-3, GROUNDLEN+9):
		turtle.home()
		turtle.begin_poly()
		turtle.fd(i)
		turtle.end_poly()
		name = 'gr%d' % i
		turtle.register_shape(name, turtle.get_poly())
		GROUND.append(name)
开发者ID:sbihel,项目名称:retrogames,代码行数:9,代码来源:walking.py


示例12: makepipes

def makepipes():
	for i in range(PIPEMIN, PIPEUNITS):
		name = ht2name(i)
		ulx = i * PIPEUNIT
		lrx = 0
		uly = 0
		lry = PIPEWIDTH
		turtle.register_shape(name, (
			(ulx, uly), (lrx, uly), (lrx, lry), (ulx, lry)
		))
开发者ID:sbihel,项目名称:retrogames,代码行数:10,代码来源:flappy.py


示例13: makeshapes

def makeshapes():
	B = 25				# base unit size

	for i in range(1, 16):
		name = 'a%d' % i
		turtle.register_shape(name, makepoly(B, B/i, B + B*i*0.2))
		SEQ.append(name)
	
	# flip sequence except for first one
	for i in range(len(SEQ)-1, 0, -1):
		SEQ.append(SEQ[i])
开发者ID:sbihel,项目名称:retrogames,代码行数:11,代码来源:eg-anim.py


示例14: mkHand

def mkHand(name, length):  
    # 注册Turtle形状,建立表针TuConsolartle  
    turtle.reset()  
    Skip(-length * 0.1)  
    # 开始记录多边形的顶点。当前的乌龟位置是多边形的第一个顶点。  
    turtle.begin_poly()  
    turtle.forward(length * 1.1)  
    # 停止记录多边形的顶点。当前的乌龟位置是多边形的最后一个顶点。将与第一个顶点相连。  
    turtle.end_poly()  
    # 返回最后记录的多边形。  
    handForm = turtle.get_poly()  
    turtle.register_shape(name, handForm)  
开发者ID:sfilata,项目名称:gitskills,代码行数:12,代码来源:clock.py


示例15: create_leg_shape

def create_leg_shape():
    WN.tracer(0) #do not draw screen.
    t = turtle.Turtle()
    t.pen(speed=0, shown=False, pendown=False)
    t.lt(90)
    t.fd(10)
    t.begin_poly()
    t.fd(100)
    t.circle(7)
    t.end_poly()
    p = t.get_poly()
    turtle.register_shape('leg', p)
开发者ID:heatheramahan,项目名称:Python_Turtle_Graphics,代码行数:12,代码来源:polysprite_Mahan_11.py


示例16: mkHand

def mkHand(name, length):
    #注册turtle形状,建立表针turtle
    turtle.reset()
    Skip(-length*0.1)
    #开始记录多边形的顶点,当前的位置是多边形的第一个顶点
    turtle.begin_poly()
    turtle.forward(length*1.1)
    #停止记录多边形的顶点,当前位置是多边形的最后一个顶点,将于第一个顶点相连
    turtle.end_poly()
    #返回最后记录的多边形
    handForm = turtle.get_poly()
    turtle.register_shape(name, handForm)
开发者ID:W7297911,项目名称:test,代码行数:12,代码来源:turtle_时钟.py


示例17: maketweendata

def maketweendata(kf1, kf2, steps, scale):
	global _kfsegments
	assert len(kf1) == len(kf2)	# must be able to match segments up

	L = []
	for i in range(len(kf1)):
		[ (x1, y1), (x2, y2) ] = normalize(kf1, i, scale)

		# Euclidean distance gives segment length
		seglen = ( (x2 - x1) ** 2 + (y2 - y1) ** 2 ) ** 0.5

		# make line segment into shape
		turtle.home()
		turtle.begin_poly()
		turtle.fd(seglen)
		turtle.end_poly()
		name = 'kf%d' % _kfsegments
		_kfsegments += 1
		turtle.register_shape(name, turtle.get_poly())

		# and compute initial heading
		heading = getheading(x1, y1, x2, y2)

		# extract out corresponding segment from key frame 2
		[ (x1b, y1b), (x2b, y2b) ] = normalize(kf2, i, scale)

		# use it to compute deltas for x, y, and heading; this is
		# where we need to be after N steps
		dx = x1b - x1
		dy = y1b - y1
		dh = getheading(x1b, y1b, x2b, y2b) - heading
		# weird special case that cropped up between BKF3 and BKF4 of
		# bird flap, where the computed delta in the heading takes the
		# long way around, as it were - adjust it to compensate
		if dh > 180:
			dh = dh - 360
		elif dh < -180:
			dh = dh + 360
		dx /= steps
		dy /= steps
		dh /= steps

		# place everything in a container
		c = Tween()
		c.name = name
		c.x, c.y = x1, y1
		c.heading = heading
		c.dx, c.dy = dx, dy
		c.dh = dh
		L.append(c)

	return L
开发者ID:sbihel,项目名称:retrogames,代码行数:52,代码来源:walking.py


示例18: drawfus_alt

def drawfus_alt():
    global basesize
    B = basesize

    ship = turtle.Shape("compound")
    mesh = ((1 * B, 0), (2 * B, 2 * B), (-2 * B, 0), (2 * B, -2 * B), (1 * B, 0))
    ship.addcomponent(mesh, "black", "black")

    redship = turtle.Shape("compound")
    redship.addcomponent(mesh, "red", "red")

    turtle.register_shape("fusee", ship)
    turtle.register_shape("fusee reac", redship)
开发者ID:cferr,项目名称:projetFusee,代码行数:13,代码来源:lunarlander.py


示例19: reg_enemy

def reg_enemy():
    global basesize
    B = 2*basesize
    enemyship = turtle.Shape("compound")
    enemy_mesh = ((0, -1*B), (1*B, -0.33*B), (1*B, 0.33*B),
                  (0, 1*B), (-1*B, 0))
    left_antenna = ((-0.33*B, -0.66*B), (-B, -B), (-0.66*B, -0.33*B))
    right_antenna = ((-0.33*B, 0.66*B), (-B, B), (-0.66*B, 0.33*B))

    enemyship.addcomponent(enemy_mesh, "red", "green")
    enemyship.addcomponent(left_antenna, "red", "green")
    enemyship.addcomponent(right_antenna, "red", "green")
    turtle.register_shape("enemy", enemyship)
开发者ID:cferr,项目名称:projetFusee,代码行数:13,代码来源:gravity.py


示例20: __init__

	def __init__(self, dx, x_cor, y_cor,width, speed, color):
		Turtle.__init__(self)
		turtle.register_shape("pad.gif")
		self.shape("pad.gif")
		self.ht()
		self.dx = dx
		self.x_cor = x_cor
		self.y_cor = y_cor
		self.width=width
		self.speed=speed
		self.goto(self.x_cor, self.y_cor)
		self.color=color
		self.st()	
开发者ID:meet-projects,项目名称:spacebrick-yl1-2016,代码行数:13,代码来源:pedalClass.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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