Logo Search packages:      
Sourcecode: inkscape version File versions

Path * bpath_to_liv_path ( NArtBpath bpath  ) 

Converts an NArtBpath (like the one stored in a SPCurve) into a livarot Path. Duplicate of splivarot.

Definition at line 447 of file sp-offset.cpp.

References NArtBpath::code, NR_CURVETO, NR_END, NR_LINETO, NR_MOVETO, NR_MOVETO_OPEN, NArtBpath::x1, NArtBpath::x2, NArtBpath::x3, NArtBpath::y1, NArtBpath::y2, and NArtBpath::y3.

Referenced by sp_offset_set(), and sp_offset_top_point().

{
    if (bpath == NULL)
        return NULL;

    Path *dest = new Path;
    dest->SetBackData (false);
    {
        int i;
        bool closed = false;
        float lastX = 0.0;
        float lastY = 0.0;

        for (i = 0; bpath[i].code != NR_END; i++)
        {
            switch (bpath[i].code)
            {
                case NR_LINETO:
                    lastX = bpath[i].x3;
                    lastY = bpath[i].y3;
                    {
                        NR::Point  tmp(lastX,lastY);
                        dest->LineTo (tmp);
                    }
                    break;

                case NR_CURVETO:
                {
                    NR::Point  tmp(bpath[i].x3, bpath[i].y3);
                    NR::Point  tms;
                    tms[0]=3 * (bpath[i].x1 - lastX);
                    tms[1]=3 * (bpath[i].y1 - lastY);
                    NR::Point  tme;
                    tme[0]=3 * (bpath[i].x3 - bpath[i].x2);
                    tme[1]= 3 * (bpath[i].y3 - bpath[i].y2);
                    dest->CubicTo (tmp,tms,tme);
                }
                lastX = bpath[i].x3;
                lastY = bpath[i].y3;
                break;

                case NR_MOVETO_OPEN:
                case NR_MOVETO:
                    if (closed)
                        dest->Close ();
                    closed = (bpath[i].code == NR_MOVETO);
                    lastX = bpath[i].x3;
                    lastY = bpath[i].y3;
                    {
                        NR::Point tmp(lastX,lastY);
                        dest->MoveTo(tmp);
                    }
                    break;
                default:
                    break;
            }
        }
        if (closed)
            dest->Close ();
    }

    return dest;
}


Generated by  Doxygen 1.6.0   Back to index