本文整理汇总了Python中pygame.rect.Rect.center方法的典型用法代码示例。如果您正苦于以下问题:Python Rect.center方法的具体用法?Python Rect.center怎么用?Python Rect.center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.rect.Rect
的用法示例。
在下文中一共展示了Rect.center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_slide_rect
# 需要导入模块: from pygame.rect import Rect [as 别名]
# 或者: from pygame.rect.Rect import center [as 别名]
def _get_slide_rect(self):
slide_rect = Rect((0, 0), (self._length, self._height))
try:
slide_rect.center = self.get_fus_center()
except AttributeError:
slide_rect.center = self.get_ghost_center()
return slide_rect
示例2: render
# 需要导入模块: from pygame.rect import Rect [as 别名]
# 或者: from pygame.rect.Rect import center [as 别名]
def render(self):
self.check()
if self.disabled: return
pos = self.rect.center
t = self.mod["eyeType"]
color0 = (255,255,255)
color1 = (0,0,0)
radius = (self.mod["eyeSkill"] + 2) * 3
color = skinColor(self.mod)
# we have to determine how big the eye will be before drawing
size = (radius * 2, radius * 2)
rect = Rect((0,0), size)
image = Surface(size)
image.fill(self.colorkey)
image.set_colorkey(self.colorkey)
# locking the surface makes multiple drawing operations quicker
image.lock()
# draw the border of the eye
if radius < 10:
steps = 16
else:
steps = 8
for t in range(0,360,steps):
t = radians(t)
new_color = Color(color.r, color.g, color.b)
h, s, v, a = new_color.hsva
v = int(sin(t) * 50) + 50
if v < 0: v = 0 - v
new_color.hsva = (h, s, v, a)
x = int(rect.centerx + cos(t) * (radius - 4))
y = int(rect.centery + sin(t) * (radius - 4))
draw.circle(image, new_color, (x, y), 3)
# draw the white and pupil
draw.circle(image, color0, rect.center, radius - 3)
draw.circle(image, color1, rect.center, (radius - 3) / 3)
image.unlock()
rect.center = pos
self.rect = rect
self.image = image