本文整理汇总了Python中pygame.surface.Surface.set_at方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.set_at方法的具体用法?Python Surface.set_at怎么用?Python Surface.set_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.surface.Surface
的用法示例。
在下文中一共展示了Surface.set_at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: activate
# 需要导入模块: from pygame.surface import Surface [as 别名]
# 或者: from pygame.surface.Surface import set_at [as 别名]
def activate(self):
xsize = 300
ysize = 70
bkg = Surface((xsize, ysize))
bkg.lock()
bkg.fill((128,128,128))
for i in range(1, 4):
draw.rect(bkg,(i*32,i*32,i*32),(4-i,4-i,xsize+(i-4)*2,ysize+(i-4)*2),3)
corner = (64,64,64)
bkg.set_at((0,0), corner)
bkg.set_at((xsize,0), corner)
bkg.set_at((xsize,ysize), corner)
bkg.set_at((0,ysize), corner)
bkg.unlock()
bkg.set_alpha(64)
self.bkg = bkg
if self.title != None:
banner = OutlineTextBanner(self.title, (200,200,200), 20)
self.title_image = banner.render()
self.title_image.set_alpha(96)
self.arrow = res.loadImage("wait_arrow.png", colorkey=1)
示例2: calculate_foreground
# 需要导入模块: from pygame.surface import Surface [as 别名]
# 或者: from pygame.surface.Surface import set_at [as 别名]
def calculate_foreground(background, composite):
print "Calculating foreground...",
sys.stdout.flush()
w, h = assert_same_sizes([background, composite])
foreground = Surface((w, h), flags=pygame.SRCALPHA)
for x in xrange(0, w):
for y in xrange(0, h):
baseline = tuple(background.get_at((x, y)))
k = composite.get_at((x, y))
if tuple(k) != baseline:
foreground.set_at((x, y), k)
pygame.image.save(foreground, 'foreground.png')
print "done!"
return foreground
示例3: normalize_images
# 需要导入模块: from pygame.surface import Surface [as 别名]
# 或者: from pygame.surface.Surface import set_at [as 别名]
def normalize_images(images):
assert len(images) >= 3
print "Normalizing %d files..." % (len(images)),
sys.stdout.flush()
# Verify w/h same for all images
w, h = assert_same_sizes(images)
# TODO: Do this on a per-tile basis. Without means we
# won't capture water correctly.
newsurf = Surface((w, h))
for x in xrange(0, w):
for y in xrange(0, h):
values = defaultdict(int)
for i in images:
k = tuple(i.get_at((x, y)))
values[k] += 1
value = sorted(values.items(), key=itemgetter(1))[-1]
newsurf.set_at((x, y), Color(*value[0]))
pygame.image.save(newsurf, 'normalized.png')
print "Done!"
return newsurf