Logo Search packages:      
Sourcecode: inkscape version File versions

SPCurve* sp_curve_reverse ( SPCurve const *  curve  ) 

Returns curve but drawn in the opposite direction. Should result in the same shape, but with all its markers drawn facing the other direction.

Definition at line 702 of file curve.cpp.

References SPCurve::bpath, SPCurve::end, SPCurve::length, sp_curve_new_sized(), and SPCurve::substart.

{
    /* We need at least moveto, curveto, end. */
    g_return_val_if_fail(curve->end - curve->substart > 1, NULL);

    NArtBpath const *be = curve->bpath + curve->end - 1;

    g_assert(is_moveto(curve->bpath[curve->substart].code));
    g_assert(is_moveto(curve->bpath[0].code));
    g_assert((be+1)->code == NR_END);

    SPCurve  *new_curve = sp_curve_new_sized(curve->length);
    sp_curve_moveto(new_curve, be->c(3));

    for (NArtBpath const *bp = be; ; --bp) {
        switch (bp->code) {
            case NR_MOVETO:
                g_assert(new_curve->bpath[new_curve->substart].code == NR_MOVETO_OPEN);
                new_curve->bpath[new_curve->substart].code = NR_MOVETO;
                /* FALL-THROUGH */
            case NR_MOVETO_OPEN:
                if (bp == curve->bpath) {
                    return new_curve;
                }
                sp_curve_moveto(new_curve, (bp-1)->c(3));
                break;

            case NR_LINETO:
                sp_curve_lineto(new_curve, (bp-1)->c(3));
                break;

            case NR_CURVETO:
                sp_curve_curveto(new_curve, bp->c(2), bp->c(1), (bp-1)->c(3));
                break;

            default:
                g_assert_not_reached();
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index