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


Python Context.clip方法代码示例

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


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

示例1: on_draw

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import clip [as 别名]
    def on_draw(self, widget: Widget, context: cairo.Context):
        if not self.is_shape_set:
            self.layout(context)

        context.set_font_size(self.font_size)

        self.shape.draw_on_context(context)
        context.set_source_rgb(1, 1, 1)
        context.fill_preserve()
        context.set_source_rgb(0, 0, 0)
        context.stroke()
        shape = self.shape

        label = self.label
        if len(label) > 0 and label[-1] == ' ':
            label += '.'
        xb, yb, w, h, xa, ya = context.text_extents(label)
        context.rectangle(shape.start.x + self.padding,
                          shape.start.y,
                          shape.width - self.padding,
                          shape.height)
        context.clip()
        context.move_to(shape.start.x + (shape.width - self.padding - w)/2,
                        shape.start.y + shape.height - self.padding)
        context.show_text(self.label)
开发者ID:gcali,项目名称:crucipixel,代码行数:27,代码来源:input.py

示例2: on_draw

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import clip [as 别名]
 def on_draw(self, widget: Widget, context: cairo.Context):
     for child in self.list:
         if child.visible:
             context.save()
             context.transform(child.fromWidgetCoords)
             if child.is_clip_set():
                 rectangle = child.clip_rectangle
                 context.rectangle(rectangle.start.x,rectangle.start.y,
                                   rectangle.width,rectangle.height)
                 context.clip()
             child.on_draw(self,context)
             context.restore()
开发者ID:gcali,项目名称:crucipixel,代码行数:14,代码来源:containers.py

示例3: on_draw

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import clip [as 别名]
    def on_draw(self, widget: Widget, context: cairo.Context):
        self.min_size = 200, 150
        super().on_draw(widget, context)

        context.save()
        context.set_font_size(self.font_size)

        if self._table_extents is None:
            self._update_table_extents(context)

        skip = max(self.skip, 0)
        how_many = self.how_many

        table_extents = self._table_extents
        title_extents = self._table_extents.title_extents

        expected_height = title_extents.total_height + self.margin

        entries = self.entries

        base = skip
        up_to = skip
        over = False
        while up_to < len(entries) and not over:
            expected_height += table_extents[up_to].total_height
            over = expected_height >= self._max_height
            if not over:
                up_to += 1

        while base > 0 and not over:
            expected_height += table_extents[base-1].total_height
            over = expected_height >= self._max_height
            if not over:
                base -= 1

        how_many = up_to - base
        skip = base
        self.base = base

        entries = self.entries[skip:skip + how_many]

        def table_extents_iterator():
            return table_extents.iter_over(
                skip, how_many
            )

        start_x, start_y = context.get_current_point()

        start_y += title_extents.total_height
        h = title_extents.total_height
        self.title_height = h
        for (index, cell), data in zip(enumerate(title_extents), self.title):
            context.save()
            offset = title_extents.get_cell_data_left(index)
            context.rectangle(start_x + offset, start_y - h, cell.width, 2*h)
            context.clip()
            context.move_to(
                start_x + offset,
                start_y
            )
            context.show_text(data)
            context.restore()
        # start_y += self.margin

        curr_x, curr_y = start_x, start_y# + title_extents.total_height

        for line_index, (line_extent, entry) in enumerate(zip(table_extents_iterator(), entries)):
            h = line_extent.total_height
            curr_y += h
            if curr_y + self.margin >= self._max_height:
                break
            for (cell_index, cell), data in zip(enumerate(line_extent), entry):
                context.save()
                offset = line_extent.get_cell_data_left(cell_index)
                context.rectangle(curr_x + offset, curr_y - h, cell.width, 2*h)
                context.clip()
                context.move_to(
                    curr_x + offset,
                    curr_y
                )
                context.show_text(data)
                context.restore()

        curr_x = start_x
        end_x = table_extents.entries_width
        curr_y = start_y + self.margin
        end_y = table_extents.get_height_up_to(skip, how_many) + start_y + self.margin + 1

        self.table_height = end_y
        self.table_width = end_x

        for line in table_extents_iterator():
            context.move_to(curr_x, curr_y)
            context.line_to(end_x, curr_y)
            context.stroke()
            curr_y += line.total_height
        context.move_to(curr_x, curr_y)
        context.line_to(end_x, curr_y)
        context.stroke()

#.........这里部分代码省略.........
开发者ID:gcali,项目名称:crucipixel,代码行数:103,代码来源:chooser_table.py

示例4: _paint_panel

# 需要导入模块: from cairo import Context [as 别名]
# 或者: from cairo.Context import clip [as 别名]

#.........这里部分代码省略.........
                    num = d_i.strftime("%d-%m-%Y %H")

                    x -= (int(d_i.strftime("%H")) * 3600 - tz) / kx

                    tw, th = ctx.text_extents(num)[2:4]
                    tx = x - tw // 2
                    ctx.move_to(tx, height - bottom + th + 5)
                    if tx - tx_prev > tw:
                        ctx.show_text(num)
                        tx_prev = tx
                        ctx.set_source_rgb(*(color_y_line_date))
                    else:
                        ctx.set_source_rgb(*(color_y_line))
                    if x >= left and x < width:
                        ctx.move_to(x, 0)
                        ctx.line_to(x, height - bottom)
                        ctx.stroke()
                    sc = space_count
                sc -= 1
        except Exception as e:
            pass

        # Рисуем верхний и правый бордер

        ctx.set_source_rgb(*color_border)
        ctx.move_to(left, 0)
        ctx.line_to(width, 0)
        ctx.line_to(width, height - bottom)
        ctx.stroke()

        # Рисуем сами графики

        ctx.rectangle(left, 0, width - left, height)
        ctx.clip()

        is_first = True
        currVarID = -1
        prevX = -1

        if typ == 0:  # Линейная
            for ind in range(4):
                """
                if len(chart_data[ind]) > 0:
                    for i in range(len(chart_data[ind]) - 1):
                        chart_data[ind][i] = list(chart_data[ind][i])
                        r1 = chart_data[ind][i]
                        r2 = chart_data[ind][i + 1]
                        chart_data[ind][i][0] += (r2[0] - r1[0]) / 2
                        chart_data[ind][i][1] += (r2[1] - r1[1]) / 2
                """
                ctx.set_source_rgb(*colors[ind])
                is_first = True
                for row in chart_data[ind]:
                    x = (row[0] - min_x) / kx + left
                    y = height - bottom - (row[1] - min_y) / ky

                    if is_first:
                        ctx.move_to(x, y)
                    else:
                        if row[0] - prevX > 10000:
                            ctx.move_to(x, y)
                        else:
                            ctx.line_to(x, y)

                    prevX = row[0]
                    is_first = False
开发者ID:SolitonNew,项目名称:pyhome,代码行数:70,代码来源:page5_1.py


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