本文整理汇总了C++中agg::path_storage::close_polygon方法的典型用法代码示例。如果您正苦于以下问题:C++ path_storage::close_polygon方法的具体用法?C++ path_storage::close_polygon怎么用?C++ path_storage::close_polygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agg::path_storage
的用法示例。
在下文中一共展示了path_storage::close_polygon方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: compose_path
void compose_path()
{
unsigned flag = 0;
if (m_close.cur_item() == 1) flag = agg::path_flags_cw;
if (m_close.cur_item() == 2) flag = agg::path_flags_ccw;
m_path.remove_all();
m_path.move_to(28.47, 6.45);
m_path.curve3(21.58, 1.12, 19.82, 0.29);
m_path.curve3(17.19, -0.93, 14.21, -0.93);
m_path.curve3(9.57, -0.93, 6.57, 2.25);
m_path.curve3(3.56, 5.42, 3.56, 10.60);
m_path.curve3(3.56, 13.87, 5.03, 16.26);
m_path.curve3(7.03, 19.58, 11.99, 22.51);
m_path.curve3(16.94, 25.44, 28.47, 29.64);
m_path.line_to(28.47, 31.40);
m_path.curve3(28.47, 38.09, 26.34, 40.58);
m_path.curve3(24.22, 43.07, 20.17, 43.07);
m_path.curve3(17.09, 43.07, 15.28, 41.41);
m_path.curve3(13.43, 39.75, 13.43, 37.60);
m_path.line_to(13.53, 34.77);
m_path.curve3(13.53, 32.52, 12.38, 31.30);
m_path.curve3(11.23, 30.08, 9.38, 30.08);
m_path.curve3(7.57, 30.08, 6.42, 31.35);
m_path.curve3(5.27, 32.62, 5.27, 34.81);
m_path.curve3(5.27, 39.01, 9.57, 42.53);
m_path.curve3(13.87, 46.04, 21.63, 46.04);
m_path.curve3(27.59, 46.04, 31.40, 44.04);
m_path.curve3(34.28, 42.53, 35.64, 39.31);
m_path.curve3(36.52, 37.21, 36.52, 30.71);
m_path.line_to(36.52, 15.53);
m_path.curve3(36.52, 9.13, 36.77, 7.69);
m_path.curve3(37.01, 6.25, 37.57, 5.76);
m_path.curve3(38.13, 5.27, 38.87, 5.27);
m_path.curve3(39.65, 5.27, 40.23, 5.62);
m_path.curve3(41.26, 6.25, 44.19, 9.18);
m_path.line_to(44.19, 6.45);
m_path.curve3(38.72, -0.88, 33.74, -0.88);
m_path.curve3(31.35, -0.88, 29.93, 0.78);
m_path.curve3(28.52, 2.44, 28.47, 6.45);
m_path.close_polygon(flag);
m_path.move_to(28.47, 9.62);
m_path.line_to(28.47, 26.66);
m_path.curve3(21.09, 23.73, 18.95, 22.51);
m_path.curve3(15.09, 20.36, 13.43, 18.02);
m_path.curve3(11.77, 15.67, 11.77, 12.89);
m_path.curve3(11.77, 9.38, 13.87, 7.06);
m_path.curve3(15.97, 4.74, 18.70, 4.74);
m_path.curve3(22.41, 4.74, 28.47, 9.62);
m_path.close_polygon(flag);
}
示例3: 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();
}
示例4:
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;
}
示例5: 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();
}
示例6: 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();
}
示例7: SolidPolygon
void CAggMemoryDC::SolidPolygon(
const PointF* points,
const Color& clr,
unsigned point_count)
{
if (m_buf==0)
return;
if(m_npaths>0)
{
m_pathCache.close_polygon();
m_colorsCache[m_countpaths] = agg::rgba8(clr.GetR(), clr.GetG(), clr.GetB(), clr.GetA());
m_path_idxCache[m_countpaths] = m_pathCache.start_new_path();
m_countpaths++;
m_pathCache.move_to(points->x, points->y);
while(--point_count>0)
{
points++;
m_pathCache.line_to(points->x, points->y);
}
}
else
{
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
solid_renderer ren_solid(renb);
ATLASSERT(point_count>0);
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_ras_aa.reset();
m_ras_aa.clip_box(0, 0, m_rcUpdate.Width(), m_rcUpdate.Height());
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);
}
}
示例8: LinearGradientRect
void CAggMemoryDC::LinearGradientRect(
const RectF& rc,
const Color& clrstart,
const Color& clrend,
bool bHorizontal/*=true*/)
{
// The gradient color array
typedef agg::pod_auto_array<agg::rgba8, 256> color_array_type;
// Gradient shape function (linear, radial, custom, etc)
//-----------------
typedef agg::gradient_xy gradient_func_type;
// Span interpolator. This object is used in all span generators
// that operate with transformations during iterating of the spans,
// for example, image transformers use the interpolator too.
//-----------------
typedef agg::span_interpolator_linear<> interpolator_type;
// Span allocator is an object that allocates memory for
// the array of colors that will be used to render the
// color spans. One object can be shared between different
// span generators.
//-----------------
typedef agg::span_allocator<agg::rgba8> span_allocator_type;
// Finally, the gradient span generator working with the agg::rgba8
// color type.
// The 4-th argument is the color function that should have
// the [] operator returning the color in range of [0...255].
// In our case it will be a simple look-up table of 256 colors.
//-----------------
typedef agg::span_gradient<agg::rgba8,
interpolator_type,
gradient_func_type,
color_array_type> span_gradient_type;
// The gradient scanline renderer type
//-----------------
typedef agg::renderer_scanline_aa<ren_base,
span_allocator_type,
span_gradient_type> renderer_gradient_type;
// Common declarations (pixel format and basic renderer).
//----------------
pixel_format pixf(m_rbuf);
ren_base renb(pixf);
// The gradient objects declarations
//----------------
gradient_func_type gradient_func; // The gradient function
agg::trans_affine gradient_mtx; // Affine transformer
interpolator_type span_interpolator(gradient_mtx); // Span interpolator
span_allocator_type span_allocator; // Span Allocator
color_array_type color_array; // Gradient colors
// Declare the gradient span itself.
// The last two arguments are so called "d1" and "d2"
// defining two distances in pixels, where the gradient starts
// and where it ends. The actual meaning of "d1" and "d2" depands
// on the gradient function.
//----------------
span_gradient_type span_gradient(span_interpolator,
gradient_func,
color_array,
bHorizontal ? rc.x : rc.y,
bHorizontal ? rc.x+rc.Width : rc.y+rc.Height);
// The gradient renderer
//----------------
renderer_gradient_type ren_gradient(renb, span_allocator, span_gradient);
fill_color_array(color_array,
agg::rgba8(clrstart.GetR(), clrstart.GetG(), clrstart.GetB(), clrstart.GetA()),
agg::rgba8(clrend.GetR(), clrend.GetG(), clrend.GetB(), clrend.GetA()));
m_path.remove_all();
m_path.move_to(rc.x, rc.y);
m_path.line_to(rc.x+rc.Width, rc.y);
m_path.line_to(rc.x+rc.Width, rc.y+rc.Height);
m_path.line_to(rc.x, rc.y+rc.Height);
m_path.close_polygon();
m_ras_aa.reset();
m_ras_aa.clip_box(0, 0, m_rcUpdate.Width(), m_rcUpdate.Height());
m_ras_aa.add_path(m_transpath);
agg::render_scanlines(m_ras_aa, m_sl, ren_gradient);
}
示例9: roadmap_canvas_draw_multiple_lines
//.........这里部分代码省略.........
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) {
count_of_points = *polygons;
int first = 1;
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++;
}
path.close_polygon();
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 ();
polygons += 1;
}
}
示例10:
the_application(agg::pix_format_e format, bool flip_y) :
agg::platform_support(format, flip_y),
m_method (10.0, 10.0, 130.0, 55.0, !flip_y),
m_radius (130 + 10.0, 10.0 + 4.0, 130 + 300.0, 10.0 + 8.0 + 4.0, !flip_y),
m_shadow_ctrl(4),
m_shape(m_path)
{
add_ctrl(m_method);
m_method.text_size(8);
m_method.add_item("Single Color");
m_method.add_item("Color LUT");
m_method.cur_item(1);
add_ctrl(m_radius);
m_radius.range(0.0, 40.0);
m_radius.value(15.0);
m_radius.label("Blur Radius=%1.2f");
add_ctrl(m_shadow_ctrl);
m_path.remove_all();
m_path.move_to(28.47, 6.45);
m_path.curve3(21.58, 1.12, 19.82, 0.29);
m_path.curve3(17.19, -0.93, 14.21, -0.93);
m_path.curve3(9.57, -0.93, 6.57, 2.25);
m_path.curve3(3.56, 5.42, 3.56, 10.60);
m_path.curve3(3.56, 13.87, 5.03, 16.26);
m_path.curve3(7.03, 19.58, 11.99, 22.51);
m_path.curve3(16.94, 25.44, 28.47, 29.64);
m_path.line_to(28.47, 31.40);
m_path.curve3(28.47, 38.09, 26.34, 40.58);
m_path.curve3(24.22, 43.07, 20.17, 43.07);
m_path.curve3(17.09, 43.07, 15.28, 41.41);
m_path.curve3(13.43, 39.75, 13.43, 37.60);
m_path.line_to(13.53, 34.77);
m_path.curve3(13.53, 32.52, 12.38, 31.30);
m_path.curve3(11.23, 30.08, 9.38, 30.08);
m_path.curve3(7.57, 30.08, 6.42, 31.35);
m_path.curve3(5.27, 32.62, 5.27, 34.81);
m_path.curve3(5.27, 39.01, 9.57, 42.53);
m_path.curve3(13.87, 46.04, 21.63, 46.04);
m_path.curve3(27.59, 46.04, 31.40, 44.04);
m_path.curve3(34.28, 42.53, 35.64, 39.31);
m_path.curve3(36.52, 37.21, 36.52, 30.71);
m_path.line_to(36.52, 15.53);
m_path.curve3(36.52, 9.13, 36.77, 7.69);
m_path.curve3(37.01, 6.25, 37.57, 5.76);
m_path.curve3(38.13, 5.27, 38.87, 5.27);
m_path.curve3(39.65, 5.27, 40.23, 5.62);
m_path.curve3(41.26, 6.25, 44.19, 9.18);
m_path.line_to(44.19, 6.45);
m_path.curve3(38.72, -0.88, 33.74, -0.88);
m_path.curve3(31.35, -0.88, 29.93, 0.78);
m_path.curve3(28.52, 2.44, 28.47, 6.45);
m_path.close_polygon();
m_path.move_to(28.47, 9.62);
m_path.line_to(28.47, 26.66);
m_path.curve3(21.09, 23.73, 18.95, 22.51);
m_path.curve3(15.09, 20.36, 13.43, 18.02);
m_path.curve3(11.77, 15.67, 11.77, 12.89);
m_path.curve3(11.77, 9.38, 13.87, 7.06);
m_path.curve3(15.97, 4.74, 18.70, 4.74);
m_path.curve3(22.41, 4.74, 28.47, 9.62);
m_path.close_polygon();
agg::trans_affine shape_mtx;
shape_mtx *= agg::trans_affine_scaling(4.0);
shape_mtx *= agg::trans_affine_translation(150, 100);
m_path.transform(shape_mtx);
agg::bounding_rect_single(m_shape, 0,
&m_shape_bounds.x1, &m_shape_bounds.y1,
&m_shape_bounds.x2, &m_shape_bounds.y2);
m_shadow_ctrl.xn(0) = m_shape_bounds.x1;
m_shadow_ctrl.yn(0) = m_shape_bounds.y1;
m_shadow_ctrl.xn(1) = m_shape_bounds.x2;
m_shadow_ctrl.yn(1) = m_shape_bounds.y1;
m_shadow_ctrl.xn(2) = m_shape_bounds.x2;
m_shadow_ctrl.yn(2) = m_shape_bounds.y2;
m_shadow_ctrl.xn(3) = m_shape_bounds.x1;
m_shadow_ctrl.yn(3) = m_shape_bounds.y2;
m_shadow_ctrl.line_color(agg::rgba(0, 0.3, 0.5, 0.3));
m_color_lut.resize(256);
unsigned i;
const agg::int8u* p = g_gradient_colors;
for(i = 0; i < 256; i++)
{
m_color_lut[i] = agg::rgba8(p[0], p[1], p[2], (i > 63) ? 255 : i * 4);//p[3]);
//m_color_lut[i].premultiply();
p += 4;
}
}
示例11:
the_application(agg::pix_format_e format, bool flip_y) :
agg::platform_support(format, flip_y),
m_method (10.0, 10.0, 130.0, 70.0, !flip_y),
m_radius (130 + 10.0, 10.0 + 4.0, 130 + 300.0, 10.0 + 8.0 + 4.0, !flip_y),
m_shadow_ctrl(4),
m_channel_r (10.0, 80.0, "Red", !flip_y),
m_channel_g (10.0, 95.0, "Green", !flip_y),
m_channel_b (10.0, 110.0, "Blue", !flip_y),
m_shape(m_path)
{
add_ctrl(m_method);
m_method.text_size(8);
m_method.add_item("Stack Blur");
m_method.add_item("Recursive Blur");
m_method.add_item("Channels");
m_method.cur_item(0);
add_ctrl(m_radius);
m_radius.range(0.0, 40.0);
m_radius.value(15.0);
m_radius.label("Blur Radius=%1.2f");
add_ctrl(m_shadow_ctrl);
add_ctrl(m_channel_r);
add_ctrl(m_channel_g);
add_ctrl(m_channel_b);
m_channel_g.status(true);
m_path.remove_all();
m_path.move_to(28.47, 6.45);
m_path.curve3(21.58, 1.12, 19.82, 0.29);
m_path.curve3(17.19, -0.93, 14.21, -0.93);
m_path.curve3(9.57, -0.93, 6.57, 2.25);
m_path.curve3(3.56, 5.42, 3.56, 10.60);
m_path.curve3(3.56, 13.87, 5.03, 16.26);
m_path.curve3(7.03, 19.58, 11.99, 22.51);
m_path.curve3(16.94, 25.44, 28.47, 29.64);
m_path.line_to(28.47, 31.40);
m_path.curve3(28.47, 38.09, 26.34, 40.58);
m_path.curve3(24.22, 43.07, 20.17, 43.07);
m_path.curve3(17.09, 43.07, 15.28, 41.41);
m_path.curve3(13.43, 39.75, 13.43, 37.60);
m_path.line_to(13.53, 34.77);
m_path.curve3(13.53, 32.52, 12.38, 31.30);
m_path.curve3(11.23, 30.08, 9.38, 30.08);
m_path.curve3(7.57, 30.08, 6.42, 31.35);
m_path.curve3(5.27, 32.62, 5.27, 34.81);
m_path.curve3(5.27, 39.01, 9.57, 42.53);
m_path.curve3(13.87, 46.04, 21.63, 46.04);
m_path.curve3(27.59, 46.04, 31.40, 44.04);
m_path.curve3(34.28, 42.53, 35.64, 39.31);
m_path.curve3(36.52, 37.21, 36.52, 30.71);
m_path.line_to(36.52, 15.53);
m_path.curve3(36.52, 9.13, 36.77, 7.69);
m_path.curve3(37.01, 6.25, 37.57, 5.76);
m_path.curve3(38.13, 5.27, 38.87, 5.27);
m_path.curve3(39.65, 5.27, 40.23, 5.62);
m_path.curve3(41.26, 6.25, 44.19, 9.18);
m_path.line_to(44.19, 6.45);
m_path.curve3(38.72, -0.88, 33.74, -0.88);
m_path.curve3(31.35, -0.88, 29.93, 0.78);
m_path.curve3(28.52, 2.44, 28.47, 6.45);
m_path.close_polygon();
m_path.move_to(28.47, 9.62);
m_path.line_to(28.47, 26.66);
m_path.curve3(21.09, 23.73, 18.95, 22.51);
m_path.curve3(15.09, 20.36, 13.43, 18.02);
m_path.curve3(11.77, 15.67, 11.77, 12.89);
m_path.curve3(11.77, 9.38, 13.87, 7.06);
m_path.curve3(15.97, 4.74, 18.70, 4.74);
m_path.curve3(22.41, 4.74, 28.47, 9.62);
m_path.close_polygon();
agg::trans_affine shape_mtx;
shape_mtx *= agg::trans_affine_scaling(4.0);
shape_mtx *= agg::trans_affine_translation(150, 100);
m_path.transform(shape_mtx);
agg::bounding_rect_single(m_shape, 0,
&m_shape_bounds.x1, &m_shape_bounds.y1,
&m_shape_bounds.x2, &m_shape_bounds.y2);
m_shadow_ctrl.xn(0) = m_shape_bounds.x1;
m_shadow_ctrl.yn(0) = m_shape_bounds.y1;
m_shadow_ctrl.xn(1) = m_shape_bounds.x2;
m_shadow_ctrl.yn(1) = m_shape_bounds.y1;
m_shadow_ctrl.xn(2) = m_shape_bounds.x2;
m_shadow_ctrl.yn(2) = m_shape_bounds.y2;
m_shadow_ctrl.xn(3) = m_shape_bounds.x1;
m_shadow_ctrl.yn(3) = m_shape_bounds.y2;
m_shadow_ctrl.line_color(agg::rgba(0, 0.3, 0.5, 0.3));
}