Exemple #1
0
    def draw(self):
        ## Init surface as screen
        surface = pygame.Surface(self.screen_size)

        ## List of buttons that need to be rendered
        list_of_render = []

        ## If the list is not hidden
        if (self.see):
            button_width = self.screen_width * self.button_size_per  ## Button width
            button_height = self.screen_height * self.button_size_per  ## Button height

            gap_x = self.screen_width * self.gap_x_per  ## Button indentation
            gap_y = self.screen_height * self.gap_y_per  ## Gap between buttons

            inner_left_margin = self.screen_width * self.inner_surface_mar_per * self.width_ratio  ## 'Center' inner horizontally
            inner_top_margin = self.screen_height * self.inner_surface_mar_per * self.height_ratio  ## 'Center' inner vertically

            text_left_margin = self.screen_width * self.text_mar_per * self.width_ratio  ## 'Center' text horizontally
            text_top_margin = self.screen_height * self.text_mar_per * self.height_ratio  ## 'Center' text vertically

            total_width = button_width  ## Width of returning surface
            total_height = (len(self.current) - 1) * (
                gap_y + button_height) + (2 * button_height
                                          )  ## Height of returning surface

            top = int(self.screen_height / 2) - int(
                total_height / 2)  ## Top position of buttons

            active_check = False  ## Check if active button has been passed

            ## Run through current buttons and render them
            for x in range(0, len(self.current)):
                ## Find y_position of button
                y = top + (x * (gap_y + button_height))

                if active_check == True:
                    y += button_height

                if self.current[x].active == True:
                    surface.blit(self.current[x].get_surface(),
                                 (gap_x, y))  ## Position button
                    surface.blit(self.current[x].get_inner(), (gap_x + (inner_left_margin * 2) \
                    , y + (inner_top_margin * 2))) ## Position inner
                    surface.blit(self.current[x].get_text(), (gap_x + (inner_left_margin * 2) + (text_left_margin * 2) \
                    , y + (inner_top_margin * 2) + (text_top_margin * 2))) ## Position text in button
                    active_check = True
                else:
                    surface.blit(self.current[x].get_surface(),
                                 (gap_x, y))  ## Position button
                    surface.blit(self.current[x].get_inner(),
                                 (gap_x + inner_left_margin,
                                  y + inner_top_margin))  ## Position inner
                    surface.blit(self.current[x].get_text(), (gap_x + inner_left_margin + text_left_margin \
                    , y + inner_top_margin + text_top_margin)) ## Position text in button

                list_of_render.append(rendering.Render_Surface(
                    surface))  ## Append current button

        return list_of_render
Exemple #2
0
 def __init__(self):
     rendering.Drawable.__init__(self)
     surface = pygame.Surface((100, 50))  # create the surface
     surface.fill((0, 0, 255))  # make it blue
     # return a 3d Render_Surface (has a depth=500)
     self.set_draw_target(rendering.Render_Surface(surface, (200, 300),
                                                   200))
Exemple #3
0
 def __init__(self):
     rendering.Drawable.__init__(self)
     surface = pygame.Surface((100, 50))  # create the surface
     surface.fill((0, 255, 0))  # make it green
     # return a Render_Surface at (50,200)
     self.set_draw_target(
         rendering.Render_Surface(surface, position=(50, 200)))
Exemple #4
0
    def draw(self):
        surface = pygame.Surface(self.surface_size)

        if self.connection == True:
            gap_x = self.surface_size[0] * .1
            gap_y = self.surface_size[1] * .1

            button_width = self.surface_size[0] * .2
            button_height = self.surface_size[1] * .1

            button_x = self.surface_size[0] - gap_x - button_width
            button_y = gap_y

            text_width = button_width * .9
            text_height = button_height * .9

            text_left_margin = button_width * .025
            text_top_margin = button_height * .025

            s = pygame.Surface((button_width, button_height))
            s.fill((0, 138, 254))

            #!!text = self.font.render(self.name, True, (1, 1, 1))
            text = self.font.render("Call: " + self.name, True, (1, 1, 1))
            text = pygame.transform.scale(text,
                                          (int(text_width), int(text_height)))

            surface.blit(s, (button_x, button_y))
            surface.blit(
                text,
                (button_x + text_left_margin, button_y + text_top_margin))
        return rendering.Render_Surface(surface)
Exemple #5
0
 def __init__(self, location=(100, 150), size=(100, 50)):
     rendering.Drawable.__init__(self)
     self.location = location
     self.size = size
     self.surface = pygame.Surface(self.size)  # create the surface
     self.surface.fill((255, 0, 0))  # fill it with red
     self.set_draw_target(
         rendering.Render_Surface(
             self.surface, position=self.location))  # create the surface
Exemple #6
0
 def update(self, book):
     pose = book.pose_source.position
     new_location = (int(-pose[0]), int(-pose[1])
                     )  # grab x/y from pose, convert to int
     if not (new_location
             == self.location):  # only update surface on change
         self.location = new_location  # update the location
         self.set_draw_target(
             rendering.Render_Surface(
                 self.surface,
                 position=self.location))  # update the surface