Logo Search packages:      
Sourcecode: inkscape version File versions

gdouble stroke_average_width ( GSList const *  objects  ) 

Determine average stroke width, simple method

Definition at line 384 of file desktop-style.cpp.

References NR::Matrix::expansion(), SPIPaint::isNone(), SPStyle::stroke, and SPObject::style.

{
    if (g_slist_length ((GSList *) objects) == 0)
        return NR_HUGE;

    gdouble avgwidth = 0.0;
    bool notstroked = true;
    int n_notstroked = 0;

    for (GSList const *l = objects; l != NULL; l = l->next) {
        if (!SP_IS_ITEM (l->data))
            continue;

        NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));

        SPObject *object = SP_OBJECT(l->data);

        if ( object->style->stroke.isNone() ) {
            ++n_notstroked;   // do not count nonstroked objects
            continue;
        } else {
            notstroked = false;
        }

        avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.expansion();
    }

    if (notstroked)
        return NR_HUGE;

    return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);
}


Generated by  Doxygen 1.6.0   Back to index