Exemple #1
0
    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);
    }
Exemple #2
0
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;
}
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);
    }
}