当前位置: 首页>>代码示例>>Python>>正文


Python turtle.register_shape函数代码示例

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


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


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