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


Python Surface.set_at方法代码示例

本文整理汇总了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)
开发者ID:bitcraft,项目名称:lpc1,代码行数:29,代码来源:dialog.py

示例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
开发者ID:fmoo,项目名称:gamedata,代码行数:17,代码来源:screenprocess.py

示例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
开发者ID:fmoo,项目名称:gamedata,代码行数:26,代码来源:screenprocess.py


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