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

static Inkscape::XML::Node * sp_stop_write ( SPObject object,
Inkscape::XML::Node repr,
guint  flags 
) [static]

Virtual write: write object attributes to repr.

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

References SPStop::currentColor, SPStop::offset, SPStop::opacity, Inkscape::XML::Node::setAttribute(), sp_repr_set_css_double(), sp_svg_write_color(), SPStop::specified_color, Inkscape::CSSOStringStream::str(), and SPColor::toRGBA32().

Referenced by sp_stop_class_init().

    SPStop *stop = SP_STOP(object);

    if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
        repr = xml_doc->createElement("svg:stop");

    guint32 specifiedcolor = stop->specified_color.toRGBA32( 255 );
    gfloat opacity = stop->opacity;

    if (((SPObjectClass *) stop_parent_class)->write)
        (* ((SPObjectClass *) stop_parent_class)->write)(object, repr, flags);

    // Since we do a hackish style setting here (because SPStyle does not support stop-color and
    // stop-opacity), we must do it AFTER calling the parent write method; otherwise
    // sp_object_write would clear our style= attribute (bug 1695287)

    Inkscape::CSSOStringStream os;
    os << "stop-color:";
    if (stop->currentColor) {
        os << "currentColor";
    } else {
        gchar c[64];
        sp_svg_write_color(c, sizeof(c), specifiedcolor);
        os << c;
    os << ";stop-opacity:" << opacity;
    repr->setAttribute("style", os.str().c_str());
    repr->setAttribute("stop-color", NULL);
    repr->setAttribute("stop-opacity", NULL);
    sp_repr_set_css_double(repr, "offset", stop->offset);
    /* strictly speaking, offset an SVG <number> rather than a CSS one, but exponents make no sense
     * for offset proportions. */

    return repr;

Generated by  Doxygen 1.6.0   Back to index