コード例 #1
0
ファイル: agg_gen_stroke.cpp プロジェクト: CaptEmulation/svgl
    //------------------------------------------------------------------------
    void gen_stroke::calc_join(const vertex_dist& v0, 
                               const vertex_dist& v1, 
                               const vertex_dist& v2,
                               double len1, double len2)
    {
        double dx1, dy1, dx2, dy2;

        dx1 = m_width * (v1.y - v0.y) / len1;
        dy1 = m_width * (v1.x - v0.x) / len1;

        dx2 = m_width * (v2.y - v1.y) / len2;
        dy2 = m_width * (v2.x - v1.x) / len2;

        m_out_vertices.remove_all();
        if(m_line_join == miter_join)
        {
            calc_miter(v0, v1, v2, dx1, dy1, dx2, dy2);
        }
        else
        {
            if(calc_point_location(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y) > 0.0)
            {
                calc_miter(v0, v1, v2, dx1, dy1, dx2, dy2);
            }
            else
            {
                if(m_line_join == round_join)
                {
                    calc_arc(v1.x, v1.y, dx1, -dy1, dx2, -dy2);
                }
                else
                {
                    m_out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
                    m_out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2));
                }
            }
        }
    }
コード例 #2
0
ファイル: agg_vcgen_contour.cpp プロジェクト: lupnfer/camc
    //------------------------------------------------------------------------
    unsigned vcgen_contour::vertex(double* x, double* y)
    {
        bool done = false;
        while(!done)
        {
            switch(m_status)
            {
            case initial:
                rewind(0);

            case ready:
                if(m_src_vertices.size() <  3)
                {
                    return path_cmd_stop;
                }
                m_src_vertex = 0;
                m_status = outline;

            case outline:
                if(m_src_vertex >= m_src_vertices.size())
                {
                    m_status = end_poly;
                    return path_cmd_end_poly | m_orientation | m_closed;
                }
                if(calc_miter(m_src_vertices.prev(m_src_vertex), 
                              m_src_vertices.curr(m_src_vertex), 
                              m_src_vertices.next(m_src_vertex)))
                {
                    m_status = add_point;
                }
                ++m_src_vertex;
                *x = m_x1;
                *y = m_y1;
                return ((m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to);

            case add_point:
                *x = m_x2;
                *y = m_y2;
                m_status = outline;
                return path_cmd_line_to;

            case end_poly:
                done = true;
                break;
            }
        }
        return path_cmd_stop;
    }