本文整理汇总了Python中circle.Circle.setradius方法的典型用法代码示例。如果您正苦于以下问题:Python Circle.setradius方法的具体用法?Python Circle.setradius怎么用?Python Circle.setradius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circle.Circle
的用法示例。
在下文中一共展示了Circle.setradius方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyApp
# 需要导入模块: from circle import Circle [as 别名]
# 或者: from circle.Circle import setradius [as 别名]
class MyApp(PygameApp):
"""
Custom version of PygameApp, to display moving circle
"""
def __init__(self, screensize = (400,400)):
"""
Application initialization is executed only ONCE!
"""
super().__init__(screensize = screensize, title="My Test Application") # call base class initializer
pygame.key.set_repeat(100) # allow keys to repeat when held 100 msec
self.setbackgroundcolor((220,220,220)) # set a new background color
self.circ = Circle(self.spritegroup) # create a default circle
def handle_event(self, event):
"""
Override the base class event handler. Based on mouse and keyboard input make adjustments
to the Circle object or make copies of it.
"""
if event.type == MOUSEMOTION:
self.circ.setpos(event.pos)
elif event.type == MOUSEBUTTONDOWN:
if event.button == 4: # scroll UP "button"
self.circ.setradius(self.circ.radius+1)
elif event.button == 5: # scroll DOWN "button"
self.circ.setradius(self.circ.radius-1)
elif event.button == 1:
newcirc = self.circ.copy() # "drop" a copy of the current circle
newcirc.setcolor((255,0,0,200))
newcirc.setthickness(1)
newcirc.update() # force update and display
elif event.type == KEYDOWN: # keyboard
circpos = self.circ.pos
if event.key == K_UP: # cursor up
circpos = (circpos[0],circpos[1]-1) # calculate a new position
elif event.key == K_DOWN: # cursor down
circpos = (circpos[0],circpos[1]+1) # calculate a new position
self.circ.setpos(circpos) # update the position
else:
print (pygame.event.event_name(event.type)) # view unhandled events on the console
return True # Keep going!
def quit(self):
"""
Override default quit behavior here, if desired
"""
pass
def poll(self):
"""
Override default poll behavior here, if desired
"""
pass