本文整理汇总了C++中agg::interactive_polygon::polygon方法的典型用法代码示例。如果您正苦于以下问题:C++ interactive_polygon::polygon方法的具体用法?C++ interactive_polygon::polygon怎么用?C++ interactive_polygon::polygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agg::interactive_polygon
的用法示例。
在下文中一共展示了interactive_polygon::polygon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_draw
virtual void on_draw()
{
pixfmt pixf(rbuf_window());
renderer_base rb(pixf);
renderer_solid r(rb);
rb.clear(agg::rgba(1, 1, 1));
scanline_type sl;
agg::rasterizer_scanline_aa<> ras;
agg::simple_polygon_vertex_source path1(m_poly1.polygon(),
m_poly1.num_points(),
false,
false);
agg::simple_polygon_vertex_source path2(m_poly2.polygon(),
m_poly2.num_points(),
false,
false);
typedef agg::conv_bspline<agg::simple_polygon_vertex_source> conv_bspline_type;
conv_bspline_type bspline1(path1);
conv_bspline_type bspline2(path2);
bspline1.interpolation_step(1.0 / m_num_points.value());
bspline2.interpolation_step(1.0 / m_num_points.value());
typedef agg::conv_curve<font_manager_type::path_adaptor_type> conv_font_curve_type;
typedef agg::conv_segmentator<conv_font_curve_type> conv_font_segm_type;
typedef agg::conv_transform<conv_font_segm_type, agg::trans_double_path> conv_font_trans_type;
agg::trans_double_path tcurve;
conv_font_curve_type fcurves(m_fman.path_adaptor());
conv_font_segm_type fsegm(fcurves);
conv_font_trans_type ftrans(fsegm, tcurve);
tcurve.preserve_x_scale(m_preserve_x_scale.status());
if(m_fixed_len.status()) tcurve.base_length(1140.0);
tcurve.base_height(30.0);
tcurve.add_paths(bspline1, bspline2);
fsegm.approximation_scale(3.0);
fcurves.approximation_scale(5.0);
if(m_feng.load_font(full_file_name("timesi.ttf"), 0, agg::glyph_ren_outline))
{
double x = 0.0;
double y = 3.0;
const char* p = text;
m_feng.hinting(false);
m_feng.height(40);
while(*p)
{
const agg::glyph_cache* glyph = m_fman.glyph(*p);
if(glyph)
{
if(x > tcurve.total_length1()) break;
m_fman.add_kerning(&x, &y);
m_fman.init_embedded_adaptors(glyph, x, y);
if(glyph->data_type == agg::glyph_data_outline)
{
ras.reset();
ras.add_path(ftrans);
r.color(agg::rgba8(0, 0, 0));
agg::render_scanlines(ras, sl, r);
}
// increment pen position
x += glyph->advance_x;
y += glyph->advance_y;
}
++p;
}
}
else
{
message("Please copy file timesi.ttf to the current directory\n"
"or download it from http://www.antigrain.com/timesi.zip");
}
typedef agg::conv_stroke<conv_bspline_type> conv_stroke_type;
conv_stroke_type stroke1(bspline1);
conv_stroke_type stroke2(bspline2);
stroke1.width(2.0);
stroke2.width(2.0);
r.color(agg::rgba8(170, 50, 20, 100));
ras.add_path(stroke1);
agg::render_scanlines(ras, sl, r);
ras.add_path(stroke2);
agg::render_scanlines(ras, sl, r);
//.........这里部分代码省略.........
示例2: on_draw
virtual void on_draw()
{
pixfmt pixf(rbuf_window());
renderer_base rb(pixf);
renderer_solid r(rb);
rb.clear(agg::rgba(1, 1, 1));
g_rasterizer.clip_box(0, 0, width(), height());
if(m_trans_type.cur_item() == 0)
{
agg::trans_bilinear tr(g_x1, g_y1, g_x2, g_y2, m_quad.polygon());
if(tr.is_valid())
{
//--------------------------
// Render transformed lion
//
agg::conv_transform<agg::path_storage,
agg::trans_bilinear> trans(g_path, tr);
agg::render_all_paths(g_rasterizer, g_scanline, r, trans, g_colors, g_path_idx, g_npaths);
//--------------------------
//--------------------------
// Render transformed ellipse
//
agg::ellipse ell((g_x1 + g_x2) * 0.5, (g_y1 + g_y2) * 0.5,
(g_x2 - g_x1) * 0.5, (g_y2 - g_y1) * 0.5,
200);
agg::conv_stroke<agg::ellipse> ell_stroke(ell);
ell_stroke.width(3.0);
agg::conv_transform<agg::ellipse,
agg::trans_bilinear> trans_ell(ell, tr);
agg::conv_transform<agg::conv_stroke<agg::ellipse>,
agg::trans_bilinear> trans_ell_stroke(ell_stroke, tr);
g_rasterizer.add_path(trans_ell);
r.color(agg::rgba(0.5, 0.3, 0.0, 0.3));
agg::render_scanlines(g_rasterizer, g_scanline, r);
g_rasterizer.add_path(trans_ell_stroke);
r.color(agg::rgba(0.0, 0.3, 0.2, 1.0));
agg::render_scanlines(g_rasterizer, g_scanline, r);
//--------------------------
}
}
else
{
agg::trans_perspective tr(g_x1, g_y1, g_x2, g_y2, m_quad.polygon());
if(tr.is_valid())
{
//--------------------------
// Render transformed lion
//
agg::conv_transform<agg::path_storage,
agg::trans_perspective> trans(g_path, tr);
agg::render_all_paths(g_rasterizer, g_scanline, r, trans, g_colors, g_path_idx, g_npaths);
//--------------------------
//--------------------------
// Render transformed ellipse
//
agg::ellipse ell((g_x1 + g_x2) * 0.5, (g_y1 + g_y2) * 0.5,
(g_x2 - g_x1) * 0.5, (g_y2 - g_y1) * 0.5,
200);
agg::conv_stroke<agg::ellipse> ell_stroke(ell);
ell_stroke.width(3.0);
agg::conv_transform<agg::ellipse,
agg::trans_perspective> trans_ell(ell, tr);
agg::conv_transform<agg::conv_stroke<agg::ellipse>,
agg::trans_perspective> trans_ell_stroke(ell_stroke, tr);
g_rasterizer.add_path(trans_ell);
r.color(agg::rgba(0.5, 0.3, 0.0, 0.3));
agg::render_scanlines(g_rasterizer, g_scanline, r);
g_rasterizer.add_path(trans_ell_stroke);
r.color(agg::rgba(0.0, 0.3, 0.2, 1.0));
agg::render_scanlines(g_rasterizer, g_scanline, r);
//--------------------------
// Testing the reverse transformations
//agg::trans_perspective tr2(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
//if(tr2.is_valid())
//{
// double x, y;
//.........这里部分代码省略.........
示例3: on_draw
virtual void on_draw()
{
pixfmt pixf(rbuf_window());
pixfmt_pre pixf_pre(rbuf_window());
renderer_base rb(pixf);
renderer_base_pre rb_pre(pixf_pre);
if(!m_test_flag)
{
rb.clear(agg::rgba(1, 1, 1));
}
if(m_trans_type.cur_item() == 0)
{
// For the affine parallelogram transformations we
// calculate the 4-th (implicit) point of the parallelogram
m_quad.xn(3) = m_quad.xn(0) + (m_quad.xn(2) - m_quad.xn(1));
m_quad.yn(3) = m_quad.yn(0) + (m_quad.yn(2) - m_quad.yn(1));
}
if(!m_test_flag)
{
//--------------------------
// Render the "quad" tool and controls
g_rasterizer.add_path(m_quad);
agg::render_scanlines_aa_solid(g_rasterizer, g_scanline, rb, agg::rgba(0, 0.3, 0.5, 0.6));
//--------------------------
agg::render_ctrl(g_rasterizer, g_scanline, rb, m_trans_type);
}
// Prepare the polygon to rasterize. Here we need to fill
// the destination (transformed) polygon.
g_rasterizer.clip_box(0, 0, width(), height());
g_rasterizer.reset();
g_rasterizer.move_to_d(m_quad.xn(0), m_quad.yn(0));
g_rasterizer.line_to_d(m_quad.xn(1), m_quad.yn(1));
g_rasterizer.line_to_d(m_quad.xn(2), m_quad.yn(2));
g_rasterizer.line_to_d(m_quad.xn(3), m_quad.yn(3));
typedef agg::span_allocator<color_type> span_alloc_type;
span_alloc_type sa;
agg::image_filter<agg::image_filter_hanning> filter;
typedef agg::wrap_mode_reflect_auto_pow2 remainder_type;
typedef agg::image_accessor_wrap<pixfmt,
remainder_type,
remainder_type> img_source_type;
pixfmt img_pixf(rbuf_img(0));
img_source_type img_src(img_pixf);
enum subdiv_shift_e { subdiv_shift = 2 };
switch(m_trans_type.cur_item())
{
case 0:
{
// Note that we consruct an affine matrix that transforms
// a parallelogram to a rectangle, i.e., it's inverted.
// It's actually the same as:
// tr(g_x1, g_y1, g_x2, g_y2, m_triangle.polygon());
// tr.invert();
agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
// Also note that we can use the linear interpolator instead of
// arbitrary span_interpolator_trans. It works much faster,
// but the transformations must be linear and parellel.
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
interpolator_type interpolator(tr);
typedef span_image_filter_2x2<img_source_type,
interpolator_type> span_gen_type;
span_gen_type sg(img_src, interpolator, filter);
agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
break;
}
case 1:
{
agg::trans_bilinear tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
if(tr.is_valid())
{
typedef agg::span_interpolator_linear<agg::trans_bilinear> interpolator_type;
interpolator_type interpolator(tr);
typedef span_image_filter_2x2<img_source_type,
interpolator_type> span_gen_type;
span_gen_type sg(img_src, interpolator, filter);
agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
}
break;
}
case 2:
{
agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
if(tr.is_valid())
{
//.........这里部分代码省略.........
示例4: on_draw
virtual void on_draw()
{
pixfmt pixf(rbuf_window());
renderer_base rb(pixf);
renderer_solid r(rb);
rb.clear(agg::rgba(1, 1, 1));
scanline_type sl;
agg::rasterizer_scanline_aa<> ras;
agg::rasterizer_scanline_aa<> ras1;
agg::rasterizer_scanline_aa<> ras2;
agg::sbool_op_e op = (agg::sbool_op_e)m_trans_type.cur_item();
ras1.gamma(agg::gamma_multiply(m_mul1.value()));
ras2.gamma(agg::gamma_multiply(m_mul2.value()));
ras.clip_box(0, 0, width(), height());
agg::path_storage ps1;
generate_circles(ps1, m_quad1.polygon(), 5, 20);
agg::path_storage ps2;
generate_circles(ps2, m_quad2.polygon(), 5, 20);
ras1.filling_rule(agg::fill_even_odd);
r.color(agg::rgba8(240, 255, 200, 100));
ras1.add_path(ps1);
agg::render_scanlines(ras1, sl, r);
r.color(agg::rgba8(255, 240, 240, 100));
ras2.add_path(ps2);
agg::render_scanlines(ras2, sl, r);
typedef agg::scanline_p8 sbool_scanline_type;
typedef agg::renderer_scanline_aa_solid<renderer_base> sbool_renderer_type;
sbool_scanline_type sl_result;
sbool_scanline_type sl1;
sbool_scanline_type sl2;
sbool_renderer_type sren(rb);
sren.color(agg::rgba8(0, 0, 0));
agg::sbool_combine_shapes_aa(op, ras1, ras2, sl1, sl2, sl_result, sren);
//--------------------------
// Render the "quad" tools and controls
r.color(agg::rgba(0, 0.3, 0.5, 0.6));
ras.add_path(m_quad1);
agg::render_scanlines(ras, sl, r);
ras.add_path(m_quad2);
agg::render_scanlines(ras, sl, r);
agg::render_ctrl(ras, sl, rb, m_trans_type);
agg::render_ctrl(ras, sl, rb, m_reset);
agg::render_ctrl(ras, sl, rb, m_mul1);
agg::render_ctrl(ras, sl, rb, m_mul2);
//--------------------------
}
示例5: on_draw
virtual void on_draw()
{
pixfmt pixf(rbuf_window());
renderer_base rb(pixf);
renderer_solid r(rb);
rb.clear(agg::rgba(1, 1, 1));
scanline_type sl;
agg::rasterizer_scanline_aa<> ras;
m_poly.close(m_close.status());
agg::simple_polygon_vertex_source path(m_poly.polygon(),
m_poly.num_points(),
false,
m_close.status());
typedef agg::conv_bspline<agg::simple_polygon_vertex_source> conv_bspline_type;
conv_bspline_type bspline(path);
bspline.interpolation_step(1.0 / m_num_points.value());
agg::trans_single_path tcurve;
tcurve.add_path(bspline);
tcurve.preserve_x_scale(m_preserve_x_scale.status());
if(m_fixed_len.status()) tcurve.base_length(1120);
typedef agg::conv_curve<font_manager_type::path_adaptor_type> conv_font_curve_type;
typedef agg::conv_segmentator<conv_font_curve_type> conv_font_segm_type;
typedef agg::conv_transform<conv_font_segm_type, agg::trans_single_path> conv_font_trans_type;
conv_font_curve_type fcurves(m_fman.path_adaptor());
conv_font_segm_type fsegm(fcurves);
conv_font_trans_type ftrans(fsegm, tcurve);
fsegm.approximation_scale(3.0);
fcurves.approximation_scale(2.0);
m_feng.height(40.0);
//m_feng.italic(true);
if(m_feng.create_font("Times New Roman", agg::glyph_ren_outline))
{
double x = 0.0;
double y = 3.0;
const char* p = text;
while(*p)
{
const agg::glyph_cache* glyph = m_fman.glyph(*p);
if(glyph)
{
if(x > tcurve.total_length()) break;
m_fman.add_kerning(&x, &y);
m_fman.init_embedded_adaptors(glyph, x, y);
if(glyph->data_type == agg::glyph_data_outline)
{
ras.reset();
ras.add_path(ftrans);
r.color(agg::rgba8(0, 0, 0));
agg::render_scanlines(ras, sl, r);
}
// increment pen position
x += glyph->advance_x;
y += glyph->advance_y;
}
++p;
}
}
typedef agg::conv_stroke<conv_bspline_type> conv_stroke_type;
conv_stroke_type stroke(bspline);
stroke.width(2.0);
r.color(agg::rgba8(170, 50, 20, 100));
ras.add_path(stroke);
agg::render_scanlines(ras, sl, r);
//--------------------------
// Render the "poly" tool and controls
r.color(agg::rgba(0, 0.3, 0.5, 0.3));
ras.add_path(m_poly);
agg::render_scanlines(ras, sl, r);
agg::render_ctrl(ras, sl, rb, m_close);
agg::render_ctrl(ras, sl, rb, m_preserve_x_scale);
agg::render_ctrl(ras, sl, rb, m_fixed_len);
agg::render_ctrl(ras, sl, rb, m_animate);
agg::render_ctrl(ras, sl, rb, m_num_points);
//--------------------------
}
示例6: on_draw
virtual void on_draw()
{
if(m_gamma.value() != m_old_gamma)
{
m_gamma_lut.gamma(m_gamma.value());
load_img(0, "spheres");
pixfmt pixf(rbuf_img(0));
pixf.apply_gamma_dir(m_gamma_lut);
m_old_gamma = m_gamma.value();
}
pixfmt pixf(rbuf_window());
pixfmt_pre pixf_pre(rbuf_window());
renderer_base rb(pixf);
renderer_base_pre rb_pre(pixf_pre);
renderer_solid r(rb);
rb.clear(agg::rgba(1, 1, 1));
if(m_trans_type.cur_item() < 2)
{
// For the affine parallelogram transformations we
// calculate the 4-th (implicit) point of the parallelogram
m_quad.xn(3) = m_quad.xn(0) + (m_quad.xn(2) - m_quad.xn(1));
m_quad.yn(3) = m_quad.yn(0) + (m_quad.yn(2) - m_quad.yn(1));
}
//--------------------------
// Render the "quad" tool and controls
g_rasterizer.add_path(m_quad);
r.color(agg::rgba(0, 0.3, 0.5, 0.1));
agg::render_scanlines(g_rasterizer, g_scanline, r);
// Prepare the polygon to rasterize. Here we need to fill
// the destination (transformed) polygon.
g_rasterizer.clip_box(0, 0, width(), height());
g_rasterizer.reset();
int b = 0;
g_rasterizer.move_to_d(m_quad.xn(0)-b, m_quad.yn(0)-b);
g_rasterizer.line_to_d(m_quad.xn(1)+b, m_quad.yn(1)-b);
g_rasterizer.line_to_d(m_quad.xn(2)+b, m_quad.yn(2)+b);
g_rasterizer.line_to_d(m_quad.xn(3)-b, m_quad.yn(3)+b);
typedef agg::span_allocator<color_type> span_alloc_type;
span_alloc_type sa;
agg::image_filter_bilinear filter_kernel;
agg::image_filter_lut filter(filter_kernel, true);
pixfmt pixf_img(rbuf_img(0));
typedef agg::image_accessor_clone<pixfmt> source_type;
source_type source(pixf_img);
start_timer();
switch(m_trans_type.cur_item())
{
case 0:
{
agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
interpolator_type interpolator(tr);
typedef image_filter_2x2_type<source_type,
interpolator_type> span_gen_type;
span_gen_type sg(source, interpolator, filter);
agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
break;
}
case 1:
{
agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
typedef image_resample_affine_type<source_type> span_gen_type;
interpolator_type interpolator(tr);
span_gen_type sg(source, interpolator, filter);
sg.blur(m_blur.value());
agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
break;
}
case 2:
{
agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
if(tr.is_valid())
{
typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type;
interpolator_type interpolator(tr);
typedef image_filter_2x2_type<source_type,
interpolator_type> span_gen_type;
span_gen_type sg(source, interpolator, filter);
agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
}
break;
}
//.........这里部分代码省略.........