Esempio n. 1
0
    def _clip(self):
        fig = self.ax.figure
        l,b,w,h = fig.bbox.get_bounds()
        path = agg.path_storage()

        for i, xy in enumerate(self.poly.get_verts()):
            x,y = xy
            y = h-y
            if i==0: path.move_to(x,y)
            else:    path.line_to(x,y)
        path.close_polygon()
        self.line.set_clip_path(path)
        self.canvas.draw_idle()
Esempio n. 2
0
    def make_agg_path(pathdata):
        agg_path = agg.path_storage()

        codes, xy = pathdata

        Ncodes = len(codes)

        for i in range(Ncodes):
            x, y = xy[i]
            code = codes[i]
            #XXX handle other path codes here
            if code == MOVETO:
                agg_path.move_to(x, y)
            elif code == LINETO:
                agg_path.line_to(x, y)
            elif code == CLOSEPOLY:
                agg_path.close_polygon()
        return agg_path
Esempio n. 3
0
    def make_agg_path(pathdata):
        agg_path = agg.path_storage()

        codes, xy = pathdata

        Ncodes = len(codes)

        for i in range(Ncodes):
            x, y = xy[i]
            code = codes[i]
            # XXX handle other path codes here
            if code == MOVETO:
                agg_path.move_to(x, y)
            elif code == LINETO:
                agg_path.line_to(x, y)
            elif code == CLOSEPOLY:
                agg_path.close_polygon()
        return agg_path
Esempio n. 4
0
    def draw_lines(self, gc, x, y, trans):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """

        x, y = trans.numerix_x_y(x, y)
        if len(x) < 2: return
        path = agg.path_storage()
        path.move_to(x[0], self.height - y[0])
        for i in xrange(1, len(x)):
            path.line_to(x[i], self.height - y[i])

        stroke = agg.conv_stroke(path)
        stroke.width(1.0)
        r, g, b = [int(255 * val) for val in gc.get_rgb()]
        a = int(255 * gc.get_alpha())

        color = agg.rgba8(r, g, b, a)
        self.renderer.color(color)
        self.rasterizer.add_path(stroke)
        agg.render_scanlines(self.rasterizer, self.scanline, self.renderer)
Esempio n. 5
0
    def draw_lines(self, gc, x, y, trans):
        """
        x and y are equal length arrays, draw lines connecting each
        point in x, y
        """

        x, y = trans.numerix_x_y(x,y)
        if len(x)<2: return
        path = agg.path_storage()
        path.move_to(x[0],self.height-y[0])
        for i in xrange(1, len(x)):
            path.line_to(x[i],self.height-y[i])

        stroke = agg.conv_stroke(path)
        stroke.width(1.0)
        r,g,b = [int(255*val) for val in gc.get_rgb()]
        a = int(255*gc.get_alpha())

        color = agg.rgba8(r,g,b,a)
        self.renderer.color(  color )
        self.rasterizer.add_path(stroke)
        agg.render_scanlines(self.rasterizer, self.scanline, self.renderer);
Esempio n. 6
0
def glyph_to_agg_path(glyph):
    path = agg.path_storage()
    for tup in glyph.path:
        print tup
        code = tup[0]
        if code == MOVETO:
            x,y = tup[1:]
            path.move_to(x,y)
        elif code == LINETO:
            x,y = tup[1:]
            path.line_to(x,y)
        elif code == CURVE3:
            xctl, yctl, xto, yto= tup[1:]
            path.curve3(xctl, yctl, xto, yto)

        elif code == CURVE4:
            xctl1, yctl1, xctl2, yctl2, xto, yto= tup[1:]
            path.curve4(xctl1, yct1, xctl2, yctl2, xto, yto)
        elif code == ENDPOLY:
            path.end_poly()

    return path
Esempio n. 7
0
buffer = agg.buffer(width, height, stride)

rbuf = agg.rendering_buffer()
rbuf.attachb(buffer)

pf = agg.pixel_format_rgba(rbuf)
rbase = agg.renderer_base_rgba(pf)
rbase.clear_rgba8(blue)

renderer =  agg.renderer_scanline_aa_solid_rgba(rbase);
renderer.color_rgba8( red )
rasterizer = agg.rasterizer_scanline_aa()
scanline = agg.scanline_p8()

## A polygon path
path = agg.path_storage()
path.move_to(10,10)
path.line_to(100,100)
path.line_to(200,200)
path.line_to(100,200)
path.close_polygon()

# stroke it
stroke = agg.conv_stroke_path(path)
stroke.width(3.0)
rasterizer.add_path(stroke)
agg.render_scanlines_rgba(rasterizer, scanline, renderer);

## A curved path
path = agg.path_storage()
path.move_to(200,10)