Release Clutter 1.11.4 (snapshot)
[profile/ivi/clutter.git] / clutter / clutter-color.h
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By: Matthew Allum  <mallum@openedhand.com>
7  *              Emmanuele Bassi <ebassi@linux.intel.com>
8  *
9  * Copyright (C) 2006, 2007, 2008 OpenedHand
10  * Copyright (C) 2009 Intel Corp.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24  */
25
26 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
27 #error "Only <clutter/clutter.h> can be included directly."
28 #endif
29
30 #ifndef __CLUTTER_COLOR_H__
31 #define __CLUTTER_COLOR_H__
32
33 #include <clutter/clutter-types.h>
34
35 G_BEGIN_DECLS
36
37 #define CLUTTER_TYPE_COLOR      (clutter_color_get_type ())
38
39 /**
40  * ClutterColor:
41  * @red: red component, between 0 and 255
42  * @green: green component, between 0 and 255
43  * @blue: blue component, between 0 and 255
44  * @alpha: alpha component, between 0 and 255
45  *
46  * Color representation.
47  */
48 struct _ClutterColor
49 {
50   /*< public >*/
51   guint8 red;
52   guint8 green;
53   guint8 blue;
54   
55   guint8 alpha;
56 };
57
58 /**
59  * CLUTTER_COLOR_INIT:
60  * @r: value for the red channel, between 0 and 255
61  * @g: value for the green channel, between 0 and 255
62  * @b: value for the blue channel, between 0 and 255
63  * @a: value for the alpha channel, between 0 and 255
64  *
65  * A macro that initializes a #ClutterColor, to be used when declaring it.
66  *
67  * Since: 1.12
68  */
69 #define CLUTTER_COLOR_INIT(r,g,b,a)     { (r), (g), (b), (a) }
70
71 GType         clutter_color_get_type   (void) G_GNUC_CONST;
72
73 ClutterColor *clutter_color_new         (guint8              red,
74                                          guint8              green,
75                                          guint8              blue,
76                                          guint8              alpha);
77 ClutterColor *clutter_color_alloc       (void);
78 ClutterColor *clutter_color_init        (ClutterColor       *color,
79                                          guint8              red,
80                                          guint8              green,
81                                          guint8              blue,
82                                          guint8              alpha);
83 ClutterColor *clutter_color_copy        (const ClutterColor *color);
84 void          clutter_color_free        (ClutterColor       *color);
85
86 void          clutter_color_add         (const ClutterColor *a,
87                                          const ClutterColor *b,
88                                          ClutterColor       *result);
89 void          clutter_color_subtract    (const ClutterColor *a,
90                                          const ClutterColor *b,
91                                          ClutterColor       *result);
92 void          clutter_color_lighten     (const ClutterColor *color,
93                                          ClutterColor       *result);
94 void          clutter_color_darken      (const ClutterColor *color,
95                                          ClutterColor       *result);
96 void          clutter_color_shade       (const ClutterColor *color,
97                                          gdouble             factor,
98                                          ClutterColor       *result);
99
100 gchar *       clutter_color_to_string   (const ClutterColor *color);
101 gboolean      clutter_color_from_string (ClutterColor       *color,
102                                          const gchar        *str);
103
104 void          clutter_color_to_hls      (const ClutterColor *color,
105                                          gfloat             *hue,
106                                          gfloat             *luminance,
107                                          gfloat             *saturation);
108 void          clutter_color_from_hls    (ClutterColor       *color,
109                                          gfloat              hue,
110                                          gfloat              luminance,
111                                          gfloat              saturation);
112
113 guint32       clutter_color_to_pixel    (const ClutterColor *color);
114 void          clutter_color_from_pixel  (ClutterColor       *color,
115                                          guint32             pixel);
116
117 guint         clutter_color_hash        (gconstpointer       v);
118 gboolean      clutter_color_equal       (gconstpointer       v1,
119                                          gconstpointer       v2);
120
121 void          clutter_color_interpolate (const ClutterColor *initial,
122                                          const ClutterColor *final,
123                                          gdouble             progress,
124                                          ClutterColor       *result);
125
126 #define CLUTTER_TYPE_PARAM_COLOR           (clutter_param_color_get_type ())
127 #define CLUTTER_PARAM_SPEC_COLOR(pspec)    (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_COLOR, ClutterParamSpecColor))
128 #define CLUTTER_IS_PARAM_SPEC_COLOR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), CLUTTER_TYPE_PARAM_COLOR))
129
130 /**
131  * CLUTTER_VALUE_HOLDS_COLOR:
132  * @x: a #GValue
133  *
134  * Evaluates to %TRUE if @x holds a #ClutterColor<!-- -->.
135  *
136  * Since: 1.0
137  */
138 #define CLUTTER_VALUE_HOLDS_COLOR(x)       (G_VALUE_HOLDS ((x), CLUTTER_TYPE_COLOR))
139
140 typedef struct _ClutterParamSpecColor  ClutterParamSpecColor;
141
142 /**
143  * ClutterParamSpecColor: (skip)
144  * @default_value: default color value
145  *
146  * A #GParamSpec subclass for defining properties holding
147  * a #ClutterColor.
148  *
149  * Since: 1.0
150  */
151 struct _ClutterParamSpecColor
152 {
153   /*< private >*/
154   GParamSpec    parent_instance;
155
156   /*< public >*/
157   ClutterColor *default_value;
158 };
159
160 void                    clutter_value_set_color         (GValue             *value,
161                                                          const ClutterColor *color);
162 const ClutterColor *    clutter_value_get_color         (const GValue       *value);
163
164 GType       clutter_param_color_get_type (void) G_GNUC_CONST;
165 GParamSpec *clutter_param_spec_color     (const gchar        *name,
166                                           const gchar        *nick,
167                                           const gchar        *blurb,
168                                           const ClutterColor *default_value,
169                                           GParamFlags         flags);
170
171 const ClutterColor *clutter_color_get_static (ClutterStaticColor color);
172
173 G_END_DECLS
174
175 #endif /* __CLUTTER_COLOR_H__ */