コード例 #1
0
ファイル: __init__.py プロジェクト: vidriloco/pymt
    def draw(self):
        '''Draw the label'''
        if self.texture is None:
            return

        x, y = self.pos
        w, h = self.size
        anchor_x = self.options['anchor_x']
        anchor_y = self.options['anchor_y']

        if anchor_x == 'left':
            pass
        elif anchor_x in ('center', 'middle'):
            x -= w * 0.5
        elif anchor_x == 'right':
            x -= w

        if anchor_y == 'bottom':
            pass
        elif anchor_y in ('center', 'middle'):
            y -= h * 0.5
        elif anchor_y == 'top':
            y -= h

        pymt.set_color(*self.color, blend=True)
        pymt.drawTexturedRectangle(
            texture=self.texture,
            pos=(int(x), int(y)), size=self.texture.size)
コード例 #2
0
ファイル: __init__.py プロジェクト: triselectif/pymt
    def draw(self):
        '''Draw the label'''
        if self.texture is None:
            return

        x, y = self.pos
        w, h = self.size
        anchor_x = self.options['anchor_x']
        anchor_y = self.options['anchor_y']
        padding_x = self.options['padding_x']
        padding_y = self.options['padding_y']

        if anchor_x == 'left':
            x += padding_x
        elif anchor_x in ('center', 'middle'):
            x -= w * 0.5
        elif anchor_x == 'right':
            x -= w + padding_x

        if anchor_y == 'bottom':
            y += padding_y
        elif anchor_y in ('center', 'middle'):
            y -= h * 0.5
        elif anchor_y == 'top':
            y -= h - padding_y

        alpha = 1
        if len(self.options['color']) > 3:
            alpha = self.options['color'][3]
        pymt.set_color(1, 1, 1, alpha, blend=True)
        pymt.drawTexturedRectangle(
            texture=self.texture,
            pos=(int(x), int(y)), size=self.texture.size)
コード例 #3
0
    def draw(self):
        """Draw the label"""
        if self.texture is None:
            return
        if not len(self.label):
            # it's a empty label, don't waste time to draw it
            return

        x, y = self.pos
        w, h = self.size
        anchor_x = self.options["anchor_x"]
        anchor_y = self.options["anchor_y"]
        padding_x = self.options["padding_x"]
        padding_y = self.options["padding_y"]

        if anchor_x == "left":
            x += padding_x
        elif anchor_x in ("center", "middle"):
            x -= w * 0.5
        elif anchor_x == "right":
            x -= w + padding_x

        if anchor_y == "bottom":
            y += padding_y
        elif anchor_y in ("center", "middle"):
            y -= h * 0.5
        elif anchor_y == "top":
            y -= h - padding_y

        alpha = 1
        if len(self.options["color"]) > 3:
            alpha = self.options["color"][3]
        pymt.set_color(1, 1, 1, alpha, blend=True)
        pymt.drawTexturedRectangle(texture=self.texture, pos=(int(x), int(y)), size=self.texture.size)
コード例 #4
0
ファイル: __init__.py プロジェクト: bernt/pymt
 def draw(self):
     '''Draw the current image camera'''
     if self._texture:
         pymt.set_color(*self.color)
         pymt.drawTexturedRectangle(self._texture, pos=self.pos, size=self.size)
     else:
         pymt.drawRectangle(pos=self.pos, size=self.size)
         pymt.drawLabel('No Camera :(', pos=(self.width/2, self.height/2))
コード例 #5
0
ファイル: __init__.py プロジェクト: hansent/pymt
    def draw(self):
        '''Draw the label'''
        if self.texture is None:
            return
        if not len(self.label):
            # it's a empty label, don't waste time to draw it
            return

        dx = 0
        dy = 0
        x, y = self.pos
        w, h = self.size
        anchor_x = self.options['anchor_x']
        anchor_y = self.options['anchor_y']
        padding_x = self.options['padding_x']
        padding_y = self.options['padding_y']

        viewport_size = self.viewport_size
        viewport_pos = self.viewport_pos

        # if a viewport is given, use the size of viewport.
        if viewport_size:
            vw, vh = viewport_size
            if vw < w:
                w = vw
            if vh < h:
                h = vh

        if anchor_x == 'left':
            x += padding_x
        elif anchor_x in ('center', 'middle'):
            x -= w * 0.5
        elif anchor_x == 'right':
            x -= w + padding_x

        if anchor_y == 'bottom':
            y += padding_y
        elif anchor_y in ('center', 'middle'):
            y -= h * 0.5
        elif anchor_y == 'top':
            y -= h - padding_y

        alpha = 1
        if len(self.options['color']) > 3:
            alpha = self.options['color'][3]
        pymt.set_color(1, 1, 1, alpha, blend=True)

        texture = self.texture
        size = list(texture.size)
        texc = texture.tex_coords[:]
        if viewport_size:
            vw, vh = map(float, viewport_size)
            tw, th = map(float, size)
            oh, ow = tch, tcw = texc[1:3]
            tcx, tcy = 0, 0
            if vw < tw:
                tcw = (vw / tw) * tcw
                size[0] = vw
            if vh < th:
                tch = (vh / th) * tch
                size[1] = vh

            if viewport_pos:
                tcx, tcy = viewport_pos
                # 100
                tcx = tcx / tw * ow
                tcy = tcy / th * oh

            # FIXME work only with flipped texture ?
            # GH EF
            # AB CD
            # usual: a, b, c, d, e, f, g, h
            # flip: g, h, e, f, c, d, a, b
            # usual: tcx, tcy, tcx+tcw, tcy, tcx+tcw, tcy+tch, tcx, tcy+tch
            texc = (tcx, tcy+tch, tcx+tcw, tcy+tch, tcx+tcw, tcy, tcx, tcy)
        pymt.drawTexturedRectangle(
            texture=texture,
            pos=(int(x), int(y)),
            size=size,
            tex_coords=texc)
コード例 #6
0
ファイル: __init__.py プロジェクト: gavine199/pymt
    def draw(self):
        '''Draw the label'''
        if self.texture is None:
            return
        if not len(self.label):
            # it's a empty label, don't waste time to draw it
            return

        dx = 0
        dy = 0
        x, y = self.pos
        w, h = self.size
        anchor_x = self.options['anchor_x']
        anchor_y = self.options['anchor_y']
        padding_x = self.options['padding_x']
        padding_y = self.options['padding_y']

        viewport_size = self.viewport_size
        viewport_pos = self.viewport_pos

        # if a viewport is given, use the size of viewport.
        if viewport_size:
            vw, vh = viewport_size
            if vw < w:
                w = vw
            if vh < h:
                h = vh

        if anchor_x == 'left':
            x += padding_x
        elif anchor_x in ('center', 'middle'):
            x -= w * 0.5
        elif anchor_x == 'right':
            x -= w + padding_x

        if anchor_y == 'bottom':
            y += padding_y
        elif anchor_y in ('center', 'middle'):
            y -= h * 0.5
        elif anchor_y == 'top':
            y -= h - padding_y

        alpha = 1
        if len(self.options['color']) > 3:
            alpha = self.options['color'][3]
        pymt.set_color(1, 1, 1, alpha, blend=True)

        texture = self.texture
        size = list(texture.size)
        texc = texture.tex_coords[:]
        if viewport_size:
            vw, vh = map(float, viewport_size)
            tw, th = map(float, size)
            oh, ow = tch, tcw = texc[1:3]
            tcx, tcy = 0, 0
            if vw < tw:
                tcw = (vw / tw) * tcw
                size[0] = vw
            if vh < th:
                tch = (vh / th) * tch
                size[1] = vh

            if viewport_pos:
                tcx, tcy = viewport_pos
                # 100
                tcx = tcx / tw * ow
                tcy = tcy / th * oh

            # FIXME work only with flipped texture ?
            # GH EF
            # AB CD
            # usual: a, b, c, d, e, f, g, h
            # flip: g, h, e, f, c, d, a, b
            # usual: tcx, tcy, tcx+tcw, tcy, tcx+tcw, tcy+tch, tcx, tcy+tch
            texc = (tcx, tcy + tch, tcx + tcw, tcy + tch, tcx + tcw, tcy, tcx,
                    tcy)
        pymt.drawTexturedRectangle(texture=texture,
                                   pos=(int(x), int(y)),
                                   size=size,
                                   tex_coords=texc)