Пример #1
0
 def GenerateSurface(self):
     text = fonts.BebasNeue.c30.render(self.title, 1, (255, 255, 255))
     surface = pygame.surface.Surface((self.length, 50))
     #images.FillWithBack(surface, images.Backgrounds.back1)
     images.FillWithColor(surface, self.background[0], self.background[1])
     surface.blit(text, GetCenter(surface, text))
     self.surface = surface
Пример #2
0
    def __init__(self,
                 text,
                 width=200,
                 position=(0, 0),
                 font=fonts.BebasNeue.c30):
        self.text = text
        text = font.render(text, 1, (255, 255, 255))

        imageA = pygame.surface.Surface((width, text.get_size()[1] + 5))
        images.FillWithColor(imageA, (0, 0, 0), (0, 0, 100))
        imageA.blit(text, GetCenter(imageA, text))
        AddBorder(imageA)

        imageB = pygame.surface.Surface((width, text.get_size()[1] + 5))
        images.FillWithColor(imageB, (0, 0, 50), (0, 0, 150))
        imageB.blit(text, GetCenter(imageB, text))
        AddBorder(imageB)

        imageC = pygame.surface.Surface((width, text.get_size()[1] + 5))
        images.FillWithColor(imageC, (0, 0, 100), (0, 0, 200))
        imageC.blit(text, GetCenter(imageC, text))
        AddBorder(imageC)

        Button.__init__(self, imageA, imageB, imageC, position)
Пример #3
0
    def GenerateSurface(self):
        #text = fonts.BebasNeue.c25.render(self)
        surfaces = []

        x_sum = 0
        for key in self.keys:
            key_name = key.title
            key_length = key.length
            surfaceA = pygame.surface.Surface((key_length, 30),
                                              pygame.SRCALPHA)
            surfaceB = pygame.surface.Surface((key_length, 30),
                                              pygame.SRCALPHA)

            background = pygame.surface.Surface((key_length, 30))
            #images.FillWithBack(background, images.Backgrounds.back6)
            images.FillWithColor(background, self.backA, self.backB)

            surfaceB.blit(background, (0, 0))
            background.set_alpha(50)
            surfaceA.blit(background, (0, 0))

            text = fonts.BebasNeue.c25.render(self.content[key_name], 1,
                                              (255, 255, 255))
            surfaceA.blit(text, GetCenter(surfaceA, text))
            surfaceB.blit(text, GetCenter(surfaceB, text))

            x_sum += key_length + 1
            surfaces.append({"ss": surfaceA, "s2": surfaceB, "ww": key_length})

        finalSurface = pygame.surface.Surface((x_sum, 30), pygame.SRCALPHA)
        finalSurfaceB = pygame.surface.Surface((x_sum, 30), pygame.SRCALPHA)
        actual_x = 0
        for s in surfaces:
            finalSurface.blit(s["ss"], (actual_x, 0))
            finalSurfaceB.blit(s["s2"], (actual_x, 0))
            actual_x += s["ww"] + 1
        self.surface = finalSurface
        self.surfaceB = finalSurfaceB
Пример #4
0
    def GraphicUpdate(self, screen):
        my_surface = pygame.surface.Surface((self.width, self.height + 50))
        images.FillWithColor(my_surface, self.background[0],
                             self.background[1])

        if self.bar:
            min_fix = 0
            max_fix = len(self.contents) * 30 - self.height
            fix = abs(min_fix - max_fix) * self.bar.position
            actual_y = 50 - fix
        else:
            actual_y = 50
        for row in self.contents:
            my_surface.blit(row.GetSurface(), (0, actual_y))
            actual_y += 30

        current_x = 0
        for key in self.keys:
            my_surface.blit(key.surface, (current_x, 0))
            current_x += key.surface.get_size()[0] + 1

        screen.blit(my_surface, (self.x, self.y))
        if self.bar:
            self.bar.GraphicUpdate(screen)
Пример #5
0
def ButtonImage(text, background, type, size=None):
    ###### BUTTON DRAW ######

    ###### CLASSIC BUTTON #####
    if type == BUTTON_IMAGES.CLASSIC.NORMAL:
        textFont = fonts.PixelSplitter.c11.render(text, 0, (0, 0, 0))
        if size == None:
            tfw, tfh = textFont.get_size()
        else:
            tfw, tfh = size
        surface = pygame.surface.Surface((tfw + 20, 16))
        surface.fill(background)
        AddBorder(surface, 1, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface
    elif type == BUTTON_IMAGES.CLASSIC.FOCUSED:
        textFont = fonts.PixelSplitter.c12.render(text, 0, (0, 0, 0))
        if size == None:
            tfw, tfh = textFont.get_size()
        else:
            tfw, tfh = size
        surface = pygame.surface.Surface((tfw + 20, 16))
        surface.fill(background)
        AddBorder(surface, 2, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface
    elif type == BUTTON_IMAGES.CLASSIC.PRESSED:
        textFont = fonts.PixelSplitter.c13.render(text, 0, (0, 0, 0))
        if size == None:
            tfw, tfh = textFont.get_size()
        else:
            tfw, tfh = size
        surface = pygame.surface.Surface((tfw + 20, 16))
        surface.fill(background)
        AddBorder(surface, 3, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface

    ###### CONNECT BUTTON #####
    elif type == BUTTON_IMAGES.CONNECT.NORMAL:
        textFont = fonts.BebasNeue.c60.render(text, 1, (0, 0, 0))
        tfw, tfh = textFont.get_size()
        surface = pygame.surface.Surface((tfw + 300, 80))
        images.FillWithColor(surface, (255, 255, 0), (200, 200, 0))
        AddBorder(surface, 1, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface
    elif type == BUTTON_IMAGES.CONNECT.FOCUSED:
        textFont = fonts.BebasNeue.c60.render(text, 1, (100, 100, 100))
        tfw, tfh = textFont.get_size()
        surface = pygame.surface.Surface((tfw + 300, 80))
        images.FillWithColor(surface, (255, 255, 0), (200, 200, 0))
        AddBorder(surface, 4, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface
    elif type == BUTTON_IMAGES.CONNECT.PRESSED:
        textFont = fonts.BebasNeue.c60.render(text, 1, (0, 0, 0))
        tfw, tfh = textFont.get_size()
        surface = pygame.surface.Surface((tfw + 300, 80))
        images.FillWithColor(surface, (100, 100, 0), (200, 200, 0))
        AddBorder(surface, 4, (0, 0, 0))
        surface.blit(textFont, GetCenter(surface, textFont))
        return surface