本文整理汇总了C++中agg::path_storage类的典型用法代码示例。如果您正苦于以下问题:C++ path_storage类的具体用法?C++ path_storage怎么用?C++ path_storage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了path_storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_to_path
void scene_renderer_t::convert_to_path( const shape_t& s, agg::path_storage& path, const Imath::V2i& offset, int subsample) const
{
path.remove_all();
Imath::V2f p0, p1, p2;
Imath::V2f shape_offset = s.offset();
Imath::M33f m( s.global_xform());
p0 = transform_point( s.triples()[0].p1(), shape_offset, m, subsample, offset);
path.move_to( p0.x, p0.y);
for( int i = 0; i < s.triples().size() - 1; ++i)
{
p2 = transform_point( s.triples()[i].p2(), shape_offset, m, subsample, offset);
p0 = transform_point( s.triples()[i+1].p0(), shape_offset, m, subsample, offset);
p1 = transform_point( s.triples()[i+1].p1(), shape_offset, m, subsample, offset);
path.curve4( p2.x, p2.y, p0.x, p0.y, p1.x, p1.y);
}
// last segment
p2 = transform_point( s.triples()[s.triples().size()-1].p2(), shape_offset, m, subsample, offset);
p0 = transform_point( s.triples()[0].p0(), shape_offset, m, subsample, offset);
p1 = transform_point( s.triples()[0].p1(), shape_offset, m, subsample, offset);
path.curve4( p2.x, p2.y, p0.x, p0.y, p1.x, p1.y);
path.close_polygon();
}
示例2: create_star
//------------------------------------------------------------------------
void create_star(agg::path_storage& ps)
{
double r = initial_width();
if(initial_height() < r) r = initial_height();
double r1 = r / 3 - 8.0;
double r2 = r1 / 1.45;
unsigned nr = 14;
unsigned i;
for(i = 0; i < nr; i++)
{
double a = agg::pi * 2.0 * i / nr - agg::pi / 2.0;
double dx = cos(a);
double dy = sin(a);
if(i & 1)
{
ps.line_to(m_polygon_cx + dx * r1, m_polygon_cy + dy * r1);
}
else
{
if(i) ps.line_to(m_polygon_cx + dx * r2, m_polygon_cy + dy * r2);
else ps.move_to(m_polygon_cx + dx * r2, m_polygon_cy + dy * r2);
}
}
}
示例3: get_path_storage
bool
get_path_storage(agg::path_storage& path, const control_point* points,
int32 count, bool closed)
{
if (count > 1) {
path.move_to(points[0].point.x, points[0].point.y);
for (int32 i = 1; i < count; i++) {
path.curve4(points[i - 1].point_out.x, points[i - 1].point_out.y,
points[i].point_in.x, points[i].point_in.y,
points[i].point.x, points[i].point.y);
}
if (closed) {
// curve from last to first control point
path.curve4(
points[count - 1].point_out.x, points[count - 1].point_out.y,
points[0].point_in.x, points[0].point_in.y,
points[0].point.x, points[0].point.y);
path.close_polygon();
}
return true;
}
return false;
}
示例4: generate_circles
void generate_circles(agg::path_storage& ps,
const double* quad,
unsigned num_circles,
double radius)
{
ps.remove_all();
unsigned i;
for(i = 0; i < 4; ++i)
{
unsigned n1 = i * 2;
unsigned n2 = (i < 3) ? i * 2 + 2 : 0;
unsigned j;
for(j = 0; j < num_circles; j++)
{
agg::ellipse ell(quad[n1] + (quad[n2] - quad[n1]) * j / num_circles,
quad[n1 + 1] + (quad[n2 + 1] - quad[n1 + 1]) * j / num_circles,
radius, radius, 100);
ps.concat_path(ell);
}
}
}
示例5: parse_lion
unsigned parse_lion(agg::path_storage& path, agg::rgba8* colors, unsigned* path_idx)
{
// Parse the lion and then detect its bounding
// box and arrange polygons orientations (make all polygons
// oriented clockwise or counterclockwise)
const char* ptr = g_lion;
unsigned npaths = 0;
while(*ptr)
{
if(*ptr != 'M' && isalnum(*ptr))
{
unsigned c = 0;
sscanf(ptr, "%x", &c);
// New color. Every new color creates new path in the path object.
path.close_polygon();
colors[npaths] = agg::rgb8_packed(c);
path_idx[npaths] = path.start_new_path();
npaths++;
while(*ptr && *ptr != '\n') ptr++;
if(*ptr == '\n') ptr++;
}
else
{
float x = 0.0;
float y = 0.0;
while(*ptr && *ptr != '\n')
{
int c = *ptr;
while(*ptr && !isdigit(*ptr)) ptr++;
x = atof(ptr);
while(*ptr && isdigit(*ptr)) ptr++;
while(*ptr && !isdigit(*ptr)) ptr++;
y = atof(ptr);
if(c == 'M')
{
path.close_polygon();
path.move_to(x, y);
}
else
{
path.line_to(x, y);
}
while(*ptr && isdigit(*ptr)) ptr++;
while(*ptr && *ptr != '\n' && !isalpha(*ptr)) ptr++;
}
if(*ptr == '\n') ptr++;
}
}
path.arrange_orientations_all_paths(agg::path_flags_cw);
return npaths;
}
示例6: e
void roadmap_canvas_draw_multiple_circles
(int count, RoadMapGuiPoint *centers, int *radius, int filled,
int fast_draw) {
int i;
static agg::path_storage path;
for (i = 0; i < count; ++i) {
int r = radius[i];
int x = centers[i].x;
int y = centers[i].y;
agg::ellipse e( x, y, r, r);
path.concat_path(e);
if (filled) {
ras.reset();
ras.add_path(path);
ren_solid.color(CurrentPen->color);
agg::render_scanlines( ras, sl, ren_solid);
/* } else if (fast_draw) {
renderer_pr ren_pr(agg_renb);
agg::rasterizer_outline<renderer_pr> ras_line(ren_pr);
ren_pr.line_color(CurrentPen->color);
ras_line.add_path(path);
*/
} else {
raso.add_path(path);
}
path.remove_all ();
}
}
示例7: make_gb_poly
void make_gb_poly(agg::path_storage& ps)
{
ps.remove_all();
unsigned i;
const double* p = poly1;
ps.move_to(p[0], p[1]);
p += 2;
for(i = 1; i < sizeof(poly1) / sizeof(double) / 2; i++)
{
ps.line_to(p[0], p[1]);
p += 2;
}
ps.close_polygon();
p = poly2;
ps.move_to(p[0], p[1]);
p += 2;
for(i = 1; i < sizeof(poly2) / sizeof(double) / 2; i++)
{
ps.line_to(p[0], p[1]);
p += 2;
}
ps.close_polygon();
}
示例8: switch
void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage& path, DRAWCMDMODE mode)
{
if (mode == HILITE && cmd->prev)
path.move_to(cmd->prev->m_point->x(), cmd->prev->m_point->y());
switch(cmd->type)
{
case M:
path.move_to(cmd->m_point->x(),cmd->m_point->y());
break;
case B:
if (cmd->initialized)
{
//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
PointList::iterator iterate = cmd->controlpoints.begin();
int x[2], y[2];
x[0] = (*iterate)->x();
y[0] = (*iterate)->y();
iterate++;
x[1] = (*iterate)->x();
y[1] = (*iterate)->y();
path.curve4(x[0], y[0], x[1], y[1], cmd->m_point->x(),cmd->m_point->y());
break;
}
case L:
if (mode == CTRL_LN)
path.move_to(cmd->m_point->x(),cmd->m_point->y());
else
path.line_to(cmd->m_point->x(),cmd->m_point->y());
break;
case S:
unsigned np = cmd->controlpoints.size();
agg::pod_array<double> m_polygon(np * 2);
unsigned _pn = 0;
PointList::iterator iterate = cmd->controlpoints.begin();
while (iterate != cmd->controlpoints.end())
{
m_polygon[_pn] = (*iterate)->x(); _pn++;
m_polygon[_pn] = (*iterate)->y(); _pn++;
iterate++;
}
//m_polygon[_pn++] = cmd->m_point->x();
//m_polygon[_pn++] = cmd->m_point->y();
//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
if (mode == CTRL_LN)
{
_pn = 0;
while (_pn < np * 2)
{
path.line_to((int) m_polygon[_pn],(int) m_polygon[_pn + 1]);
_pn += 2;
}
path.line_to(cmd->m_point->x(), cmd->m_point->y());
}
else
{
//path.line_to((int) m_polygon[0],(int) m_polygon[1]);
aggpolygon poly(&m_polygon[0], np, false, false);
agg::conv_bcspline<agg::simple_polygon_vertex_source> bspline(poly);
bspline.interpolation_step(0.01);
agg::path_storage npath;
npath.join_path(bspline);
path.join_path(npath);
if (mode == HILITE)
path.move_to((int) m_polygon[np * 2 - 2], (int) m_polygon[np * 2 - 1] );
path.line_to(cmd->m_point->x(), cmd->m_point->y());
}
break;
}
}
示例9: roadmap_canvas_draw_multiple_lines
void roadmap_canvas_draw_multiple_lines (int count, int *lines,
RoadMapGuiPoint *points, int fast_draw) {
int i;
int count_of_points;
dbg_time_start(DBG_TIME_DRAW_LINES);
#ifdef WIN32_PROFILE
ResumeCAPAll();
#endif
#ifdef _WIN32_
if (fast_draw) {
roadmap_canvas_native_draw_multiple_lines (count, lines, points,
CurrentPen->color.r, CurrentPen->color.g, CurrentPen->color.b,
CurrentPen->thickness);
return;
}
#endif
if (!fast_draw) {
raso.round_cap(true);
raso.line_join(agg::outline_miter_accurate_join);
} else {
raso.round_cap(false);
raso.line_join(agg::outline_no_join);
}
// raso.accurate_join(true);
static agg::path_storage path;
for (i = 0; i < count; ++i) {
int first = 1;
count_of_points = *lines;
if (count_of_points < 2) continue;
dbg_time_start(DBG_TIME_CREATE_PATH);
for (int j=0; j<count_of_points; j++) {
if (first) {
first = 0;
path.move_to(points->x, points->y);
} else {
path.line_to(points->x, points->y);
}
points++;
}
dbg_time_end(DBG_TIME_CREATE_PATH);
dbg_time_start(DBG_TIME_ADD_PATH);
#if 0
if (fast_draw) {
renderer_pr ren_pr(agg_renb);
agg::rasterizer_outline<renderer_pr> ras_line(ren_pr);
ren_pr.line_color(CurrentPen->color);
ras_line.add_path(path);
} else {
#endif
raso.add_path(path);
//}
path.remove_all ();
dbg_time_end(DBG_TIME_ADD_PATH);
lines += 1;
}
#ifdef WIN32_PROFILE
SuspendCAPAll();
#endif
return;
dbg_time_end(DBG_TIME_DRAW_LINES);
}
void roadmap_canvas_draw_multiple_polygons
(int count, int *polygons, RoadMapGuiPoint *points, int filled,
int fast_draw) {
int i;
int count_of_points;
static agg::path_storage path;
for (i = 0; i < count; ++i) {
//.........这里部分代码省略.........
示例10: Lines
void CAggMemoryDC::Lines(
const PointFVector& pts,
const Color& clr,
const REAL width/*=1.0*/)
{
if (m_buf==0)
return;
unsigned count=pts.size()/2;
ATLASSERT(count>0);
ATLASSERT((float)count/2.0f>0);
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
solid_renderer ren_solid(renb);
m_path.remove_all();
for(unsigned i=0; i<count; ++i)
{
m_path.move_to(pts[i*2].x, pts[i*2].y);
m_path.line_to(pts[i*2+1].x, pts[i*2+1].y);
}
typedef agg::conv_stroke<conv_path_trans_type> conv_stroke_outline;
conv_stroke_outline stroke(m_transpath);
stroke.width(width);
m_ras_aa.add_path(stroke);
ren_solid.color(agg::rgba8(clr.GetR(), clr.GetG(), clr.GetB(), clr.GetA()));
agg::render_scanlines(m_ras_aa, m_sl, ren_solid);
}
示例11: create_star
//------------------------------------------------------------------------
void create_star(double xc, double yc,
double r1, double r2,
unsigned n, double start_angle = 0.0)
{
m_ps.remove_all();
unsigned i;
start_angle *= agg::pi / 180.0;
for(i = 0; i < n; i++)
{
double a = agg::pi * 2.0 * i / n - agg::pi / 2.0;
double dx = cos(a + start_angle);
double dy = sin(a + start_angle);
if(i & 1)
{
m_ps.line_to(xc + dx * r1, yc + dy * r1);
}
else
{
if(i) m_ps.line_to(xc + dx * r2, yc + dy * r2);
else m_ps.move_to(xc + dx * r2, yc + dy * r2);
}
}
m_ps.close_polygon();
}
示例12: parse_lion
void parse_lion()
{
g_npaths = parse_lion(g_path, g_colors, g_path_idx);
agg::pod_array_adaptor<unsigned> path_idx(g_path_idx, 100);
agg::bounding_rect(g_path, path_idx, 0, g_npaths, &g_x1, &g_y1, &g_x2, &g_y2);
g_base_dx = (g_x2 - g_x1) / 2.0;
g_base_dy = (g_y2 - g_y1) / 2.0;
g_path.flip_x(g_x1, g_x2);
g_path.flip_y(g_y1, g_y2);
}
示例13: LollyPop
void CAggMemoryDC::LollyPop(
const GraphTypes::RectF& rc,
const GraphTypes::Color& clr,
const GraphTypes::Color& clroutline,
bool bLeft)
{
if (m_buf==0)
return;
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
agg::line_profile_aa lnprof;
lnprof.width(1.0);
solid_renderer ren_solid(renb);
outline_renderer outline_rd(renb, lnprof);
outline_rasterizer_aa outline_rt(outline_rd);
outline_rd.color(agg::rgba8(clroutline.GetR(),
clroutline.GetG(), clroutline.GetB(), clroutline.GetA()));
REAL radius=rc.Height/2;
REAL split=rc.Width-rc.Height;
REAL xcenter=bLeft? (rc.x+radius) : (rc.x+rc.Width-radius);
REAL ycenter=rc.y+radius;
agg::ellipse circle(xcenter, ycenter, radius, radius, 10);
typedef agg::conv_transform<agg::ellipse, agg::trans_affine> conv_ellipse_trans_type;
conv_ellipse_trans_type m_transcircle(circle, m_mtx);
// connector line
PointF p1, p2;
p1.x=bLeft ? (rc.x+rc.Width-split) : rc.x;
p1.y=rc.y+radius;
p2.x=bLeft ? (rc.x+rc.Width) : (rc.x+split);
p2.y=p1.y;
m_path.remove_all();
m_path.move_to(p1.x, p1.y);
m_path.line_to(p2.x, p2.y);
m_ras_aa.reset();
m_ras_aa.add_path(m_transcircle);
outline_rt.add_path(m_transcircle);
outline_rt.add_path(m_transpath);
ren_solid.color(agg::rgba8(clr.GetR(), clr.GetG(), clr.GetB(), clr.GetA()));
agg::render_scanlines(m_ras_aa, m_sl, ren_solid);
outline_rt.render(true);
}
示例14:
the_application(agg::pix_format_e format, bool flip_y) :
agg::platform_support(format, flip_y),
m_rotate(10, 3, "Rotate", !flip_y),
m_even_odd(60, 3, "Even-Odd", !flip_y),
m_draft(130, 3, "Draft", !flip_y),
m_roundoff(175, 3, "Roundoff", !flip_y),
m_angle_delta(10, 21, 250-10, 27, !flip_y),
m_redraw_flag(true)
{
m_angle_delta.label("Step=%4.3f degree");
g_attr[g_npaths++] = path_attributes(g_path.start_new_path(),
agg::rgba8(255, 255, 0),
agg::rgba8(0, 0, 0),
1.0);
g_path.concat_poly(g_poly_bulb, AGG_POLY_SIZE(g_poly_bulb), true);
g_attr[g_npaths++] = path_attributes(g_path.start_new_path(),
agg::rgba8(255, 255, 200),
agg::rgba8(90, 0, 0),
0.7);
g_path.concat_poly(g_poly_beam1, AGG_POLY_SIZE(g_poly_beam1), true);
g_path.concat_poly(g_poly_beam2, AGG_POLY_SIZE(g_poly_beam2), true);
g_path.concat_poly(g_poly_beam3, AGG_POLY_SIZE(g_poly_beam3), true);
g_path.concat_poly(g_poly_beam4, AGG_POLY_SIZE(g_poly_beam4), true);
g_attr[g_npaths++] = path_attributes(g_path.start_new_path(),
agg::rgba8(0, 0, 0),
agg::rgba8(0, 0, 0),
0.0);
g_path.concat_poly(g_poly_fig1, AGG_POLY_SIZE(g_poly_fig1), true);
g_path.concat_poly(g_poly_fig2, AGG_POLY_SIZE(g_poly_fig2), true);
g_path.concat_poly(g_poly_fig3, AGG_POLY_SIZE(g_poly_fig3), true);
g_path.concat_poly(g_poly_fig4, AGG_POLY_SIZE(g_poly_fig4), true);
g_path.concat_poly(g_poly_fig5, AGG_POLY_SIZE(g_poly_fig5), true);
g_path.concat_poly(g_poly_fig6, AGG_POLY_SIZE(g_poly_fig6), true);
m_rotate.text_size(7);
m_even_odd.text_size(7);
m_draft.text_size(7);
m_roundoff.text_size(7);
add_ctrl(m_rotate);
add_ctrl(m_even_odd);
add_ctrl(m_draft);
add_ctrl(m_roundoff);
add_ctrl(m_angle_delta);
m_angle_delta.value(0.01);
}
示例15: SolidPolygon
void CAggMemoryDC::SolidPolygon(
const PointF* points,
const Color& clr,
unsigned point_count,
REAL widthoutline,
const Color& clroutline )
{
if (m_buf==0)
return;
ATLASSERT(point_count>0);
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
solid_renderer ren_solid(renb);
m_ras_aa.reset();
m_path.remove_all();
m_path.move_to(points->x, points->y);
while(--point_count>0)
{
points++;
m_path.line_to(points->x, points->y);
}
m_path.close_polygon();
m_ras_aa.add_path(m_transpath);
ren_solid.color(agg::rgba8(clr.GetR(), clr.GetG(), clr.GetB(), clr.GetA()));
agg::render_scanlines(m_ras_aa, m_sl, ren_solid);
if(widthoutline>REAL(0))
{
typedef agg::conv_stroke<conv_path_trans_type> conv_trans_stroke_outline;
ren_solid.color(agg::rgba8(clroutline.GetR(),
clroutline.GetG(), clroutline.GetB(), clroutline.GetA()));
conv_trans_stroke_outline stroke(m_transpath);
stroke.width(widthoutline);
m_ras_aa.add_path(stroke);
agg::render_scanlines(m_ras_aa, m_sl, ren_solid);
}
}