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

void sp_gradient_repr_write_vector ( SPGradient gr  ) 

Writes the gradient's internal vector (whether from its own stops, or inherited from refs) into the gradient repr as svg:stop elements.

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

References Inkscape::XML::Node::addChild(), Inkscape::XML::Node::setAttribute(), sp_gradient_repr_clear_vector(), sp_repr_set_css_double(), sp_svg_write_color(), SPGradientVector::stops, Inkscape::CSSOStringStream::str(), and SPGradient::vector.

    g_return_if_fail(gr != NULL);

    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(gr));
    Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr);

    /* We have to be careful, as vector may be our own, so construct repr list at first */
    GSList *cl = NULL;

    for (guint i = 0; i < gr->vector.stops.size(); i++) {
        Inkscape::CSSOStringStream os;
        Inkscape::XML::Node *child = xml_doc->createElement("svg:stop");
        sp_repr_set_css_double(child, "offset", gr->vector.stops[i].offset);
        /* strictly speaking, offset an SVG <number> rather than a CSS one, but exponents make no
         * sense for offset proportions. */
        gchar c[64];
        sp_svg_write_color(c, sizeof(c), gr->vector.stops[i].color.toRGBA32( 0x00 ));
        os << "stop-color:" << c << ";stop-opacity:" << gr->vector.stops[i].opacity;
        child->setAttribute("style", os.str().c_str());
        /* Order will be reversed here */
        cl = g_slist_prepend(cl, child);


    /* And insert new children from list */
    while (cl) {
        Inkscape::XML::Node *child = static_cast<Inkscape::XML::Node *>(cl->data);
        repr->addChild(child, NULL);
        cl = g_slist_remove(cl, child);

Generated by  Doxygen 1.6.0   Back to index