当前位置: 首页>>代码示例>>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;未经允许,请勿转载。