1 #ifndef __SP_GRADIENT_CHEMISTRY_H__
2 #define __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 *
12 * Copyright (C) 2007 Johan Engelen
13 * Copyright (C) 2001-2002 Lauris Kaplinski
14 * Copyright (C) 2001 Ximian, Inc.
15 *
16 * Released under GNU GPL, read the file 'COPYING' for more information
17 */
19 #include "forward.h"
20 #include "sp-gradient.h"
22 /*
23 * Either normalizes given gradient to vector, or returns fresh normalized
24 * vector - in latter case, original gradient is flattened and stops cleared
25 * No transrefing - i.e. caller shouldn't hold reference to original and
26 * does not get one to new automatically (doc holds ref of every object anyways)
27 */
29 SPGradient *sp_gradient_ensure_vector_normalized (SPGradient *gradient);
32 /*
33 * Sets item fill/stroke to lineargradient with given vector, creating
34 * new private gradient, if needed
35 * gr has to be normalized vector
36 */
38 SPGradient *sp_item_set_gradient (SPItem *item, SPGradient *gr, SPGradientType type, bool is_fill);
40 /*
41 * Get default normalized gradient vector of document, create if there is none
42 */
44 SPGradient *sp_document_default_gradient_vector (SPDocument *document, guint32 color = 0);
45 SPGradient *sp_gradient_vector_for_object (SPDocument *doc, SPDesktop *desktop, SPObject *o, bool is_fill);
47 void sp_object_ensure_fill_gradient_normalized (SPObject *object);
48 void sp_object_ensure_stroke_gradient_normalized (SPObject *object);
50 SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, const gchar *property);
51 SPGradient *sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item);
53 SPGradient *sp_gradient_fork_vector_if_necessary (SPGradient *gr);
54 SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector);
57 SPStop* sp_first_stop(SPGradient *gradient);
58 SPStop* sp_last_stop(SPGradient *gradient);
59 SPStop* sp_prev_stop(SPStop *stop, SPGradient *gradient);
60 SPStop* sp_next_stop(SPStop *stop);
61 SPStop* sp_get_stop_i(SPGradient *gradient, guint i);
62 guint sp_number_of_stops(SPGradient *gradient);
63 guint sp_number_of_stops_before_stop(SPGradient *gradient, SPStop *target);
65 guint32 average_color (guint32 c1, guint32 c2, gdouble p = 0.5);
67 SPStop *sp_vector_add_stop (SPGradient *vector, SPStop* prev_stop, SPStop* next_stop, gfloat offset);
69 void sp_gradient_transform_multiply (SPGradient *gradient, NR::Matrix postmul, bool set);
71 SPGradient * sp_item_gradient (SPItem *item, bool fill_or_stroke);
72 void sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::Point p_desk, bool fill_or_stroke, bool write_repr, bool scale);
73 NR::Point sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
74 SPGradient *sp_item_gradient_get_vector (SPItem *item, bool fill_or_stroke);
75 SPGradientSpread sp_item_gradient_get_spread (SPItem *item, bool fill_or_stroke);
77 struct SPCSSAttr;
78 void sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop);
79 guint32 sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
80 void sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
81 void sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke);
83 #endif
85 /*
86 Local Variables:
87 mode:c++
88 c-file-style:"stroustrup"
89 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
90 indent-tabs-mode:nil
91 fill-column:99
92 End:
93 */
94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :