コード例 #1
0
    def bevel(self, surface, inner=False):
        """
		Applies a raised bevel effect to this Widget's initial background surface.
		"""
        color_tuple = self.current_background_color()
        surface.fill(color_tuple)
        color = Color(*color_tuple)
        highlight = color.correct_gamma(2) if inner else color.correct_gamma(
            0.75)
        shadow = color.correct_gamma(0.5) if inner else color.correct_gamma(
            1.5)
        bd = self.bevel_depth
        polygon(
            surface,
            highlight,
            [  # top
                (0, 0), (self.rect.width, 0), (self.rect.width - bd, bd),
                (bd, bd)
            ])
        polygon(
            surface,
            shadow,
            [  # right
                (self.rect.width, 0), (self.rect.width, self.rect.height),
                (self.rect.width - bd, self.rect.height - bd),
                (self.rect.width - bd, bd)
            ])
        polygon(
            surface,
            shadow,
            [  # bottom
                (self.rect.width, self.rect.height), (0, self.rect.height),
                (bd, self.rect.height - bd),
                (self.rect.width - bd, self.rect.height - bd)
            ])
        polygon(
            surface,
            highlight,
            [  # left
                (0, 0), (bd, bd), (bd, self.rect.height - bd),
                (0, self.rect.height)
            ])
        return surface
コード例 #2
0
    def get_surface(self):
        """
		Returns a Surface to use as this element's background, decorated with whichever effect function
		is set on this widget having been applied.
		"""
        surface = Surface(self.rect.size)
        surface.fill(self.current_background_color())

        color = Color(*self.current_background_color())
        highlight = color.correct_gamma(2)
        shadow = color.correct_gamma(0.5)
        arc(surface, shadow, self._circle_rect, RADIANS_TOPRIGHT,
            RADIANS_BOTTOM_LEFT, self.bevel_depth)
        arc(surface, highlight, self._circle_rect, RADIANS_BOTTOM_LEFT,
            RADIANS_TOPRIGHT, self.bevel_depth)

        if self.selected:
            circle(surface, self.dot_color, self._circle_rect.center,
                   self.dot_radius)

        for att in ["disabled", "focused", "hovering"]:
            setattr(self._label, att, getattr(self, att))
        surface.blit(self._label.get_surface(), self._label_rect.topleft)
        return surface