Python cairo.OPERATOR_SOURCE Examples

The following are 14 code examples of cairo.OPERATOR_SOURCE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module cairo , or try the search function .
Example #1
Source File: grid.py    From royal-chaos with MIT License 6 votes vote down vote up
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() 
Example #2
Source File: grid.py    From ns-3-dev-git with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #3
Source File: grid.py    From ns3-802.11ad with GNU General Public License v2.0 6 votes vote down vote up
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() 
Example #4
Source File: grid.py    From ntu-dsi-dcn with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #5
Source File: grid.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #6
Source File: grid.py    From ns3-load-balance with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #7
Source File: grid.py    From 802.11ah-ns3 with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #8
Source File: grid.py    From ns3-rdma with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #9
Source File: OverlayWindow.py    From pychess with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #10
Source File: clearine.py    From clearine with MIT License 5 votes vote down vote up
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) 
Example #11
Source File: grid.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #12
Source File: grid.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #13
Source File: grid.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #14
Source File: glnav3.py    From hazzy with GNU General Public License v2.0 4 votes vote down vote up
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)