1 #ifndef SEEN_SP_GRADIENT_CHEMISTRY_H
2 #define SEEN_SP_GRADIENT_CHEMISTRY_H
4 /*
5 * Various utility methods for gradients
6 *
7 * Author:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * bulia byak <buliabyak@users.sf.net>
10 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
11 * Jon A. Cruz <jon@joncruz.org>
12 *
13 * Copyright (C) 2010 Authors
14 * Copyright (C) 2007 Johan Engelen
15 * Copyright (C) 2001-2002 Lauris Kaplinski
16 * Copyright (C) 2001 Ximian, Inc.
17 *
18 * Released under GNU GPL, read the file 'COPYING' for more information
19 */
21 #include "forward.h"
22 #include "sp-gradient.h"
24 /*
25 * Either normalizes given gradient to vector, or returns fresh normalized
26 * vector - in latter case, original gradient is flattened and stops cleared
27 * No transrefing - i.e. caller shouldn't hold reference to original and
28 * does not get one to new automatically (doc holds ref of every object anyways)
29 */
31 SPGradient *sp_gradient_ensure_vector_normalized (SPGradient *gradient);
34 /*
35 * Sets item fill/stroke to lineargradient with given vector, creating
36 * new private gradient, if needed
37 * gr has to be normalized vector
38 */
40 SPGradient *sp_item_set_gradient (SPItem *item, SPGradient *gr, SPGradientType type, bool is_fill);
42 /*
43 * Get default normalized gradient vector of document, create if there is none
44 */
45 SPGradient *sp_document_default_gradient_vector( SPDocument *document, SPColor const &color, bool singleStop );
46 SPGradient *sp_gradient_vector_for_object( SPDocument *doc, SPDesktop *desktop, SPObject *o, bool is_fill, bool singleStop = false );
48 void sp_object_ensure_fill_gradient_normalized (SPObject *object);
49 void sp_object_ensure_stroke_gradient_normalized (SPObject *object);
51 SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, const gchar *property);
52 SPGradient *sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item);
54 SPGradient *sp_gradient_fork_vector_if_necessary (SPGradient *gr);
55 SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector);
58 SPStop* sp_last_stop(SPGradient *gradient);
59 SPStop* sp_get_stop_i(SPGradient *gradient, guint i);
60 guint sp_number_of_stops(SPGradient const *gradient);
61 guint sp_number_of_stops_before_stop(SPGradient const *gradient, SPStop *target);
63 guint32 average_color (guint32 c1, guint32 c2, gdouble p = 0.5);
65 SPStop *sp_vector_add_stop (SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset);
67 void sp_gradient_transform_multiply (SPGradient *gradient, Geom::Matrix postmul, bool set);
69 SPGradient * sp_item_gradient (SPItem *item, bool fill_or_stroke);
70 void sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, Geom::Point p_desk, bool fill_or_stroke, bool write_repr, bool scale);
71 Geom::Point sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
72 SPGradient *sp_item_gradient_get_vector (SPItem *item, bool fill_or_stroke);
73 SPGradientSpread sp_item_gradient_get_spread (SPItem *item, bool fill_or_stroke);
75 struct SPCSSAttr;
76 void sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop);
77 guint32 sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
78 void sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
79 void sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke);
81 #endif // SEEN_SP_GRADIENT_CHEMISTRY_H
83 /*
84 Local Variables:
85 mode:c++
86 c-file-style:"stroustrup"
87 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
88 indent-tabs-mode:nil
89 fill-column:99
90 End:
91 */
92 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :