Logo Search packages:      
Sourcecode: inkscape version File versions

SPCurve* sp_curve_new_from_static_bpath ( NArtBpath const *  bpath  ) 

Construct an SPCurve from read-only, static storage.

We could treat read-onliness and staticness (i.e. can't call free on bpath) as orthogonal attributes, but at the time of writing we have only one caller.

Definition at line 124 of file curve.cpp.

References SPCurve::bpath, SPCurve::closed, SPCurve::end, SPCurve::hascpt, SPCurve::length, SPCurve::moving, SPCurve::posSet, SPCurve::refcount, SPCurve::sbpath, and SPCurve::substart.

{
    g_return_val_if_fail(bpath != NULL, NULL);

    bool sbpath;
    if (!sp_bpath_good(bpath)) {
        NArtBpath *new_bpath = sp_bpath_clean(bpath);
        g_return_val_if_fail(new_bpath != NULL, NULL);
        sbpath = false;
        bpath = new_bpath;
    } else {
        sbpath = true;
    }

    SPCurve *curve = g_new(SPCurve, 1);

    curve->refcount = 1;
    curve->bpath = const_cast<NArtBpath *>(bpath);
    curve->length = sp_bpath_length(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->sbpath = sbpath;
    curve->hascpt = false;
    curve->posSet = false;
    curve->moving = false;
    curve->closed = sp_bpath_closed(bpath);

    return curve;
}


Generated by  Doxygen 1.6.0   Back to index