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

static gint sp_style_write_ipaint ( gchar *  b,
gint const   len,
gchar const *const   key,
SPIPaint const *const   paint,
SPIPaint const *const   base,
guint const   flags 
) [static]

Write SPIPaint object into string.

Definition at line 3580 of file style.cpp.

References SPIPaint::color, SVGICCColor::colorProfile, SVGICCColor::colors, SPIPaint::colorSet, SPIPaint::currentcolor, SPIPaint::href, SPColor::icc, SPIPaint::inherit, SPIPaint::noneSet, SPIPaint::set, sp_svg_write_color(), Inkscape::CSSOStringStream::str(), SPColor::toRGBA32(), and SPIPaint::value.

Referenced by sp_style_write_difference(), and sp_style_write_string().

{
    int retval = 0;

    if ((flags & SP_STYLE_FLAG_ALWAYS)
        || ((flags & SP_STYLE_FLAG_IFSET) && paint->set)
        || ((flags & SP_STYLE_FLAG_IFDIFF) && paint->set
            && (!base->set || sp_paint_differ(paint, base))))
    {
        CSSOStringStream css;

        if (paint->inherit) {
            css << "inherit";
        } else {
            if ( paint->value.href && paint->value.href->getURI() ) {
                const gchar* uri = paint->value.href->getURI()->toString();
                css << "url(" << uri << ")";
            }

            if ( paint->noneSet ) {
                if ( !css.str().empty() ) {
                    css << " ";
                }
                css << "none";
            }

            if ( paint->currentcolor ) {
                if ( !css.str().empty() ) {
                    css << " ";
                }
                css << "currentColor";
            }

            if ( paint->colorSet ) {
                if ( !css.str().empty() ) {
                    css << " ";
                }
                char color_buf[8];
                sp_svg_write_color(color_buf, sizeof(color_buf), paint->value.color.toRGBA32( 0 ));
                css << color_buf;
            }

            if (paint->value.color.icc) {
                if ( !css.str().empty() ) {
                    css << " ";
                }
                css << "icc-color(" << paint->value.color.icc->colorProfile;
                for (vector<double>::const_iterator i(paint->value.color.icc->colors.begin()),
                         iEnd(paint->value.color.icc->colors.end());
                     i != iEnd; ++i) {
                    css << ", " << *i;
                }
                css << ')';
            }
        }

        if ( !css.str().empty() ) {
            retval = g_snprintf( b, len, "%s:%s;", key, css.str().c_str() );
        }
    }

    return retval;
}


Generated by  Doxygen 1.6.0   Back to index