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


Python Surface.lock方法代码示例

本文整理汇总了Python中pygame.surface.Surface.lock方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.lock方法的具体用法?Python Surface.lock怎么用?Python Surface.lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame.surface.Surface的用法示例。


在下文中一共展示了Surface.lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: activate

# 需要导入模块: from pygame.surface import Surface [as 别名]
# 或者: from pygame.surface.Surface import lock [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: render

# 需要导入模块: from pygame.surface import Surface [as 别名]
# 或者: from pygame.surface.Surface import lock [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
开发者ID:MacLeek,项目名称:mh,代码行数:55,代码来源:mob.py


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