Exemplo n.º 1
0
 def draw(self):
     if self._texture:
         set_color(*self.color)
         drawTexturedRectangle(texture=self._texture, pos=self.pos, size=self.size)
     else:
         set_color(0, 0, 0)
         drawRectangle(pos=self.pos, size=self.size)
Exemplo n.º 2
0
 def draw(self):
     '''Draw the image on screen'''
     imgpos = (int(self.x - self.anchor_x * self.scale),
               int(self.y - self.anchor_y * self.scale))
     r, g, b = self.color[:3]
     with DO(gx_color(r, g, b, self.opacity), gx_blending):
         drawTexturedRectangle(texture=self.texture, pos=imgpos, size=(self.size[0] * self.scale, self.size[1] * self.scale))
Exemplo n.º 3
0
 def draw(self):
     '''Draw the image on screen'''
     imgpos = (int(self.x - self.anchor_x * self.scale),
               int(self.y - self.anchor_y * self.scale))
     r, g, b = self.color[:3]
     with DO(gx_color(r, g, b, self.opacity), gx_blending):
         drawTexturedRectangle(texture=self.texture, pos=imgpos, size=(self.size[0] * self.scale, self.size[1] * self.scale))
Exemplo n.º 4
0
 def draw(self):
     '''Draw the current image camera'''
     if self._texture:
         set_color(*self.color)
         drawTexturedRectangle(self._texture, pos=self.pos, size=self.size)
     else:
         drawRectangle(pos=self.pos, size=self.size)
         drawLabel('No Camera :(', pos=(self.width/2, self.height/2))
Exemplo n.º 5
0
 def draw(self):
     if self._texture:
         set_color(*self.color)
         drawTexturedRectangle(texture=self._texture,
                               pos=self.pos,
                               size=self.size)
     else:
         set_color(0, 0, 0)
         drawRectangle(pos=self.pos, size=self.size)
Exemplo n.º 6
0
    def _render_cover(self, index):
        # render the children on a fbo
        child = self.children[index]
        with self._fbo:
            self._fbo.clear()
            child.dispatch_event('on_draw')

        # pre-calculate
        y2 = self.center[1] - self.thumbnail_size[1] / 2.
        angle, x = self._get_cover_position(index, 0)

        # if a transition is in way,
        # use it to calculate angle/position from
        # current position and future position
        if self._transition != 0:
            i2 = index
            if self._transition > 0:
                i2 -= 1
            elif self._transition < 0:
                i2 += 1

            i2          = min(max(-1, i2), len(self.children))
            angle2, x2  = self._get_cover_position(i2, self._transition)

            # do linear alpha
            if self._transition > 0:
                angle   += self._transition * (angle2 - angle)
                x       += self._transition * (x2 - x)
            else:
                angle   -= self._transition * (angle2 - angle)
                x       -= self._transition * (x2 - x)

        # calculate alpha coordinate
        # this is to make cover more darker on the farest side
        # and make brighter the current displayed cover

        a = 1. - .7 * (angle / 90.)
        alpha_coords = (
            (1, 1, 1, 0), (a, a, a, 0),
            (a, a, a, 0), (1, 1, 1, 0))

        # draw !
        glTranslatef(x, y2, 0)
        glRotatef(angle, 0, 1, 0)

        # draw the cover
        if self.cover_blend:
            set_color(1, blend=True)
            drawTexturedRectangle(
                texture=self._fbo.texture,
                size=self.thumbnail_size,
                color_coords=self._cover_blend_coords)
        else:
            set_color(1)
            drawTexturedRectangle(
                texture=self._fbo.texture,
                size=self.thumbnail_size,
                color_coords=alpha_coords)

        # now, for reflection, don't do matrix transformation
        # just invert texcoord + play with color
        old_texcoords = self._fbo.texture.tex_coords
        self._fbo.texture.flip_vertical()
        self._fbo.texture.tex_coords = list(self._fbo.texture.tex_coords)
        self._fbo.texture.tex_coords[1] = self.reflection_percent
        self._fbo.texture.tex_coords[3] = self.reflection_percent

        # draw reflection
        pos = (0, -self.thumbnail_size[1] * self.reflection_percent)
        size = (self.thumbnail_size[0], self.thumbnail_size[1] * self.reflection_percent)

        # activate blending with background ?
        if self.reflection_blend:
            set_color(*self.style['bg-color'])
            drawRectangle(pos=pos, size=size)
            set_color(1, 1, 1, blend=True)

        drawTexturedRectangle(
            texture=self._fbo.texture,
            pos=pos, size=size,
            color_coords=self._reflection_coords)

        # restore fbo tex_coords
        self._fbo.texture.tex_coords = old_texcoords

        # reset our position changes
        glRotatef(angle, 0, -1, 0)
        glTranslatef(-x, -y2, 0)
Exemplo n.º 7
0
    def _render_cover(self, index):
        # render the children on a fbo
        child = self.children[index]
        with self._fbo:
            self._fbo.clear()
            child.dispatch_event('on_draw')

        # pre-calculate
        y2 = self.center[1] - self.thumbnail_size[1] / 2.
        angle, x = self._get_cover_position(index, 0)

        # if a transition is in way,
        # use it to calculate angle/position from
        # current position and future position
        if self._transition != 0:
            i2 = index
            if self._transition > 0:
                i2 -= 1
            elif self._transition < 0:
                i2 += 1

            i2 = min(max(-1, i2), len(self.children))
            angle2, x2 = self._get_cover_position(i2, self._transition)

            # do linear alpha
            if self._transition > 0:
                angle += self._transition * (angle2 - angle)
                x += self._transition * (x2 - x)
            else:
                angle -= self._transition * (angle2 - angle)
                x -= self._transition * (x2 - x)

        # calculate alpha coordinate
        # this is to make cover more darker on the farest side
        # and make brighter the current displayed cover

        a = 1. - .7 * (angle / 90.)
        alpha_coords = ((1, 1, 1, 0), (a, a, a, 0), (a, a, a, 0), (1, 1, 1, 0))

        # draw !
        glTranslatef(x, y2, 0)
        glRotatef(angle, 0, 1, 0)

        # draw the cover
        if self.cover_blend:
            set_color(1, blend=True)
            drawTexturedRectangle(texture=self._fbo.texture,
                                  size=self.thumbnail_size,
                                  color_coords=self._cover_blend_coords)
        else:
            set_color(1)
            drawTexturedRectangle(texture=self._fbo.texture,
                                  size=self.thumbnail_size,
                                  color_coords=alpha_coords)

        # now, for reflection, don't do matrix transformation
        # just invert texcoord + play with color
        old_texcoords = self._fbo.texture.tex_coords
        self._fbo.texture.flip_vertical()
        self._fbo.texture.tex_coords = list(self._fbo.texture.tex_coords)
        self._fbo.texture.tex_coords[1] = self.reflection_percent
        self._fbo.texture.tex_coords[3] = self.reflection_percent

        # draw reflection
        pos = (0, -self.thumbnail_size[1] * self.reflection_percent)
        size = (self.thumbnail_size[0],
                self.thumbnail_size[1] * self.reflection_percent)

        # activate blending with background ?
        if self.reflection_blend:
            set_color(*self.style['bg-color'])
            drawRectangle(pos=pos, size=size)
            set_color(1, 1, 1, blend=True)

        drawTexturedRectangle(texture=self._fbo.texture,
                              pos=pos,
                              size=size,
                              color_coords=self._reflection_coords)

        # restore fbo tex_coords
        self._fbo.texture.tex_coords = old_texcoords

        # reset our position changes
        glRotatef(angle, 0, -1, 0)
        glTranslatef(-x, -y2, 0)