Logo Search packages:      
Sourcecode: inkscape version File versions

SPCurve* sp_curve_new_from_foreign_bpath ( NArtBpath const   bpath[]  ) 

Convert const NArtBpath array to SPCurve.

Returns:
new SPCurve, or NULL if the curve was not created for some reason.

Definition at line 93 of file curve.cpp.

References SPCurve::_bpath, SPCurve::closed, NArtBpath::code, SPCurve::end, SPCurve::hascpt, SPCurve::length, SPCurve::moving, NR_MOVETO, NR_MOVETO_OPEN, SPCurve::posSet, SPCurve::refcount, sp_bpath_clean(), sp_bpath_closed(), sp_bpath_good(), sp_bpath_length(), and SPCurve::substart.

Referenced by sp_curve_copy(), and sp_curve_new_from_bpath().

{
    g_return_val_if_fail(bpath != NULL, NULL);

    NArtBpath *new_bpath;
    if (!sp_bpath_good(bpath)) {
        new_bpath = sp_bpath_clean(bpath);
        g_return_val_if_fail(new_bpath != NULL, NULL);
    } else {
        unsigned const len = sp_bpath_length(bpath);
        new_bpath = g_new(NArtBpath, len);
        memcpy(new_bpath, bpath, len * sizeof(NArtBpath));
    }

    SPCurve *curve = g_new(SPCurve, 1);

    curve->refcount = 1;
    curve->_bpath = new_bpath;
    curve->length = sp_bpath_length(new_bpath);
    curve->end = curve->length - 1;
    gint i = curve->end;
    for (; i > 0; i--)
        if ((curve->_bpath[i].code == NR_MOVETO) ||
            (curve->_bpath[i].code == NR_MOVETO_OPEN))
            break;
    curve->substart = i;
    curve->hascpt = false;
    curve->posSet = false;
    curve->moving = false;
    curve->closed = sp_bpath_closed(new_bpath);

    return curve;
}


Generated by  Doxygen 1.6.0   Back to index