Beispiel #1
0
    def render_path(self, pathid):

        path = self.pathd[pathid]

        if path.antialiased:
            renderer = self.renderer
            scanline = self.scanline
            render_scanlines = agg.render_scanlines_rgba
        else:
            renderer = self.rendererbin
            scanline = self.scanlinebin
            render_scanlines = agg.render_scanlines_bin_rgba

        affine = self.adisplay * path.affine
        #print 'display affine:\n', self.adisplay
        #print 'path affine:\n', path.affine
        #print 'product affine:\n', affine
        aggaffine = agg.trans_affine(*affine.vec6)
        transpath = agg.conv_transform_path(path.agg_path, aggaffine)

        if path.facecolor is not None:
            #print 'render path', path.facecolor, path.agg_facecolor
            self.rasterizer.add_path(transpath)
            renderer.color_rgba8(path.agg_facecolor)
            render_scanlines(self.rasterizer, scanline, renderer)

        if path.color is not None:
            stroke = agg.conv_stroke_transpath(transpath)
            stroke.width(path.linewidth)
            self.rasterizer.add_path(stroke)
            renderer.color_rgba8(path.agg_color)
            render_scanlines(self.rasterizer, scanline, renderer)
Beispiel #2
0
    def render_path(self, pathid):

        path = self.pathd[pathid]

        if path.antialiased:
            renderer = self.renderer
            scanline = self.scanline
            render_scanlines = agg.render_scanlines_rgba
        else:
            renderer = self.rendererbin
            scanline = self.scanlinebin
            render_scanlines = agg.render_scanlines_bin_rgba

        affine = self.adisplay * path.affine
        # print 'display affine:\n', self.adisplay
        # print 'path affine:\n', path.affine
        # print 'product affine:\n', affine
        aggaffine = agg.trans_affine(*affine.vec6)
        transpath = agg.conv_transform_path(path.agg_path, aggaffine)

        if path.facecolor is not None:
            # print 'render path', path.facecolor, path.agg_facecolor
            self.rasterizer.add_path(transpath)
            renderer.color_rgba8(path.agg_facecolor)
            render_scanlines(self.rasterizer, scanline, renderer)

        if path.color is not None:
            stroke = agg.conv_stroke_transpath(transpath)
            stroke.width(path.linewidth)
            self.rasterizer.add_path(stroke)
            renderer.color_rgba8(path.agg_color)
            render_scanlines(self.rasterizer, scanline, renderer)
Beispiel #3
0
    return path

width, height = 300,300
fname = os.path.join(matplotlib.get_data_path(), 'fonts/ttf/Vera.ttf')
font = FT2Font(fname)
glyph = font.load_char(ord('y'))
path = glyph_to_agg_path(glyph)

curve = agg.conv_curve_path(path)


scaling = agg.trans_affine_scaling(20,20)
translation = agg.trans_affine_translation(4,4)
rotation = agg.trans_affine_rotation(3.1415926)
mtrans = translation*scaling # cannot use this as a temporary
tpath = agg.conv_transform_path(path, mtrans)

curve = agg.conv_curve_trans(tpath)

stride = width*4
buffer = agg.buffer(width, height, stride)

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

red = agg.rgba8(255,0,0,255)
blue = agg.rgba8(0,0,255,255)
white = agg.rgba8(255,255,255,255)

pf = agg.pixel_format_rgba(rbuf)
rbase = agg.renderer_base_rgba(pf)
Beispiel #4
0
agg.render_scanlines_rgba(rasterizer, scanline, renderer);

## Transforming a path
path = agg.path_storage()
path.move_to(0,0)
path.line_to(1,0)
path.line_to(1,1)
path.line_to(0,1)
path.close_polygon()

rotation = agg.trans_affine_rotation(pi/4)
scaling = agg.trans_affine_scaling(30,30)
translation = agg.trans_affine_translation(300,300)
trans = rotation*scaling*translation

transpath = agg.conv_transform_path(path, trans)
stroke = agg.conv_stroke_transpath(transpath)
stroke.width(2.0)
rasterizer.add_path(stroke)
renderer.color_rgba8( black )
agg.render_scanlines_rgba(rasterizer, scanline, renderer);

## Converting a transformed path to a curve
path = agg.path_storage()
path.move_to(0,0)
path.curve3(1,0)
path.curve3(1,1)
path.curve3(0,1)
path.close_polygon()

rotation = agg.trans_affine_rotation(pi/4)