Exemplo n.º 1
0
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)
rbase.clear_rgba8(white)
Exemplo n.º 2
0
## 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)
scaling = agg.trans_affine_scaling(30,30)
translation = agg.trans_affine_translation(300,250)
trans = rotation*scaling*translation
trans.flip_y()

transpath = agg.conv_transform_path(path, trans)
curvetrans = agg.conv_curve_trans(transpath)
stroke = agg.conv_stroke_curvetrans(curvetrans)
stroke.width(2.0)
rasterizer.add_path(stroke)
renderer.color_rgba8( white )
agg.render_scanlines_rgba(rasterizer, scanline, renderer);

if 0:
    ## Copy a rectangle from the buffer the rectangle defined by
    ## x0,y0->x1,y1 and paste it at xdest, ydest
    x0, y0 = 10, 50
    x1, y1 = 110, 190
    xdest, ydest = 350, 200