第一个例子,简单的描绘箭头和箭尾,并没有使用直线进行相连
//Scanline Rasterizer
agg::rasterizer_scanline_aa<> ras;
agg::scanline_u8 sl;
agg::arrowhead ah;
ah.head(0,10,5,5);
ah.tail(10,10,5,5);
ras.reset();
agg::vcgen_markers_term mt;
mt.add_vertex(200,250,agg::path_cmd_move_to);
mt.add_vertex(280,250,agg::path_cmd_line_to);
agg::conv_marker<agg::vcgen_markers_term,agg::arrowhead> arr(mt,ah);
ras.add_path(arr);
//错误的情况:ras.add_path(ah),将不清楚描绘的具体位置
agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));
第二个例子,用线段将箭头和箭尾连接起来
agg::rasterizer_scanline_aa<>ras;
agg::scanline_u8 sl;
agg::arrowhead ah;
ah.head(0,10,5,5);
ah.tail(10,10,5,5);
// 用path_storage生成一条直线
agg::path_storage ps;
ps.move_to(200,250);
ps.line_to(280,250);
agg::conv_stroke<agg::path_storage,agg::vcgen_markers_term>csps(ps);
agg::conv_marker<agg::vcgen_markers_term,agg::arrowhead>arrow(csps.markers(),ah);
ras.add_path(csps);
agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));
ras.add_path(arrow);
agg::render_scanlines_aa_solid(ras,sl,renb,agg::rgba8(255,0,0));