Beispiel #1
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_idx(-1),
        m_gamma(130 + 10.0, 10.0 + 4.0, 130 + 150.0, 10.0 + 8.0 + 4.0, !flip_y),
        m_alpha(130 + 150.0 + 10.0, 10.0 + 4.0, 500 - 10.0, 10.0 + 8.0 + 4.0, !flip_y),
        m_test(130 + 10.0, 10.0 + 4.0 + 16.0,    "Test Performance", !flip_y)
    {
        m_x[0] = 100 + 120; m_y[0] = 60;
        m_x[1] = 369 + 120; m_y[1] = 170;
        m_x[2] = 143 + 120; m_y[2] = 310;

        add_ctrl(m_gamma);
        m_gamma.range(0.0, 1.0);
        m_gamma.value(0.5);
        m_gamma.label("Gamma=%1.2f");
        m_gamma.no_transform();

        add_ctrl(m_alpha);
        m_alpha.range(0.0, 1.0);
        m_alpha.value(1.0);
        m_alpha.label("Alpha=%1.2f");
        m_alpha.no_transform();

        add_ctrl(m_test);
        m_test.no_transform();
    }
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_ctrl_color(agg::rgba(0, 0.3, 0.5, 0.3)),
        m_line1(5),
        m_scale_x(5.0,   5.0, 240.0, 12.0, !flip_y),
        m_start_x(250.0, 5.0, 495.0, 12.0, !flip_y)
    {
        m_line1.line_color(m_ctrl_color);
        m_line1.xn(0) = 20;
        m_line1.yn(0) = 20;
        m_line1.xn(1) = 500-20;
        m_line1.yn(1) = 500-20;
        m_line1.xn(2) = 500-60;
        m_line1.yn(2) = 20;
        m_line1.xn(3) = 40;
        m_line1.yn(3) = 500-40;
        m_line1.xn(4) = 100;
        m_line1.yn(4) = 300;
        m_line1.close(false);

        add_ctrl(m_line1);
        m_line1.transform(m_scale);

        m_scale_x.label("Scale X=%.2f");
        m_scale_x.range(0.2, 3.0);
        m_scale_x.value(1.0);
        add_ctrl(m_scale_x);
        m_scale_x.no_transform();

        m_start_x.label("Start X=%.2f");
        m_start_x.range(0.0, 10.0);
        m_start_x.value(0.0);
        add_ctrl(m_start_x);
        m_start_x.no_transform();
    }
Beispiel #3
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_idx(-1),
        m_radius(10, 10, 600-10,   19,    !flip_y),
        m_gamma(10, 10+20, 600-10, 19+20, !flip_y),
        m_offset(10, 10+40, 600-10, 19+40, !flip_y),
        m_white_on_black(10, 10+60, "White on black")
    {
        m_x[0] = 100;   m_y[0] = 100;
        m_x[1] = 500;   m_y[1] = 350;
        add_ctrl(m_radius);
        add_ctrl(m_gamma);
        add_ctrl(m_offset);
        add_ctrl(m_white_on_black);
        m_gamma.label("gamma=%4.3f");
        m_gamma.range(0.0, 3.0);
        m_gamma.value(1.8);

        m_radius.label("radius=%4.3f");
        m_radius.range(0.0, 50.0);
        m_radius.value(25.0);

        m_offset.label("subpixel offset=%4.3f");
        m_offset.range(-2.0, 3.0);

        m_white_on_black.text_color(agg::rgba8(127, 127, 127));
        m_white_on_black.inactive_color(agg::rgba8(127, 127, 127));
    }
    //------------------------------------------------------------------------
    virtual void on_idle() 
    {
        bool redraw = false;
        if(m_rotate_polygon.status())
        {
            m_polygon_angle.value(m_polygon_angle.value() + 0.5);
            if(m_polygon_angle.value() >= 180.0) 
            {
                m_polygon_angle.value(m_polygon_angle.value() - 360.0);
            }
            redraw = true;
        }

        if(m_rotate_image.status())
        {
            m_image_angle.value(m_image_angle.value() + 0.5);
            if(m_image_angle.value() >= 180.0) 
            {
                m_image_angle.value(m_image_angle.value() - 360.0);
            }
            redraw = true;
        }

        if(redraw) force_redraw();

    }
 the_application(agg::pix_format_e format, bool flip_y) :
     agg::platform_support(format, flip_y),
     m_quad1(4, 5.0),
     m_quad2(4, 5.0),
     m_trans_type(420, 5.0, 420+130.0, 145.0, !flip_y),
     m_reset     (350, 5.0,  "Reset", !flip_y),
     m_mul1      (5.0,  5.0, 340.0, 12.0, !flip_y),
     m_mul2      (5.0, 20.0, 340.0, 27.0, !flip_y)
 {
     m_trans_type.add_item("Union");
     m_trans_type.add_item("Intersection");
     m_trans_type.add_item("Linear XOR");
     m_trans_type.add_item("Saddle XOR");
     m_trans_type.add_item("Abs Diff XOR");
     m_trans_type.add_item("A-B");
     m_trans_type.add_item("B-A");
     m_trans_type.cur_item(0);
     add_ctrl(m_trans_type);
     add_ctrl(m_reset);
     add_ctrl(m_mul1);
     add_ctrl(m_mul2);
     m_mul1.value(1.0);
     m_mul2.value(1.0);
     m_mul1.label("Opacity1=%.3f");
     m_mul2.label("Opacity2=%.3f");
 }
Beispiel #6
0
    //------------------------------------------------------------------------
    virtual void on_idle() 
    {
        bool redraw = false;
        if(m_rotate_polygon.status())
        {
            m_polygon_angle.value(m_polygon_angle.value() + 0.5);
            if(m_polygon_angle.value() >= 180.0) 
            {
                m_polygon_angle.value(m_polygon_angle.value() - 360.0);
            }
            redraw = true;
        }

        if(m_rotate_pattern.status())
        {
            m_pattern_angle.value(m_pattern_angle.value() - 0.5);
            if(m_pattern_angle.value() <= -180.0) 
            {
                m_pattern_angle.value(m_pattern_angle.value() + 360.0);
            }
            generate_pattern();
            redraw = true;
        }

        if(redraw) force_redraw();

    }
Beispiel #7
0
    virtual void on_draw()
    {
        prim_pixfmt_type pixf(rbuf_window());
        prim_ren_base_type rb(pixf);
        rb.clear(agg::rgba8(255, 255, 255));

        generate_color_ramp(m_ramp1, 
                            agg::rgba(0, 0, 0, m_alpha_dst.value()),
                            agg::rgba(0, 0, 1, m_alpha_dst.value()),
                            agg::rgba(0, 1, 0, m_alpha_dst.value()),
                            agg::rgba(1, 0, 0, 0));

        generate_color_ramp(m_ramp2, 
                            agg::rgba(0, 0, 0, m_alpha_src.value()),
                            agg::rgba(0, 0, 1, m_alpha_src.value()),
                            agg::rgba(0, 1, 0, m_alpha_src.value()),
                            agg::rgba(1, 0, 0, 0));

        render_scene(rb);
        agg::renderer_scanline_aa_solid<prim_ren_base_type> ren(rb);

        agg::render_ctrl_rs(m_ras, m_sl, ren, m_alpha_dst);
        agg::render_ctrl_rs(m_ras, m_sl, ren, m_alpha_src);
        agg::render_ctrl_rs(m_ras, m_sl, ren, m_comp_op);
    }
Beispiel #8
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_step  (115,  5,    400, 11,     !flip_y),
        m_radius(115,  5+15, 400, 11+15,  !flip_y),
        m_filters(0.0, 0.0, 110.0, 210.0, !flip_y),
        m_normalize  (8.0, 215.0, "Normalize Filter", !flip_y),
        m_run        (8.0, 245.0, "RUN Test!", !flip_y),
        m_single_step(8.0, 230.0, "Single Step", !flip_y),
        m_refresh    (8.0, 265.0, "Refresh", !flip_y),
        m_cur_angle(0.0),
        m_cur_filter(1),
        m_num_steps(0),
        m_num_pix(0.0),
        m_time1(0),
        m_time2(0)
    {
        add_ctrl(m_radius);
        add_ctrl(m_step);
        add_ctrl(m_filters);
        add_ctrl(m_run);
        add_ctrl(m_single_step);
        add_ctrl(m_normalize);
        add_ctrl(m_refresh);
        m_run.text_size(7.5);
        m_single_step.text_size(7.5);
        m_normalize.text_size(7.5);
        m_refresh.text_size(7.5);
        m_normalize.status(true);

        m_radius.label("Filter Radius=%.3f");
        m_step.label("Step=%3.2f");
        m_radius.range(2.0, 8.0);
        m_radius.value(4.0);
        m_step.range(1.0, 10.0);
        m_step.value(5.0);

        m_filters.add_item("simple (NN)");
        m_filters.add_item("bilinear");
        m_filters.add_item("bicubic");
        m_filters.add_item("spline16");
        m_filters.add_item("spline36");
        m_filters.add_item("hanning");
        m_filters.add_item("hamming");
        m_filters.add_item("hermite");
        m_filters.add_item("kaiser");
        m_filters.add_item("quadric");
        m_filters.add_item("catrom");
        m_filters.add_item("gaussian");
        m_filters.add_item("bessel");
        m_filters.add_item("mitchell");
        m_filters.add_item("sinc");
        m_filters.add_item("lanczos");
        m_filters.add_item("blackman");
        m_filters.cur_item(1);

        m_filters.border_width(0, 0);
        m_filters.background_color(agg::rgba(0.0, 0.0, 0.0, 0.1));
        m_filters.text_size(6.0);
        m_filters.text_thickness(0.85);
    }
Beispiel #9
0
    virtual void on_key(int x, int y, unsigned key, unsigned flags)
    {
        if(key == ' ')
        {

            agg::trans_affine mtx;
            mtx *= agg::trans_affine_translation((m_min_x + m_max_x) * -0.5, (m_min_y + m_max_y) * -0.5);
            mtx *= agg::trans_affine_scaling(m_scale.value());
            mtx *= agg::trans_affine_rotation(agg::deg2rad(m_rotate.value()));
            mtx *= agg::trans_affine_translation((m_min_x + m_max_x) * 0.5, (m_min_y + m_max_y) * 0.5);
            mtx *= agg::trans_affine_translation(m_x, m_y);

            double m[6];
            mtx.store_to(m);

            char buf[128];
            sprintf(buf, "%3.3f, %3.3f, %3.3f, %3.3f, %3.3f, %3.3f",
                         m[0], m[1], m[2], m[3], m[4], m[5]);

            message(buf);
            FILE* fd = fopen("transform.txt", "a");
            fprintf(fd, "%s\n", buf);
            fclose(fd);
        }
    }
Beispiel #10
0
    void on_idle()
    {
        if(m_run.status())
        {
            if(m_cur_angle < 360.0)
            {
                m_cur_angle += m_step.value();
                copy_img_to_img(1, 0);
#ifdef AGG_ACCURATE_TIME
                start_timer();
#endif
                transform_image(m_step.value());
#ifdef AGG_ACCURATE_TIME
                m_time2 += elapsed_time();
#endif
                m_num_steps++;
            }
            else
            {
                m_cur_angle = 0.0;
#ifndef AGG_ACCURATE_TIME
                m_time2 = clock();
#endif
                wait_mode(true);
                m_run.status(false);
            }
            force_redraw();
        }
        else
        {
            wait_mode(true);
        }
    }
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_gamma_lut(2.0),
        m_quad(4, 5.0),
        m_trans_type(400, 5.0, 430+170.0, 100.0, !flip_y),
        m_gamma(5.0, 5.0+15*0, 400-5, 10.0+15*0, !flip_y),
        m_blur (5.0, 5.0+15*1, 400-5, 10.0+15*1, !flip_y),
        m_old_gamma(2.0)
    {
        m_trans_type.text_size(7);
        m_trans_type.add_item("Affine No Resample");
        m_trans_type.add_item("Affine Resample");
        m_trans_type.add_item("Perspective No Resample LERP");
        m_trans_type.add_item("Perspective No Resample Exact");
        m_trans_type.add_item("Perspective Resample LERP");
        m_trans_type.add_item("Perspective Resample Exact");
        m_trans_type.cur_item(4);
        add_ctrl(m_trans_type);

        m_gamma.range(0.5, 3.0);
        m_gamma.value(2.0);
        m_gamma.label("Gamma=%.3f");
        add_ctrl(m_gamma);

        m_blur.range(0.5, 5.0);
        m_blur.value(1.0);
        m_blur.label("Blur=%.3f");
        add_ctrl(m_blur);
    }
Beispiel #12
0
  //------------------------------------------------------------------------
  virtual void on_mouse_button_down(int x, int y, unsigned flags) {
    if (flags & agg::mouse_left) {
      if (sqrt((x - m_image_cx) * (x - m_image_cx) +
               (y - m_image_cy) * (y - m_image_cy)) < 5.0) {
        m_dx = x - m_image_cx;
        m_dy = y - m_image_cy;
        m_flag = 1;
      } else {
        agg::rasterizer_scanline_aa<> ras;
        agg::trans_affine polygon_mtx;

        polygon_mtx *=
            agg::trans_affine_translation(-m_polygon_cx, -m_polygon_cy);
        polygon_mtx *= agg::trans_affine_rotation(m_polygon_angle.value() *
                                                  agg::pi / 180.0);
        polygon_mtx *= agg::trans_affine_scaling(m_polygon_scale.value(),
                                                 m_polygon_scale.value());
        polygon_mtx *=
            agg::trans_affine_translation(m_polygon_cx, m_polygon_cy);

        agg::path_storage ps;
        create_star(ps);

        agg::conv_transform<agg::path_storage> tr(ps, polygon_mtx);
        ras.add_path(tr);
        if (ras.hit_test(x, y)) {
          m_dx = x - m_polygon_cx;
          m_dy = y - m_polygon_cy;
          m_flag = 2;
        }
      }
    }
  }
Beispiel #13
0
    void draw_aliased()
    {
        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_bin ren_bin(rb);

        agg::path_storage path;
        

        path.move_to(m_x[0] - 200, m_y[0]);
        path.line_to(m_x[1] - 200, m_y[1]);
        path.line_to(m_x[2] - 200, m_y[2]);
        path.close_polygon();

        ren_bin.color(agg::rgba(0.1, 0.5, 0.7, m_alpha.value()));

        m_ras.gamma(agg::gamma_threshold(m_gamma.value()));
        m_ras.add_path(path);
        agg::render_scanlines(m_ras, m_sl_bin, ren_bin);

        //-- Drawing an outline with subpixel accuracy (aliased)
        //typedef agg::renderer_primitives<renderer_base> renderer_pr;
        //renderer_pr ren_pr(rb);
        //agg::rasterizer_outline<renderer_pr> ras_line(ren_pr);
        //ren_pr.line_color(agg::rgba(0.0, 0.0, 0.0));
        //ras_line.add_path(path);
    }
Beispiel #14
0
  virtual void on_draw() {
    agg::rasterizer_scanline_aa<> pf;
    agg::scanline_p8 sl;

    typedef agg::renderer_base<pixfmt> renderer_base;

    pixfmt pixf(rbuf_window());
    renderer_base rb(pixf);

    rb.clear(agg::rgba(1, 1, 1));

    agg::ellipse e1;
    agg::conv_transform<agg::ellipse> t1(e1, trans_affine_resizing());

    unsigned i;
    unsigned n_drawn = 0;
    for (i = 0; i < m_num_points; i++) {
      double z = m_points[i].z;
      double alpha = 1.0;
      if (z < m_scale_ctrl_z.value1()) {
        alpha = 1.0 - (m_scale_ctrl_z.value1() - z) *
                          m_slider_ctrl_sel.value() * 100.0;
      }

      if (z > m_scale_ctrl_z.value2()) {
        alpha = 1.0 - (z - m_scale_ctrl_z.value2()) *
                          m_slider_ctrl_sel.value() * 100.0;
      }

      if (alpha > 1.0) alpha = 1.0;
      if (alpha < 0.0) alpha = 0.0;

      if (alpha > 0.0) {
        e1.init(m_points[i].x, m_points[i].y, m_slider_ctrl_size.value() * 5.0,
                m_slider_ctrl_size.value() * 5.0, 8);
        pf.add_path(t1);

        agg::render_scanlines_aa_solid(
            pf, sl, rb, agg::rgba(m_points[i].color.r, m_points[i].color.g,
                                  m_points[i].color.b, alpha));
        n_drawn++;
      }
    }

    agg::render_ctrl(pf, sl, rb, m_scale_ctrl_z);
    agg::render_ctrl(pf, sl, rb, m_slider_ctrl_sel);
    agg::render_ctrl(pf, sl, rb, m_slider_ctrl_size);

    char buf[10];
    sprintf(buf, "%08u", n_drawn);

    agg::gsv_text txt;
    txt.size(15.0);
    txt.text(buf);
    txt.start_point(10.0, initial_height() - 20.0);
    agg::gsv_text_outline<> txt_o(txt, trans_affine_resizing());
    pf.add_path(txt_o);
    agg::render_scanlines_aa_solid(pf, sl, rb, agg::rgba(0, 0, 0));
  }
Beispiel #15
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_ctrl_color(agg::rgba(0, 0.3, 0.5, 0.3)),
        m_scale_x(5.0,   5.0, 240.0, 12.0, !flip_y),
        m_start_x(250.0, 5.0, 495.0, 12.0, !flip_y)
    {
        m_curve1.line_color(m_ctrl_color);
        m_curve2.line_color(m_ctrl_color);
        m_curve3.line_color(m_ctrl_color);
        m_curve4.line_color(m_ctrl_color);
        m_curve5.line_color(m_ctrl_color);
        m_curve6.line_color(m_ctrl_color);
        m_curve7.line_color(m_ctrl_color);
        m_curve8.line_color(m_ctrl_color);
        m_curve9.line_color(m_ctrl_color);

        m_curve1.curve(64, 19, 14, 126, 118, 266, 19, 265);
        m_curve2.curve(112, 113, 178, 32, 200, 132, 125, 438);
        m_curve3.curve(401, 24, 326, 149, 285, 11, 177, 77);
        m_curve4.curve(188, 427, 129, 295, 19, 283, 25, 410);
        m_curve5.curve(451, 346, 302, 218, 265, 441, 459, 400);
        m_curve6.curve(454, 198, 14, 13, 220, 291, 483, 283);
        m_curve7.curve(301, 398, 355, 231, 209, 211, 170, 353);
        m_curve8.curve(484, 101, 222, 33, 486, 435, 487, 138);
        m_curve9.curve(143, 147, 11, 45, 83, 427, 132, 197);

        add_ctrl(m_curve1);
        add_ctrl(m_curve2);
        add_ctrl(m_curve3);
        add_ctrl(m_curve4);
        add_ctrl(m_curve5);
        add_ctrl(m_curve6);
        add_ctrl(m_curve7);
        add_ctrl(m_curve8);
        add_ctrl(m_curve9);

        m_curve1.no_transform();
        m_curve2.no_transform();
        m_curve3.no_transform();
        m_curve4.no_transform();
        m_curve5.no_transform();
        m_curve6.no_transform();
        m_curve7.no_transform();
        m_curve8.no_transform();
        m_curve9.no_transform();

        m_scale_x.label("Scale X=%.2f");
        m_scale_x.range(0.2, 3.0);
        m_scale_x.value(1.0);
        m_scale_x.no_transform();
        add_ctrl(m_scale_x);

        m_start_x.label("Start X=%.2f");
        m_start_x.range(0.0, 10.0);
        m_start_x.value(0.0);
        m_start_x.no_transform();
        add_ctrl(m_start_x);
    }
Beispiel #16
0
 void draw_curve(Pattern& patt, 
                 Rasterizer& ras, 
                 Renderer& ren, 
                 PatternSource& src, 
                 VertexSource& vs)
 {
     patt.create(src);
     ren.scale_x(m_scale_x.value());
     ren.start_x(m_start_x.value());
     ras.add_path(vs);
 }
Beispiel #17
0
    virtual void on_draw()
    {
        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid r(rb);

        rb.clear(agg::rgba(1, 1, 1));

        agg::trans_warp_magnifier lens;
        lens.center(g_x1, g_y1);
        lens.magnification(m_magn_slider.value());
        lens.radius(m_radius_slider.value() / m_magn_slider.value());

        agg::conv_segmentator<agg::path_storage> segm(g_path);

        agg::trans_affine mtx;
        mtx *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
        mtx *= agg::trans_affine_rotation(g_angle + agg::pi);
        mtx *= agg::trans_affine_translation(width()/2, height()/2);

        agg::conv_transform<
            agg::conv_segmentator<
                agg::path_storage> > trans_mtx(segm, mtx);

        agg::conv_transform<
            agg::conv_transform<
                agg::conv_segmentator<
                    agg::path_storage> >, agg::trans_warp_magnifier> trans_lens(trans_mtx, lens);

        agg::render_all_paths(g_rasterizer, g_scanline, r, trans_lens, g_colors, g_path_idx, g_npaths);

        agg::render_ctrl(g_rasterizer, g_scanline, rb, m_magn_slider);
        agg::render_ctrl(g_rasterizer, g_scanline, rb, m_radius_slider);


        // Testing inverse_transform()
        //--------------------
        //double x, y;
        //for(y = 0; y < height(); y += 10)
        //{
        //    for(x = 0; x < height(); x += 10)
        //    {
        //        double x2 = x+0.5;
        //        double y2 = y+0.5;
        //        lens.transform(&x2, &y2);
        //        lens.inverse_transform(&x2, &y2);
        //        agg::ellipse e(x2, y2, 1, 1);
        //        g_rasterizer.add_path(e);
        //        r.color(agg::rgba8(0,0,0));
        //        agg::render_scanlines(g_rasterizer, g_scanline, r);
        //    }
        //}
    }
Beispiel #18
0
 virtual void on_idle()
 {
     unsigned i;
     for(i = 0; i < m_num_points; i++)
     {
         m_points[i].x += random_dbl(0, m_slider_ctrl_sel.value()) - m_slider_ctrl_sel.value()*0.5;
         m_points[i].y += random_dbl(0, m_slider_ctrl_sel.value()) - m_slider_ctrl_sel.value()*0.5;
         m_points[i].z += random_dbl(0, m_slider_ctrl_sel.value()*0.01) - m_slider_ctrl_sel.value()*0.005;
         if(m_points[i].z < 0.0) m_points[i].z = 0.0;
         if(m_points[i].z > 1.0) m_points[i].z = 1.0;
     }
     force_redraw();
 }
Beispiel #19
0
 the_application(agg::pix_format_e format, bool flip_y) :
     agg::platform_support(format, flip_y),
     m_angle(5,  5,    300, 12,    !flip_y),
     m_scale(5,  5+15, 300, 12+15, !flip_y)
 {
     add_ctrl(m_angle);
     add_ctrl(m_scale);
     m_angle.label("Angle=%3.2f");
     m_scale.label("Scale=%3.2f");
     m_angle.range(-180.0, 180.0);
     m_angle.value(0.0);
     m_scale.range(0.1, 5.0);
     m_scale.value(1.0);
 }
Beispiel #20
0
    virtual void on_draw()
    {
        typedef agg::gamma_lut<agg::int8u, agg::int8u, 8, 8> gamma_lut_type;
        typedef agg::pixfmt_bgr24_gamma<gamma_lut_type> pixfmt;
        typedef agg::renderer_base<pixfmt> renderer_base;
        typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;

        gamma_lut_type gamma(m_gamma.value());
        pixfmt pixf(rbuf_window(), gamma);
        renderer_base rb(pixf);
        renderer_solid ren(rb);

        rb.clear(m_white_on_black.status() ? agg::rgba(0,0,0) : agg::rgba(1,1,1));

        agg::rasterizer_scanline_aa<> ras;
        agg::scanline_p8 sl;

        agg::ellipse e;

        // Render two "control" circles
        ren.color(agg::rgba8(127,127,127));
        e.init(m_x[0], m_y[0], 3, 3, 16);
        ras.add_path(e);
        agg::render_scanlines(ras, sl, ren);
        e.init(m_x[1], m_y[1], 3, 3, 16);
        ras.add_path(e);
        agg::render_scanlines(ras, sl, ren);

        double d = m_offset.value();

        // Creating a rounded rectangle
        agg::rounded_rect r(m_x[0]+d, m_y[0]+d, m_x[1]+d, m_y[1]+d, m_radius.value());
        r.normalize_radius();

        // Drawing as an outline
        agg::conv_stroke<agg::rounded_rect> p(r);
        p.width(1.0);
        ras.add_path(p);
        ren.color(m_white_on_black.status() ? agg::rgba(1,1,1) : agg::rgba(0,0,0));
        agg::render_scanlines(ras, sl, ren);

        ras.gamma(agg::gamma_none());

        // Render the controls
        agg::render_ctrl(ras, sl, rb, m_radius);
        agg::render_ctrl(ras, sl, rb, m_gamma);
        agg::render_ctrl(ras, sl, rb, m_offset);
        agg::render_ctrl(ras, sl, rb, m_white_on_black);
    }
Beispiel #21
0
    virtual void on_draw()
    {
        int width = rbuf_window().width();
        int height = rbuf_window().height();

        typedef agg::renderer_base<pixfmt> renderer_base;
        typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;

        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid r(rb);
        rb.clear(agg::rgba(1,1,1));

        agg::trans_affine mtx;
        mtx *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
        mtx *= agg::trans_affine_scaling(g_scale, g_scale);
        mtx *= agg::trans_affine_rotation(g_angle + agg::pi);
        mtx *= agg::trans_affine_skewing(g_skew_x/1000.0, g_skew_y/1000.0);
        mtx *= agg::trans_affine_translation(width/2, height/2);

        if(m_scanline.status())
        {
            agg::conv_stroke<agg::path_storage> stroke(g_path);
            stroke.width(m_width_slider.value());
            stroke.line_join(agg::round_join);
            agg::conv_transform<agg::conv_stroke<agg::path_storage> > trans(stroke, mtx);
            agg::render_all_paths(g_rasterizer, g_scanline, r, trans, g_colors, g_path_idx, g_npaths);
        }
        else
        {
            typedef agg::renderer_outline_aa<renderer_base> renderer_type;
            typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;

            double w = m_width_slider.value() * mtx.scale();

            agg::line_profile_aa profile(w, agg::gamma_none());
            renderer_type ren(rb, profile);
            rasterizer_type ras(ren);

            agg::conv_transform<agg::path_storage> trans(g_path, mtx);

            ras.render_all_paths(trans, g_colors, g_path_idx, g_npaths);
        }


        agg::render_ctrl(g_rasterizer, g_scanline, rb, m_width_slider);
        agg::render_ctrl(g_rasterizer, g_scanline, rb, m_scanline);
    }
Beispiel #22
0
    virtual void on_draw()
    {
        typedef agg::pixfmt_bgra32 pixfmt;
        typedef agg::renderer_base<pixfmt> renderer_base;
        typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;

        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid ren(rb);

        rb.clear(agg::rgba(1,1,1));

        agg::rasterizer_scanline_aa<> ras;
        agg::scanline_p8 sl;
        agg::trans_affine mtx;

        ras.gamma(agg::gamma_power(m_gamma.value()));
        mtx *= agg::trans_affine_translation((m_min_x + m_max_x) * -0.5, (m_min_y + m_max_y) * -0.5);
        mtx *= agg::trans_affine_scaling(m_scale.value());
        mtx *= agg::trans_affine_rotation(agg::deg2rad(m_rotate.value()));
        mtx *= agg::trans_affine_translation((m_min_x + m_max_x) * 0.5 + m_x, (m_min_y + m_max_y) * 0.5 + m_y + 30);
        
        m_path.expand(m_expand.value());
        m_path.render(ras, sl, ren, mtx, rb.clip_box(), 1.0);

        ras.gamma(agg::gamma_none());
        agg::render_ctrl(ras, sl, ren, m_expand);
        agg::render_ctrl(ras, sl, ren, m_gamma);
        agg::render_ctrl(ras, sl, ren, m_scale);
        agg::render_ctrl(ras, sl, ren, m_rotate);


        //agg::gamma_lut<> gl(m_gamma.value());
        //unsigned x, y;
        //unsigned w = unsigned(width());
        //unsigned h = unsigned(height());
        //for(y = 0; y < h; y++)
        //{
        //    for(x = 0; x < w; x++)
        //    {
        //        agg::rgba8 c = rb.pixel(x, y);
        //        c.r = gl.inv(c.r);
        //        c.g = gl.inv(c.g);
        //        c.b = gl.inv(c.b);
        //        rb.copy_pixel(x, y, c);
        //    }
        //}
    }
void CCustomRendererView::OnDraw(CDC* pDC)
{
	CCustomRendererDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

    RECT clrect;
    GetClientRect(&clrect);
    int width = clrect.right - clrect.left;
    int height = clrect.bottom - clrect.top;

    hdc_renderer r(*pDC, agg::rgba8());

    agg::trans_affine mtx;
    mtx *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
    mtx *= agg::trans_affine_scaling(g_scale, g_scale);
    mtx *= agg::trans_affine_rotation(g_angle);
    mtx *= agg::trans_affine_translation(width/2, height/2);

    agg::path_storage p2(g_path);
    agg::conv_transform<agg::path_storage> trans(p2, mtx);

    r.saturation(unsigned(g_sat_slider.value() * 255.0));
    agg::render_all_paths(g_rasterizer, g_scanline, r, trans, g_colors, g_path_idx, g_npaths);
    agg::render_ctrl(g_rasterizer, g_scanline, r, g_sat_slider);
}
Beispiel #24
0
  the_application(agg::pix_format_e format, bool flip_y)
      : agg::platform_support(format, flip_y),
        m_gamma(5.0, 5.0, 340.0, 12.0, !flip_y),
        m_mouse_x(200),
        m_mouse_y(200) {
    m_gamma.range(0.5, 2.5);
    m_gamma.value(1.0);
    m_gamma.label("Gamma = %.3f");
    add_ctrl(m_gamma);
    m_gamma.no_transform();

    m_gamma_lut.gamma(m_gamma.value());
    m_old_gamma = m_gamma.value();

    build_gradient_lut();
  }
Beispiel #25
0
    //------------------------------------------------------------------------
    void draw_dashes_draft()
    {
        pixfmt pixf(rbuf_window());
        base_renderer rb(pixf);
        primitives_renderer prim(rb);
        outline_rasterizer ras(prim);

        int i;
        for(i = 0; i < m_graph.get_num_edges(); i++)
        {
            graph::edge e  = m_graph.get_edge(i);
            graph::node n1 = m_graph.get_node(e.node1, width(), height());
            graph::node n2 = m_graph.get_node(e.node2, width(), height());
            curve c(n1.x, n1.y, n2.x, n2.y);
            dash_stroke_draft<curve> s(c, 6.0, 3.0, m_width.value());

            int r = rand() & 0x7F;
            int g = rand() & 0x7F;
            int b = rand() & 0x7F;
            int a = 255;
            if(m_translucent.status()) a = 80;
            prim.line_color(agg::srgba8(r, g, b, a));
            ras.add_path(s);
        }
    }
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_feng(),
        m_fman(m_feng),
        m_poly1(6, 5.0),
        m_poly2(6, 5.0),
        m_num_points      (5.0, 5.0, 340.0, 12.0, !flip_y),
        m_fixed_len       (350, 5.0,  "Fixed Length", !flip_y),
        m_preserve_x_scale(465, 5.0,  "Preserve X scale", !flip_y),
        m_animate         (350, 25.0, "Animate", !flip_y),
        m_prev_animate(false)
    {
        add_ctrl(m_fixed_len);
        add_ctrl(m_preserve_x_scale);
        add_ctrl(m_animate);
        m_fixed_len.status(true);
        m_preserve_x_scale.status(true);
        m_num_points.range(10.0, 400.0);
        m_num_points.value(200.0);
        m_num_points.label("Number of intermediate Points = %.3f");
        add_ctrl(m_num_points);

        m_poly1.close(false);
        m_poly2.close(false);
    }
Beispiel #27
0
    //------------------------------------------------------------------------
    void draw_nodes_fine(scanline_rasterizer& ras)
    {
        gradient_span_alloc sa;
        pixfmt pixf(rbuf_window());
        base_renderer rb(pixf);
        int i;
        for(i = 0; i < m_graph.get_num_nodes(); i++)
        {
            graph::node n = m_graph.get_node(i, width(), height());
            agg::ellipse ell(n.x, n.y, 5.0 * m_width.value(), 5.0 * m_width.value());

            double x, y;
            switch(m_draw)
            {
                case 0:
                    ell.rewind(0);
                    while(!agg::is_stop(ell.vertex(&x, &y)));
                    break;

                case 1:
                    ras.reset();
                    ras.add_path(ell);
                    break;

                case 2:
                    ras.reset();
                    ras.add_path(ell);
                    ras.sort();
                    break;

                case 3:
                {
                    gradient_function gf;
                    agg::trans_affine mtx;
                    mtx *= agg::trans_affine_scaling(m_width.value() / 2.0);
                    mtx *= agg::trans_affine_translation(n.x, n.y);
                    mtx.invert();
                    interpolator inter(mtx);
                    gradient_span_gen sg(inter, gf, m_gradient_colors, 0.0, 10.0);
                    gradient_renderer ren(rb, sa, sg);
                    ras.add_path(ell);
                    agg::render_scanlines(ras, m_sl, ren);
                }
                break;
            }
        }
    }
Beispiel #28
0
  the_application(agg::pix_format_e format, bool flip_y)
      : agg::platform_support(format, flip_y),
        m_idx(-1),
        m_join(10.0, 10.0, 133.0, 80.0, !flip_y),
        m_cap(10.0, 80.0 + 10.0, 133.0, 80.0 + 80.0, !flip_y),
        m_width(130 + 10.0, 10.0 + 4.0, 500.0 - 10.0, 10.0 + 8.0 + 4.0,
                !flip_y),
        m_miter_limit(130 + 10.0, 20.0 + 10.0 + 4.0, 500.0 - 10.0,
                      20.0 + 10.0 + 8.0 + 4.0, !flip_y) {
    m_x[0] = 57 + 100;
    m_y[0] = 60;
    m_x[1] = 369 + 100;
    m_y[1] = 170;
    m_x[2] = 143 + 100;
    m_y[2] = 310;

    add_ctrl(m_join);
    m_join.text_size(7.5);
    m_join.text_thickness(1.0);
    m_join.add_item("Miter Join");
    m_join.add_item("Miter Join Revert");
    m_join.add_item("Round Join");
    m_join.add_item("Bevel Join");
    m_join.cur_item(2);

    add_ctrl(m_cap);
    m_cap.add_item("Butt Cap");
    m_cap.add_item("Square Cap");
    m_cap.add_item("Round Cap");
    m_cap.cur_item(2);

    add_ctrl(m_width);
    m_width.range(3.0, 40.0);
    m_width.value(20.0);
    m_width.label("Width=%1.2f");

    add_ctrl(m_miter_limit);
    m_miter_limit.range(1.0, 10.0);
    m_miter_limit.value(4.0);
    m_miter_limit.label("Miter Limit=%1.2f");

    m_join.no_transform();
    m_cap.no_transform();
    m_width.no_transform();
    m_miter_limit.no_transform();
  }
Beispiel #29
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_alpha_dst(5, 5,    400, 11,    !flip_y),
        m_alpha_src(5, 5+15, 400, 11+15, !flip_y),
        m_comp_op(420, 5.0, 420+170.0, 395.0, !flip_y)
    {
        m_alpha_dst.label("Dst Alpha=%.2f");
        m_alpha_dst.value(1.0);
        add_ctrl(m_alpha_dst);

        m_alpha_src.label("Src Alpha=%.2f");
        m_alpha_src.value(1.0);
        add_ctrl(m_alpha_src);

        m_comp_op.text_size(6.8);
        m_comp_op.add_item("clear");
        m_comp_op.add_item("src");
        m_comp_op.add_item("dst");
        m_comp_op.add_item("src-over");
        m_comp_op.add_item("dst-over");
        m_comp_op.add_item("src-in");
        m_comp_op.add_item("dst-in");
        m_comp_op.add_item("src-out");
        m_comp_op.add_item("dst-out");
        m_comp_op.add_item("src-atop");
        m_comp_op.add_item("dst-atop");
        m_comp_op.add_item("xor");
        m_comp_op.add_item("plus");
        m_comp_op.add_item("minus");
        m_comp_op.add_item("multiply");
        m_comp_op.add_item("screen");
        m_comp_op.add_item("overlay");
        m_comp_op.add_item("darken");
        m_comp_op.add_item("lighten");
        m_comp_op.add_item("color-dodge");
        m_comp_op.add_item("color-burn");
        m_comp_op.add_item("hard-light");
        m_comp_op.add_item("soft-light");
        m_comp_op.add_item("difference");
        m_comp_op.add_item("exclusion");
        m_comp_op.add_item("contrast");
        m_comp_op.add_item("invert");
        m_comp_op.add_item("invert-rgb");
        m_comp_op.cur_item(3);
        add_ctrl(m_comp_op);
    }
Beispiel #30
0
    the_application(agg::pix_format_e format, bool flip_y) :
        agg::platform_support(format, flip_y),
        m_angle     (5,      5,    150,     12,    !flip_y),
        m_scale     (5,      5+15, 150,     12+15, !flip_y),
        m_period    (5+170,  5,    150+170, 12,    !flip_y),
        m_amplitude (5+170,  5+15, 150+170, 12+15, !flip_y),
        m_distortion(480,    5,    600,     90,    !flip_y),

        m_center_x(0.0),
        m_center_y(0.0),
        m_phase(0.0)
    {
        add_ctrl(m_angle);
        add_ctrl(m_scale);
        add_ctrl(m_amplitude);
        add_ctrl(m_period);
        add_ctrl(m_distortion);
        m_angle.label("Angle=%3.2f");
        m_scale.label("Scale=%3.2f");
        m_angle.range(-180.0, 180.0);
        m_angle.value(20.0);
        m_scale.range(0.1, 5.0);
        m_scale.value(1.0);

        m_amplitude.label("Amplitude=%3.2f");
        m_period.label("Period=%3.2f");
        m_amplitude.range(0.1, 40.0);
        m_period.range(0.1, 2.0);
        m_amplitude.value(10.0);
        m_period.value(1.0);

        m_distortion.add_item("Wave");
        m_distortion.add_item("Swirl");
        m_distortion.add_item("Wave-Swirl");
        m_distortion.add_item("Swirl-Wave");
        m_distortion.cur_item(0);

        unsigned i;
        const agg::int8u* p = g_gradient_colors;
        for(i = 0; i < 256; i++)
        {
            m_gradient_colors[i] = agg::rgba8(p[0], p[1], p[2], p[3]);
            p += 4;
        }
    }