當前位置: 首頁>>代碼示例>>Python>>正文


Python Texture.create方法代碼示例

本文整理匯總了Python中kivy.graphics.texture.Texture.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Texture.create方法的具體用法?Python Texture.create怎麽用?Python Texture.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kivy.graphics.texture.Texture的用法示例。


在下文中一共展示了Texture.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_drawings

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def create_drawings(self):
        from kivy.graphics import Line, RenderContext

        # very first time, create a texture for the shader
        if not hasattr(SmoothLinePlot, '_texture'):
            tex = Texture.create(size=(1, 64), colorfmt='rgb')
            tex.add_reload_observer(SmoothLinePlot._smooth_reload_observer)
            SmoothLinePlot._texture = tex
            SmoothLinePlot._smooth_reload_observer(tex)

        self._grc = RenderContext(
            fs=SmoothLinePlot.SMOOTH_FS,
            use_parent_modelview=True,
            use_parent_projection=True)
        with self._grc:
            self._gcolor = Color(*self.color)
            self._gline = Line(
                points=[], cap='none', width=2.,
                texture=SmoothLinePlot._texture)

        return [self._grc] 
開發者ID:wolfmanjm,項目名稱:kivy-smoothie-host,代碼行數:23,代碼來源:__init__.py

示例2: draw_mathtext

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def draw_mathtext(self, gc, x, y, s, prop, angle):
        '''Draw the math text using matplotlib.mathtext. The position
           x,y is given in Kivy coordinates.
        '''
        ftimage, depth = self.mathtext_parser.parse(s, self.dpi, prop)
        w = ftimage.get_width()
        h = ftimage.get_height()
        texture = Texture.create(size=(w, h))
        if _mpl_ge_1_5:
            texture.blit_buffer(ftimage.as_rgba_str()[0][0], colorfmt='rgba',
                                bufferfmt='ubyte')
        else:
            texture.blit_buffer(ftimage.as_rgba_str(), colorfmt='rgba',
                                bufferfmt='ubyte')
        texture.flip_vertical()
        with self.widget.canvas:
            Rectangle(texture=texture, pos=(x, y), size=(w, h)) 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:19,代碼來源:backend_kivy.py

示例3: __init__

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def __init__(self, **kwargs):
        global cap, frame, frame_size

        # capture and render the first frame
        self.frame_size = frame_size
        frame = cap.read()
        image = cv2.flip(frame, 0)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        image = cv2.resize(image, frame_size)
        buf = image.tostring()
        self.image_texture = Texture.create(size=(image.shape[1], image.shape[0]), colorfmt='rgb')
        self.image_texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')

        # coordinates of Trashy
        self.t_x = 0
        self.t_y = 0

        self.current_user = 'No user yet'
        self.tickcount = 0
        self.labels = ["can", "bottle", "ken",
                       "grace", "frank", "tim", "shelly"]
        self.users = ["ken", "grace", "frank", "tim", "shelly"]

        super(MainView, self).__init__(**kwargs)
        Clock.schedule_interval(self.tick, 0.06) 
開發者ID:tlkh,項目名稱:SmartBin,代碼行數:27,代碼來源:SmartBinApp.py

示例4: init_camera

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def init_camera(self):
        # create the device
        self._device = hg.cvCreateCameraCapture(self._index)

        # Set preferred resolution
        cv.SetCaptureProperty(self._device, cv.CV_CAP_PROP_FRAME_WIDTH,
                              self.resolution[0])
        cv.SetCaptureProperty(self._device, cv.CV_CAP_PROP_FRAME_HEIGHT,
                              self.resolution[1])

        # and get frame to check if it's ok
        frame = hg.cvQueryFrame(self._device)
        # Just set the resolution to the frame we just got, but don't use
        # self.resolution for that as that would cause an infinite recursion
        # with self.init_camera (but slowly as we'd have to always get a
        # frame).
        self._resolution = (int(frame.width), int(frame.height))

        #get fps
        self.fps = cv.GetCaptureProperty(self._device, cv.CV_CAP_PROP_FPS)
        if self.fps <= 0:
            self.fps = 1 / 30.

        if not self.stopped:
            self.start() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:27,代碼來源:camera_opencv.py

示例5: create_drawings

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def create_drawings(self):
        from kivy.graphics import Line, RenderContext
        from kivy.graphics.texture import Texture

        # very first time, create a texture for the shader
        if not hasattr(SmoothLinePlot, '_texture'):
            tex = Texture.create(size=(1, 64), colorfmt='rgb')
            tex.add_reload_observer(SmoothLinePlot._smooth_reload_observer)
            SmoothLinePlot._texture = tex
            SmoothLinePlot._smooth_reload_observer(tex)

        self._grc = RenderContext(fs=SmoothLinePlot.SMOOTH_FS,
                use_parent_modelview=True,
                use_parent_projection=True)
        with self._grc:
            self._gcolor = Color(*self.color)
            self._gline = Line(points=[], cap='none', width=2.,
                    texture=SmoothLinePlot._texture)

        return [self._grc] 
開發者ID:autosportlabs,項目名稱:RaceCapture_App,代碼行數:22,代碼來源:__init__.py

示例6: draw

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def draw(self, *args):
        super(ContourPlot, self).draw(*args)
        data = self.data
        xdim, ydim = data.shape

        # Find the minimum and maximum z values
        zmax = data.max()
        zmin = data.min()
        rgb_scale_factor = 1.0 / (zmax - zmin) * 255
        # Scale the z values into RGB data
        buf = np.array(data, dtype=float, copy=True)
        np.subtract(buf, zmin, out=buf)
        np.multiply(buf, rgb_scale_factor, out=buf)
        # Duplicate into 3 dimensions (RGB) and convert to byte array
        buf = np.asarray(buf, dtype=np.uint8)
        buf = np.expand_dims(buf, axis=2)
        buf = np.concatenate((buf, buf, buf), axis=2)
        buf = np.reshape(buf, (xdim, ydim, 3))

        charbuf = bytearray(np.reshape(buf, (buf.size)))
        self._texture = Texture.create(size=(xdim, ydim), colorfmt='rgb')
        self._texture.blit_buffer(charbuf, colorfmt='rgb', bufferfmt='ubyte')
        image = self._image
        image.texture = self._texture

        x_px = self.x_px()
        y_px = self.y_px()
        bl = x_px(self.xrange[0]), y_px(self.yrange[0])
        tr = x_px(self.xrange[1]), y_px(self.yrange[1])
        image.pos = bl
        w = tr[0] - bl[0]
        h = tr[1] - bl[1]
        image.size = (w, h) 
開發者ID:wolfmanjm,項目名稱:kivy-smoothie-host,代碼行數:35,代碼來源:__init__.py

示例7: draw

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def draw(self):
        '''
        Draw the figure using the agg renderer
        '''
        self.canvas.clear()
        FigureCanvasAgg.draw(self)
        if self.blitbox is None:
            l, b, w, h = self.figure.bbox.bounds
            w, h = int(w), int(h)
            buf_rgba = self.get_renderer().buffer_rgba()
        else:
            bbox = self.blitbox
            l, b, r, t = bbox.extents
            w = int(r) - int(l)
            h = int(t) - int(b)
            t = int(b) + h
            reg = self.copy_from_bbox(bbox)
            buf_rgba = reg.to_string()
        texture = Texture.create(size=(w, h))
        texture.flip_vertical()
        color = self.figure.get_facecolor()
        with self.canvas:
            Color(*color)
            Rectangle(pos=self.pos, size=(w, h))
            Color(1.0, 1.0, 1.0, 1.0)
            self.img_rect = Rectangle(texture=texture, pos=self.pos,
                                      size=(w, h))
        texture.blit_buffer(bytes(buf_rgba), colorfmt='rgba', bufferfmt='ubyte')
        self.img_texture = texture 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:31,代碼來源:backend_kivyagg.py

示例8: _print_image

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def _print_image(self, filename, *args, **kwargs):
        '''Write out format png. The image is saved with the filename given.
        '''
        l, b, w, h = self.figure.bbox.bounds
        img = None
        if self.img_texture is None:
            texture = Texture.create(size=(w, h))
            texture.blit_buffer(bytes(self.get_renderer().buffer_rgba()),
                                colorfmt='rgba', bufferfmt='ubyte')
            texture.flip_vertical()
            img = Image(texture)
        else:
            img = Image(self.img_texture)
        img.save(filename) 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:16,代碼來源:backend_kivyagg.py

示例9: print_png

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def print_png(self, filename, *args, **kwargs):
        '''Call the widget function to make a png of the widget.
        '''
        fig = FigureCanvasAgg(self.figure)
        FigureCanvasAgg.draw(fig)

        l, b, w, h = self.figure.bbox.bounds
        texture = Texture.create(size=(w, h))
        texture.blit_buffer(bytes(fig.get_renderer().buffer_rgba()),
                                colorfmt='rgba', bufferfmt='ubyte')
        texture.flip_vertical()
        img = Image(texture)
        img.save(filename) 
開發者ID:kivy-garden,項目名稱:garden.matplotlib,代碼行數:15,代碼來源:backend_kivy.py

示例10: update

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def update(self, dt):
        ret, frame = self.capture.read()
        if ret:
            # convert it to texture
            buf1 = cv2.flip(frame, 0)
            buf = buf1.tostring()
            image_texture = Texture.create(
                size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
            image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
            # display image from the texture
            self.texture = image_texture 
開發者ID:makelove,項目名稱:OpenCV-Python-Tutorial,代碼行數:13,代碼來源:kivy_cv1.py

示例11: _get_line_options

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def _get_line_options(self):
        # Get or create line options, to be used for Label creation
        if self._line_options is None:
            self._line_options = kw = {
                'font_size': self.font_size,
                'font_name': self.font_name,
                'anchor_x': 'left',
                'anchor_y': 'top',
                'padding_x': 0,
                'padding_y': 0,
                'padding': (0, 0)}
            self._label_cached = Label(**kw)
        return self._line_options 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:15,代碼來源:textinput.py

示例12: _update

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def _update(self, dt):
        sample, self._sample = self._sample, None
        if sample is None:
            return

        if self._texture is None and self._texturesize is not None:
            self._texture = Texture.create(
                size=self._texturesize, colorfmt='rgb')
            self._texture.flip_vertical()
            self.dispatch('on_load')

        # decode sample
        # read the data from the buffer memory
        try:
            buf = sample.get_buffer()
            result, mapinfo = buf.map(Gst.MapFlags.READ)

            # We cannot get the data out of mapinfo, using Gst 1.0.6 + Gi 3.8.0
            # related bug report:
            # https://bugzilla.gnome.org/show_bug.cgi?id=6t8663
            # ie: mapinfo.data is normally a char*, but here, we have an int
            # So right now, we use ctypes instead to read the mapinfo ourself.
            addr = mapinfo.__hash__()
            c_mapinfo = _MapInfo.from_address(addr)

            # now get the memory
            self._buffer = string_at(c_mapinfo.data, mapinfo.size)
            self._copy_to_gpu()
        finally:
            if mapinfo is not None:
                buf.unmap(mapinfo) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:33,代碼來源:camera_gi.py

示例13: _update

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def _update(self, dt):
        if self._buffer is None:
            return
        if self._texture is None and self._texturesize is not None:
            self._texture = Texture.create(
                size=self._texturesize, colorfmt='rgb')
            self._texture.flip_vertical()
            self.dispatch('on_load')
        self._copy_to_gpu() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:11,代碼來源:camera_pygst.py

示例14: init_camera

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def init_camera(self):
        # create the device
        self._device = Device(devnum=self._index, showVideoWindow=0)
        # set resolution
        try:
            self._device.setResolution(self.resolution[0], self.resolution[1])
        except:
            raise Exception('VideoCapture: Resolution not supported')
        self.fps = 1 / 30. 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:11,代碼來源:camera_videocapture.py

示例15: _update

# 需要導入模塊: from kivy.graphics.texture import Texture [as 別名]
# 或者: from kivy.graphics.texture.Texture import create [as 別名]
def _update(self, dt):
        data, camera_width, camera_height = self._device.getBuffer()
        if self._texture is None:
            # first update, resize if necessary
            self.size = camera_width, camera_height
            # and create texture
            from kivy.graphics.texture import Texture
            self._texture = Texture.create(size=self.size, colorfmt='rgb')
            self.dispatch('on_load')

        # update buffer
        self._buffer = data
        self._copy_to_gpu() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:15,代碼來源:camera_videocapture.py


注:本文中的kivy.graphics.texture.Texture.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。