当前位置: 首页>>代码示例>>Python>>正文


Python graphics.Rectangle方法代码示例

本文整理汇总了Python中kivy.graphics.Rectangle方法的典型用法代码示例。如果您正苦于以下问题:Python graphics.Rectangle方法的具体用法?Python graphics.Rectangle怎么用?Python graphics.Rectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.graphics的用法示例。


在下文中一共展示了graphics.Rectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_mathtext

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [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

示例2: draw_rubberband

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def draw_rubberband(self, event, x0, y0, x1, y1):
        w = abs(x1 - x0)
        h = abs(y1 - y0)
        rect = [int(val)for val in (min(x0, x1) + self.canvas.x, min(y0, y1)
                        + self.canvas.y, w, h)]
        if self.lastrect is None:
            self.canvas.canvas.add(Color(*self.rubberband_color))
        else:
            self.canvas.canvas.remove(self.lastrect)
        self.lastrect = InstructionGroup()
        self.lastrect.add(Line(rectangle=rect, width=1.0, dash_length=5.0,
                dash_offset=5.0))
        self.lastrect.add(Color(1.0, 0.0, 0.0, 0.2))
        self.lastrect.add(Rectangle(pos=(rect[0], rect[1]),
                                    size=(rect[2], rect[3])))
        self.canvas.canvas.add(self.lastrect) 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:18,代码来源:backend_kivy.py

示例3: __init__

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def __init__(self, **kwargs):
        super(ResizeCursor, self).__init__(**kwargs)
        self.size_hint = (None, None)
        self.pos_hint = (None, None)
        self.source = ''
        self.rect = Rectangle(pos=(-9998,-9998), size=(1, 1))
        self.size = (dp(22), dp(22))
        self.pos = [-9998, -9998]

        # Makes an instruction group with a rectangle and
        # loads an image inside it
        # Binds its properties to mouse positional changes and events triggered
        instr = InstructionGroup()
        instr.add(self.rect)
        self.canvas.after.add(instr)
        self.bind(pos=lambda obj, val: setattr(self.rect, 'pos', val))
        self.bind(source=lambda obj, val: setattr(self.rect, 'source', val))
        self.bind(hidden=lambda obj, val: self.on_mouse_move(Window.mouse_pos))
        Window.bind(mouse_pos=lambda obj, val: self.on_mouse_move(val)) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:21,代码来源:modal_cursor.py

示例4: start

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def start(win, ctx):
    # late import to avoid breaking module loading
    from kivy.input.postproc import kivy_postproc_modules
    kivy_postproc_modules['fps'] = StatsInput()
    global _ctx
    ctx.label = Label(text='FPS: 0.0')
    ctx.inputstats = 0
    ctx.stats = []
    ctx.statsr = []
    with win.canvas.after:
        ctx.color = Color(1, 0, 0, .5)
        ctx.rectangle = Rectangle(pos=(0, win.height - 25),
                                  size=(win.width, 25))
        ctx.color = Color(1, 1, 1)
        ctx.rectangle = Rectangle(pos=(5, win.height - 20))
        ctx.color = Color(1, 1, 1, .5)
        for x in range(64):
            ctx.stats.append(0)
            ctx.statsr.append(
                Rectangle(pos=(win.width - 64 * 4 + x * 4, win.height - 25),
                          size=(4, 0)))
    Clock.schedule_interval(partial(update_fps, ctx), .5)
    Clock.schedule_interval(partial(update_stats, ctx), 1 / 60.) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:25,代码来源:monitor.py

示例5: _touch_down

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def _touch_down(win, touch):
    ud = touch.ud
    touch.scale_for_screen(win.width, win.height)
    with win.canvas.after:
        ud['tr.color'] = Color(1, 1, 1, pointer_alpha)
        iw, ih = pointer_image.size
        ud['tr.rect'] = Rectangle(
            pos=(
                touch.x - (pointer_image.width / 2. * pointer_scale),
                touch.y - (pointer_image.height / 2. * pointer_scale)),
            size=(iw * pointer_scale, ih * pointer_scale),
            texture=pointer_image.texture)

    if not ud.get('tr.grab', False):
        ud['tr.grab'] = True
        touch.grab(win) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:18,代码来源:touchring.py

示例6: _mouse_move

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def _mouse_move(win, pos, *args):
    global cursor_size
    if hasattr(win, '_cursor'):
        c = win._cursor
    else:
        with win.canvas.after:
            img = Image(cursor_image)
            Color(1, 1, 1, 1, mode='rgba')
            size = (
                cursor_size[0] or img.texture.size[0],
                cursor_size[1] or img.texture.size[1]
            )
            print(size)
            win._cursor = c = Rectangle(texture=img.texture,
                                        size=size)

    c.pos = pos[0] + cursor_offset[0], pos[1] - c.size[1] + cursor_offset[1] 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:19,代码来源:touchring.py

示例7: init_gesture

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def init_gesture(self, touch):
        '''Create a new gesture from touch, ie it's the first on
        surface, or was not close enough to any existing gesture (yet)'''
        col = self.color
        if self.use_random_color is True:
            col = hsv_to_rgb(random(), 1., 1.)

        g = GestureContainer(touch, max_strokes=self.max_strokes,
                             line_width=self.line_width, color=col)

        # Create the bounding box Rectangle for the gesture
        if self.draw_bbox:
            bb = g.bbox
            with self.canvas:
                Color(col[0], col[1], col[2], self.bbox_alpha, mode='rgba',
                      group=g.id)

                g._bbrect = Rectangle(
                    group=g.id,
                    pos=(bb['minx'], bb['miny']),
                    size=(bb['maxx'] - bb['minx'],
                          bb['maxy'] - bb['miny']))

        self._gestures.append(g)
        return g 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:27,代码来源:gesturesurface.py

示例8: _refresh_hint_text

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def _refresh_hint_text(self):
        _lines, self._hint_text_flags = self._split_smart(self.hint_text)
        _hint_text_labels = []
        _hint_text_rects = []
        _create_label = self._create_line_label

        for x in _lines:
            lbl = _create_label(x, hint=True)
            _hint_text_labels.append(lbl)
            _hint_text_rects.append(Rectangle(size=lbl.size))

        self._hint_text_lines = _lines
        self._hint_text_labels = _hint_text_labels
        self._hint_text_rects = _hint_text_rects

        # Remember to update graphics
        self._trigger_update_graphics()

    #
    # Properties
    # 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:23,代码来源:textinput.py

示例9: on_touch_move

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def on_touch_move( self, touch ) :
        if self._touched :
            self._d = touch.pos
            self._hover_size, self._hover_pos = self._get_hover()

            if self.root_layout :
                self._clear_canvas()

                with self.root_layout.canvas :
                    kg.Color( *self.hover_color, **self._unique_group )
                    kg.Rectangle( 
                        size=self._hover_size, \
                        pos=self._hover_pos, \
                        **self._unique_group 
                    )
            return True 
开发者ID:curzel-it,项目名称:kivy-material-ui,代码行数:18,代码来源:labels.py

示例10: __init__

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def __init__(self, **kwargs):
        super(Graph, self).__init__(**kwargs)

        with self.canvas:
            self._fbo = Fbo(size=self.size, with_stencilbuffer=self._with_stencilbuffer)

        with self._fbo:
            self._background_color = Color(*self.background_color)
            self._background_rect = Rectangle(size=self.size)
            self._mesh_ticks_color = Color(*self.tick_color)
            self._mesh_ticks = Mesh(mode='lines')
            self._mesh_rect_color = Color(*self.border_color)
            self._mesh_rect = Mesh(mode='line_strip')

        with self.canvas:
            Color(1, 1, 1)
            self._fbo_rect = Rectangle(size=self.size, texture=self._fbo.texture)

        mesh = self._mesh_rect
        mesh.vertices = [0] * (5 * 4)
        mesh.indices = range(5)

        self._plot_area = StencilView()
        self.add_widget(self._plot_area)

        t = self._trigger = Clock.create_trigger(self._redraw_all)
        ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
        tc = self._trigger_color = Clock.create_trigger(self._update_colors)

        self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
                  y_grid=ts, draw_border=ts)
        self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
                  xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
                  y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
                  font_size=t, label_options=t, x_ticks_angle=t)
        self.bind(tick_color=tc, background_color=tc, border_color=tc)
        self._trigger() 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:39,代码来源:__init__.py

示例11: create_drawings

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def create_drawings(self):
        self._image = Rectangle()
        self._color = Color([1, 1, 1, 1])
        self.bind(color=lambda instr, value: setattr(self._color, 'rgba', value))
        return [self._color, self._image] 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:7,代码来源:__init__.py

示例12: start_cursor

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def start_cursor(self, x, y):
        tx, ty = self.transform_to_wpos(x, y)
        label = CoreLabel(text="{:1.2f},{:1.2f}".format(tx, ty))
        label.refresh()
        texture = label.texture
        px, py = (x, y)
        with self.ids.surface.canvas.after:
            Color(0, 0, 1, mode='rgb', group='cursor_group')
            self.crossx = [
                Rectangle(pos=(px, 0), size=(1, self.height), group='cursor_group'),
                Rectangle(pos=(0, py), size=(self.width, 1), group='cursor_group'),
                Line(circle=(px, py, 20), group='cursor_group'),
                Rectangle(texture=texture, pos=(px - texture.size[0] / 2, py - 40), size=texture.size, group='cursor_group')
            ] 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:16,代码来源:viewer.py

示例13: draw

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [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

示例14: redraw_canvas

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def redraw_canvas(self, *args):
        if self.current_highlighted_child:
            self.instruction_canvas.clear()
            self.instruction_canvas.add(Color(*self.highlighted_color))

            if self.highlighted_shape =='rectangle':
                self.instruction_canvas.add(Rectangle(pos=self.current_highlighted_child.pos, size=self.current_highlighted_child.size))
            elif self.highlighted_shape =='rounded_rectangle':
                self.instruction_canvas.add(RoundedRectangle(pos=self.current_highlighted_child.pos, size=self.current_highlighted_child.size))
            else:
                raise Exception('Invalid highlighted shape {}'.format(self.highlighted_shape)) 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:13,代码来源:highlightbehavior.py

示例15: _draw_selection

# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Rectangle [as 别名]
def _draw_selection(self, *largs):
        pos, size, line_num, (s1c, s1r), (s2c, s2r),\
            _lines, _get_text_width, tab_width, _label_cached, width,\
            padding_left, padding_right, x, canvas_add, selection_color = largs
        # Draw the current selection on the widget.
        if line_num < s1r or line_num > s2r:
            return
        x, y = pos
        w, h = size
        x1 = x
        x2 = x + w
        if line_num == s1r:
            lines = _lines[line_num]
            x1 -= self.scroll_x
            x1 += _get_text_width(lines[:s1c], tab_width, _label_cached)
        if line_num == s2r:
            lines = _lines[line_num]
            x2 = (x - self.scroll_x) + _get_text_width(lines[:s2c],
                                                       tab_width,
                                                       _label_cached)
        width_minus_padding = width - (padding_right + padding_left)
        maxx = x + width_minus_padding
        if x1 > maxx:
            return
        x1 = max(x1, x)
        x2 = min(x2, x + width_minus_padding)
        canvas_add(Color(*selection_color, group='selection'))
        canvas_add(Rectangle(
            pos=(x1, pos[1]), size=(x2 - x1, size[1]), group='selection')) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:31,代码来源:textinput.py


注:本文中的kivy.graphics.Rectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。