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


Python cairo.OPERATOR_SOURCE属性代码示例

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


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

示例1: draw_line

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import OPERATOR_SOURCE [as 别名]
def draw_line(self, ctx, x, y, width, height):
        """! Draw Line 
        @param self this object
        @param ctx ctx
        @param x x
        @param y y
        @param width width
        @param height height
        @return none
        """
        ctx.move_to(x, y)
        ctx.rel_line_to(width, height)
        ctx.close_path()
        ctx.set_operator(cairo.OPERATOR_SOURCE)
        ctx.set_line_width(1.0)
        ctx.set_source_rgb(0, 0, 0)
        ctx.stroke() 
开发者ID:KTH,项目名称:royal-chaos,代码行数:19,代码来源:grid.py

示例2: draw_line

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import OPERATOR_SOURCE [as 别名]
def draw_line(self, ctx, x, y, width, height):
        ctx.move_to(x, y)
        ctx.rel_line_to(width, height)
        ctx.close_path()
        ctx.set_operator(cairo.OPERATOR_SOURCE)
        ctx.set_line_width(1.0)
        ctx.set_source_rgb(0, 0, 0)
        ctx.stroke() 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:10,代码来源:grid.py

示例3: __svgToSurface

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import OPERATOR_SOURCE [as 别名]
def __svgToSurface(self, svg, width, height):
        assert isinstance(width, int)
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
        context = cairo.Context(surface)
        context.set_operator(cairo.OPERATOR_SOURCE)
        if svg.props.width != width or svg.props.height != height:
            context.scale(width / float(svg.props.width),
                          height / float(svg.props.height))
        svg.render_cairo(context)
        return surface 
开发者ID:pychess,项目名称:pychess,代码行数:12,代码来源:OverlayWindow.py

示例4: draw_background

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import OPERATOR_SOURCE [as 别名]
def draw_background(self, widget, context):
        # setup a semi-transparent background
        context.set_source_rgba(0, 0, 0, config["main-opacity"])
        context.set_operator(cairo.OPERATOR_SOURCE)
        context.paint()
        context.set_operator(cairo.OPERATOR_OVER) 
开发者ID:okitavera,项目名称:clearine,代码行数:8,代码来源:clearine.py

示例5: use_pango_font

# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import OPERATOR_SOURCE [as 别名]
def use_pango_font(font, start, count, will_call_prepost=False):
    import pango, cairo, pangocairo
    fontDesc = pango.FontDescription(font)
    a = array.array('b', itertools.repeat(0, 256 * 256))
    surface = cairo.ImageSurface.create_for_data(a, cairo.FORMAT_A8, 256, 256)
    context = pangocairo.CairoContext(cairo.Context(surface))
    layout = context.create_layout()
    fontmap = pangocairo.cairo_font_map_get_default()
    font = fontmap.load_font(fontmap.create_context(), fontDesc)
    layout.set_font_description(fontDesc)
    metrics = font.get_metrics()
    descent = metrics.get_descent()
    d = pango.PIXELS(descent)
    linespace = metrics.get_ascent() + metrics.get_descent()
    width = metrics.get_approximate_char_width()

    glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT)
    glPixelStorei(GL_UNPACK_SWAP_BYTES, 0)
    glPixelStorei(GL_UNPACK_LSB_FIRST, 1)
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 256)
    glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 256)
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0)
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0)
    glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0)
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
    glPixelZoom(1, -1)

    base = glGenLists(count)
    for i in range(count):
        ch = unichr(start + i)
        layout.set_text(ch)
        w, h = layout.get_size()
        context.save()
        context.new_path()
        context.rectangle(0, 0, 256, 256)
        context.set_source_rgba(0., 0., 0., 0.)
        context.set_operator(cairo.OPERATOR_SOURCE);
        context.paint()
        context.restore()

        context.save()
        context.set_source_rgba(1., 1., 1., 1.)
        context.set_operator(cairo.OPERATOR_SOURCE);
        context.move_to(0, 0)
        context.update_layout(layout)
        context.show_layout(layout)
        context.restore()

        w, h = pango.PIXELS(w), pango.PIXELS(h)
        glNewList(base + i, GL_COMPILE)
        glBitmap(0, 0, 0, 0, 0, h - d, '');
        if not will_call_prepost: pango_font_pre()
        if w and h: glDrawPixels(w, h, GL_LUMINANCE, GL_UNSIGNED_BYTE, a)
        glBitmap(0, 0, 0, 0, w, -h + d, '');
        if not will_call_prepost: pango_font_post()
        glEndList()

    glPopClientAttrib()
    return base, pango.PIXELS(width), pango.PIXELS(linespace) 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:61,代码来源:glnav3.py


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