Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static SPPainter * sp_radialgradient_painter_new ( SPPaintServer *  ps,
NR::Matrix const &  full_transform,
NR::Matrix const &  ,
NRRect const *  bbox 
) [static]

Create radial gradient context.

Todo:
fixme: We may try to normalize here too, look at linearGradient (Lauris)

Todo:
Problem: What to do, if we have mixed lengths and percentages? Currently we do ignore percentages at all, but that is not good (lauris)

Definition at line 1759 of file sp-gradient.cpp.

References SPGradient::color, NR::Matrix::copyto(), SPRadialGradient::cx, SPRadialGradient::cy, SPRadialGradient::fx, SPRadialGradient::fy, SPGradient::gradientTransform, SPRGPainter::painter, SPRadialGradient::r, SPRGPainter::rg, SPRGPainter::rgr, sp_gradient_ensure_colors(), sp_gradient_get_spread(), sp_rg_fill(), and SPGradient::units.

Referenced by sp_radialgradient_class_init().

{
    SPRadialGradient *rg = SP_RADIALGRADIENT(ps);
    SPGradient *gr = SP_GRADIENT(ps);

    if (!gr->color) sp_gradient_ensure_colors(gr);

    SPRGPainter *rgp = g_new(SPRGPainter, 1);

    rgp->painter.type = SP_PAINTER_IND;
    rgp->painter.fill = sp_rg_fill;

    rgp->rg = rg;

    NR::Matrix gs2px;

    if (gr->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
        /** \todo
         * fixme: We may try to normalize here too, look at
         * linearGradient (Lauris)
         */

        /* BBox to user coordinate system */
        NR::Matrix bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0);

        NR::Matrix gs2user = gr->gradientTransform * bbox2user;

        gs2px = gs2user * full_transform;
    } else {
        /** \todo
         * Problem: What to do, if we have mixed lengths and percentages?
         * Currently we do ignore percentages at all, but that is not
         * good (lauris)
         */

        gs2px = gr->gradientTransform * full_transform;
    }

    NRMatrix gs2px_nr;
    gs2px.copyto(&gs2px_nr);

    nr_rgradient_renderer_setup(&rgp->rgr, gr->color, sp_gradient_get_spread(gr),
                                &gs2px_nr,
                                rg->cx.computed, rg->cy.computed,
                                rg->fx.computed, rg->fy.computed,
                                rg->r.computed);

    return (SPPainter *) rgp;
}


Generated by  Doxygen 1.6.0   Back to index