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 */
46 SPGradient *sp_document_default_gradient_vector (SPDocument *document, guint32 color = 0);
47 SPGradient *sp_gradient_vector_for_object (SPDocument *doc, SPDesktop *desktop, SPObject *o, bool is_fill);
49 void sp_object_ensure_fill_gradient_normalized (SPObject *object);
50 void sp_object_ensure_stroke_gradient_normalized (SPObject *object);
52 SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, const gchar *property);
53 SPGradient *sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item);
55 SPGradient *sp_gradient_fork_vector_if_necessary (SPGradient *gr);
56 SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector);
59 SPStop* sp_last_stop(SPGradient *gradient);
60 SPStop* sp_get_stop_i(SPGradient *gradient, guint i);
61 guint sp_number_of_stops(SPGradient const *gradient);
62 guint sp_number_of_stops_before_stop(SPGradient const *gradient, SPStop *target);
64 guint32 average_color (guint32 c1, guint32 c2, gdouble p = 0.5);
66 SPStop *sp_vector_add_stop (SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset);
68 void sp_gradient_transform_multiply (SPGradient *gradient, Geom::Matrix postmul, bool set);
70 SPGradient * sp_item_gradient (SPItem *item, bool fill_or_stroke);
71 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);
72 Geom::Point sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
73 SPGradient *sp_item_gradient_get_vector (SPItem *item, bool fill_or_stroke);
74 SPGradientSpread sp_item_gradient_get_spread (SPItem *item, bool fill_or_stroke);
76 struct SPCSSAttr;
77 void sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop);
78 guint32 sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
79 void sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
80 void sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke);
82 #endif // SEEN_SP_GRADIENT_CHEMISTRY_H
84 /*
85 Local Variables:
86 mode:c++
87 c-file-style:"stroustrup"
88 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
89 indent-tabs-mode:nil
90 fill-column:99
91 End:
92 */
93 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :