本文整理汇总了Python中surface.Surface.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.fill方法的具体用法?Python Surface.fill怎么用?Python Surface.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Weapon
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import fill [as 别名]
class Weapon(Emitter, Inputable):
def __init__(self, level, **kwargs):
super().__init__(**kwargs)
self._level = level
self._part = None
self._s = Surface((20, 10))
self._s.fill((255, 0, 0))
self._input = Input(inputStream=self.getInputStream())
self._input.set(pygame.KEYDOWN, self.createNew, pygame.K_f)
def createNew(self):
x, y = self._offsetFunc()
self._part = Particle((self._anchor.x + x, self._anchor.y + y, 20, 10),
(10, 0),
self._s,
self._level,
Behaviors.killAt(150, 150),
Behaviors.moveAt(self._anchor.getIntDir() * 10, 0),
Behaviors.killOnCollision(exceptions=(self._anchor.getId(),)),
Behaviors.cleanupCollision(),
altname="bullet")
if x < 0:
self._part.x -= self._part.w
self._part.move.setSpeed(x=self._part.move.getTopSpeed(x=True))
def _emit(self):
if self._part:
self._children.append(self._part)
self._part = None
def tick(self):
self._input()
super().tick()
示例2: arc
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import fill [as 别名]
def arc(self, surface, color, rect, start_angle, stop_angle, width=1):
"""
Draw arc shape, and returns bounding Rect.
Argument include surface to draw, color, rect, start_angle, stop_angle.
Optional width argument of outline.
"""
if hasattr(rect, 'width'):
_rect = rect
else:
_rect = Rect(rect)
if _rect.width == _rect.height:
surface.beginPath()
surface.arc(_rect.x+int(_rect.width/2), _rect.y+int(_rect.height/2), int(_rect.width/2), -start_angle, -stop_angle, True)
if width:
surface.setLineWidth(width)
if hasattr(color, 'a'):
surface.setStrokeStyle(color)
else:
surface.setStrokeStyle(Color(color))
surface.stroke()
else:
surface.closePath()
if hasattr(color, 'a'):
surface.setFillStyle(color)
else:
surface.setFillStyle(Color(color))
surface.fill()
else:
if _rect.width < _rect.height:
dim = _rect.height
else:
dim = _rect.width
surf = Surface((dim,dim))
surf.beginPath()
xdim = int(dim/2)
surf.arc(xdim, xdim, xdim, -start_angle, -stop_angle, True)
if width:
surf.setLineWidth(width)
if hasattr(color, 'a'):
surface.setStrokeStyle(color)
else:
surface.setStrokeStyle(Color(color))
surf.stroke()
else:
surface.closePath()
if hasattr(color, 'a'):
surface.setFillStyle(color)
else:
surface.setFillStyle(Color(color))
surf.fill()
surface.drawImage(surf.canvas, 0, 0, dim, dim, _rect.x, _rect.y, _rect.width, _rect.height) #pyjs0.8 *.canvas
if surface._display:
return surface._display._surface_rect.clip(_rect)
else:
return surface.get_rect().clip(_rect)
示例3: update
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import fill [as 别名]
def update(self):
self._heartLen = self._parent.getBaseHealth()
self.w, self.h = 10 * self._heartLen + 2 * ceil(self._heartLen / 2), 16
surf = Surface((self.w, self.h))
trans = self._heartFilled[0].get_at((0, 0))
surf.fill(trans)
surf.set_colorkey(trans)
self._display = Display(surface=surf, klass=self)
for i in range(self._heartLen):
self._hearts.append(surf.subsurface(Object(rect=(10 * i + 2 * (i // 2), 0, 10, 16)).asRect()))