Esempio n. 1
0
    def render_marker(self, markerid):
        marker = self.markerd[markerid]

        path = marker.path

        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

        affinelocs = self.adisplay * marker.affine

        Nmarkers = marker.locs.shape[0]
        Locs = npy.ones((3, Nmarkers))
        Locs[0] = marker.locs[:, 0]
        Locs[1] = marker.locs[:, 1]

        Locs = affinelocs * Locs

        dpiscale = self.dpi / 72.  # for some reason this is broken
        # this will need to be highly optimized and hooked into some
        # extension code using cached marker rasters as we now do in
        # _backend_agg

        pathcodes, pathxy = marker.path.pathdata

        pathx = dpiscale * pathxy[:, 0]
        pathy = dpiscale * pathxy[:, 1]

        Npath = len(pathcodes)
        XY = npy.ones((Npath, 2))

        for xv, yv, tmp in Locs.T:
            XY[:, 0] = (pathx + xv).astype(int) + 0.5
            XY[:, 1] = (pathy + yv).astype(int) + 0.5

            pathdata = pathcodes, XY
            aggpath = PathPrimitiveAgg.make_agg_path(pathdata)

            if path.facecolor is not None:
                self.rasterizer.add_path(aggpath)
                renderer.color_rgba8(path.agg_facecolor)
                render_scanlines(self.rasterizer, scanline, renderer)

            if path.color is not None:
                stroke = agg.conv_stroke_path(aggpath)
                stroke.width(path.linewidth)
                self.rasterizer.add_path(stroke)
                renderer.color_rgba8(path.agg_color)
                render_scanlines(self.rasterizer, scanline, renderer)
Esempio n. 2
0
    def render_marker(self, markerid):
        marker = self.markerd[markerid]

        path = marker.path

        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

        affinelocs = self.adisplay * marker.affine

        Nmarkers = marker.locs.shape[0]
        Locs = npy.ones((3, Nmarkers))
        Locs[0] = marker.locs[:, 0]
        Locs[1] = marker.locs[:, 1]

        Locs = affinelocs * Locs

        dpiscale = self.dpi / 72.0  # for some reason this is broken
        # this will need to be highly optimized and hooked into some
        # extension code using cached marker rasters as we now do in
        # _backend_agg

        pathcodes, pathxy = marker.path.pathdata

        pathx = dpiscale * pathxy[:, 0]
        pathy = dpiscale * pathxy[:, 1]

        Npath = len(pathcodes)
        XY = npy.ones((Npath, 2))

        for xv, yv, tmp in Locs.T:
            XY[:, 0] = (pathx + xv).astype(int) + 0.5
            XY[:, 1] = (pathy + yv).astype(int) + 0.5

            pathdata = pathcodes, XY
            aggpath = PathPrimitiveAgg.make_agg_path(pathdata)

            if path.facecolor is not None:
                self.rasterizer.add_path(aggpath)
                renderer.color_rgba8(path.agg_facecolor)
                render_scanlines(self.rasterizer, scanline, renderer)

            if path.color is not None:
                stroke = agg.conv_stroke_path(aggpath)
                stroke.width(path.linewidth)
                self.rasterizer.add_path(stroke)
                renderer.color_rgba8(path.agg_color)
                render_scanlines(self.rasterizer, scanline, renderer)
Esempio n. 3
0
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)
path.line_to(350,50)
path.curve3(150,200)
path.curve3(100,70)
path.close_polygon()
curve = agg.conv_curve_path(path)

# fill it
rasterizer.add_path(curve)