Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_curve_lineto ( SPCurve curve,
gdouble  x,
gdouble  y 
)

Adds a line to the current subpath.

Definition at line 391 of file curve.cpp.

References SPCurve::_bpath, SPCurve::closed, NArtBpath::code, SPCurve::end, SPCurve::hascpt, SPCurve::movePos, SPCurve::moving, NR_END, NR_LINETO, NR_MOVETO_OPEN, SPCurve::posSet, NArtBpath::setC(), sp_curve_ensure_space(), NArtBpath::x3, and NArtBpath::y3.

{
    g_return_if_fail(curve != NULL);
    g_return_if_fail(curve->hascpt);

    if (curve->moving) {
        /* fix endpoint */
        g_return_if_fail(!curve->posSet);
        g_return_if_fail(curve->end > 1);
        NArtBpath *bp = curve->_bpath + curve->end - 1;
        g_return_if_fail(bp->code == NR_LINETO);
        bp->x3 = x;
        bp->y3 = y;
        curve->moving = false;
        return;
    }

    if (curve->posSet) {
        /* start a new segment */
        sp_curve_ensure_space(curve, 2);
        NArtBpath *bp = curve->_bpath + curve->end;
        bp->code = NR_MOVETO_OPEN;
        bp->setC(3, curve->movePos);
        bp++;
        bp->code = NR_LINETO;
        bp->x3 = x;
        bp->y3 = y;
        bp++;
        bp->code = NR_END;
        curve->end += 2;
        curve->posSet = false;
        curve->closed = false;
        return;
    }

    /* add line */

    g_return_if_fail(curve->end > 1);
    sp_curve_ensure_space(curve, 1);
    NArtBpath *bp = curve->_bpath + curve->end;
    bp->code = NR_LINETO;
    bp->x3 = x;
    bp->y3 = y;
    bp++;
    bp->code = NR_END;
    curve->end++;
}


Generated by  Doxygen 1.6.0   Back to index