X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fgradient-chemistry.cpp;h=70bc835bc6420f993b45fdf93b28626361f24495;hb=dc9e07d7ab84affb6b7d7d47f5a9d3247dc58089;hp=df013fdfc95516ee08924d1ae08cc194bffc89d0;hpb=18a425ebfcb0066d75a6811c512598bb5496eeef;p=inkscape.git diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index df013fdfc..70bc835bc 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -30,10 +30,12 @@ #include "sp-text.h" #include "sp-tspan.h" #include +#include #include "xml/repr.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" +#include "prefs-utils.h" // Terminology: @@ -234,6 +236,10 @@ sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector, SPGradient * sp_gradient_fork_vector_if_necessary (SPGradient *gr) { + // Some people actually prefer their gradient vectors to be shared... + if (prefs_get_int_attribute("options.forkgradientvectors", "value", 1) == 0) + return gr; + if (SP_OBJECT_HREFCOUNT(gr) > 1) { SPDocument *doc = SP_OBJECT_DOCUMENT(gr); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); @@ -558,8 +564,8 @@ sp_get_stop_i(SPGradient *gradient, guint stop_i) return stop; } -static guint32 -average_color (guint32 c1, guint32 c2, gdouble p = 0.5) +guint32 +average_color (guint32 c1, guint32 c2, gdouble p) { guint32 r = (guint32) (SP_RGBA32_R_U (c1) * (1 - p) + SP_RGBA32_R_U (c2) * p); guint32 g = (guint32) (SP_RGBA32_G_U (c1) * (1 - p) + SP_RGBA32_G_U (c2) * p); @@ -798,21 +804,6 @@ sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke) } -// FIXME: make general global function -static double -get_offset_between_points (NR::Point p, NR::Point begin, NR::Point end) -{ - double length = NR::L2(end - begin); - NR::Point be = (end - begin) / length; - double r = NR::dot(p - begin, be); - - if (r < 0.0) return 0.0; - if (r > length) return 1.0; - - return (r / length); -} - - /** Set the position of point point_type of the gradient applied to item (either fill_or_stroke) to p_w (in desktop coordinates). Write_repr if you want the change to become permanent.