示例#1
0
    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)
示例#2
0
    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)
示例#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
文件: video.py 项目: azoon/pymt
 def draw(self):
     b = self.bordersize
     b2 = b * 2
     pymt.set_color(*self.style['bg-color'])
     pymt.drawCSSRectangle((-b, -b), (self.width + b2, self.height + b2),
                           style=self.style)
     super(MTVideo, self).draw()
示例#5
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))
示例#6
0
 def draw(self):
     if self.ctx.mode == 'layout':
         set_color(0, 0.7, 0)
         drawRectangle(pos=(-10,-10),size=(self.width+20,self.height+20))
         drawLabel(label=str(self.parent.groupid), pos=(-12, -10),
                   color=(1, 1, 1), center=False)
     elif self.ctx.mode == 'edit':
         set_color(0.7, 0.7, 0)
         drawRectangle(pos=(-10,-10),size=(self.width+20,self.height+20))
示例#7
0
文件: touchring.py 项目: azoon/pymt
    def draw(self):
        for touch in getCurrentTouches():
            if 'kinetic' in touch.profile:
                set_color(1, 1, 1, .2)
            else:
                set_color(1, 1, 1, .7)

            # draw touch
            ring_img.pos = touch.pos
            ring_img.draw()
示例#8
0
 def draw(self):
     if not self.show_grid:
         return
     set_color(*self.style.get('grid-color'))
     glLineWidth(1)
     glEnableClientState(GL_VERTEX_ARRAY)
     self.vbo.bind()
     glVertexPointer(2, GL_FLOAT, 0, None)
     glDrawArrays(GL_LINES, 0, self.lcount)
     self.vbo.unbind()
     glDisableClientState(GL_VERTEX_ARRAY)
示例#9
0
    def draw(self):
        t = getClock().get_time()
        touches = getCurrentTouches()

        # draw closed touches
        to_delete = []
        ids = [touch.id for touch in touches]
        for id in self.closetouches:
            if not id in ids:
                to_delete.append(id)
                continue
            touch = self.closetouches[id]
            value = ((t - touch.time_start) - 1) / 2.
            if value > 1:
                self.do_close()
                return
            set_color(1, 1, 1, .7)
            drawSemiCircle(pos=(touch.x, touch.y),
                           inner_radius=30,
                           outer_radius=50,
                           slices=64,
                           sweep_angle=value * 360)

        # delete old touches
        for id in to_delete:
            del self.closetouches[id]

        # search
        for touch in touches:
            if 'closeapp.invalid_for_close' in touch.userdata:
                continue
            # distance < 20
            if Vector(touch.osxpos, touch.osypos).distance(
                    Vector(touch.sx, touch.sy)) > 0.015:
                # flag
                touch.userdata['closeapp.invalid_for_close'] = True
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # 1s minimum
            if t - touch.time_start < 1:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # check corner screen
            if touch.sx < .75 or touch.sy < .75:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # add touches to closed touches
            self.closetouches[touch.id] = touch
示例#10
0
文件: closeapp.py 项目: Markitox/pymt
    def draw(self):
        t = getClock().get_time()
        touches = getCurrentTouches()

        # draw closed touches
        to_delete = []
        ids = [touch.id for touch in touches]
        for id in self.closetouches:
            if not id in ids:
                to_delete.append(id)
                continue
            touch = self.closetouches[id]
            value = ((t - touch.time_start) - 1) / 2.
            if value > 1:
                self.do_close()
                return
            set_color(1, 1, 1, .7)
            drawSemiCircle(pos=(touch.x, touch.y), inner_radius=30, outer_radius=50, slices=64, sweep_angle=value*360)

        # delete old touches
        for id in to_delete:
            del self.closetouches[id]

        # search
        for touch in touches:
            if 'closeapp.invalid_for_close' in touch.userdata:
                continue
            # distance < 20
            if Vector(*touch.opos).distance(Vector(touch.sx, touch.sy)) > 0.015:
                # flag
                touch.userdata['closeapp.invalid_for_close'] = True
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # 1s minimum
            if t - touch.time_start < 1:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # check corner screen
            if touch.sx < .75 or touch.sy < .75:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # add touches to closed touches
            self.closetouches[touch.id] = touch
示例#11
0
 def on_draw(self):
     w, h = getWindow().size
     with gx_matrix:
         glMultMatrixf(self.transform_mat)
         self.draw()
         for child in [x for x in self.children if x.do_draw]:
             child.dispatch_event('on_draw')
         # draw pen
         glLineWidth(3)
         set_color(.8, .8, .8, .8)
         for x in self.linepen:
             drawLine(x)
         # draw selection
         if len(self.selection) > 2:
             set_color(.2, .6, .2, .8)
             drawLine(self.selection)
             set_color(.2, .6, .2, .3)
             drawLine(self.selection[-1] + self.selection[0])
示例#12
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)
示例#13
0
 def draw_drag_icon(self=None):
     set_color(1,0,1)
     drawRectangle(pos=(-30,-30),size=(60,60))
示例#14
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

        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)
示例#15
0
文件: video.py 项目: azoon/pymt
 def draw(self):
     pymt.set_color(*self.style['bg-color'])
     pymt.drawCSSRectangle(pos=self.pos, size=self.size, style=self.style)
     self.image.color = self.style['color']
     super(MTButtonVideo, self).draw()