4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2008,2009 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
26 * @short_description: A generic color definition
28 * #CoglColor is a simple structure holding the definition of a color such
29 * that it can be efficiently used by GL
34 #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
35 #error "Only <cogl/cogl.h> can be included directly."
38 #ifndef __COGL_COLOR_H__
39 #define __COGL_COLOR_H__
41 #include <cogl/cogl-types.h>
48 * Creates a new (empty) color
50 * Return value: a newly-allocated #CoglColor. Use cogl_color_free()
51 * to free the allocated resources
56 cogl_color_new (void);
60 * @color: the color to copy
62 * Creates a copy of @color
64 * Return value: a newly-allocated #CoglColor. Use cogl_color_free()
65 * to free the allocate resources
70 cogl_color_copy (const CoglColor *color);
74 * @color: the color to free
76 * Frees the resources allocated by cogl_color_new() and cogl_color_copy()
81 cogl_color_free (CoglColor *color);
84 * cogl_color_init_from_4ub:
85 * @color: A pointer to a #CoglColor to initialize
86 * @red: value of the red channel, between 0 and 255
87 * @green: value of the green channel, between 0 and 255
88 * @blue: value of the blue channel, between 0 and 255
89 * @alpha: value of the alpha channel, between 0 and 255
91 * Sets the values of the passed channels into a #CoglColor.
96 cogl_color_init_from_4ub (CoglColor *color,
103 * cogl_color_set_from_4ub:
104 * @color: A pointer to a #CoglColor to initialize
105 * @red: value of the red channel, between 0 and 255
106 * @green: value of the green channel, between 0 and 255
107 * @blue: value of the blue channel, between 0 and 255
108 * @alpha: value of the alpha channel, between 0 and 255
110 * Sets the values of the passed channels into a #CoglColor.
113 * Deprecated: 1.4: Use cogl_color_init_from_4ub instead.
116 cogl_color_set_from_4ub (CoglColor *color,
123 * cogl_color_init_from_4f:
124 * @color: A pointer to a #CoglColor to initialize
125 * @red: value of the red channel, between 0 and %1.0
126 * @green: value of the green channel, between 0 and %1.0
127 * @blue: value of the blue channel, between 0 and %1.0
128 * @alpha: value of the alpha channel, between 0 and %1.0
130 * Sets the values of the passed channels into a #CoglColor
135 cogl_color_init_from_4f (CoglColor *color,
142 * cogl_color_set_from_4f:
143 * @color: A pointer to a #CoglColor to initialize
144 * @red: value of the red channel, between 0 and %1.0
145 * @green: value of the green channel, between 0 and %1.0
146 * @blue: value of the blue channel, between 0 and %1.0
147 * @alpha: value of the alpha channel, between 0 and %1.0
149 * Sets the values of the passed channels into a #CoglColor
152 * Deprecated: 1.4: Use cogl_color_init_from_4f instead.
155 cogl_color_set_from_4f (CoglColor *color,
162 * cogl_color_init_from_4fv:
163 * @color: A pointer to a #CoglColor to initialize
164 * @color_array: a pointer to an array of 4 float color components
166 * Sets the values of the passed channels into a #CoglColor
171 cogl_color_init_from_4fv (CoglColor *color,
175 * cogl_color_get_red_byte:
176 * @color: a #CoglColor
178 * Retrieves the red channel of @color as a byte value
181 * Return value: the red channel of the passed color
186 cogl_color_get_red_byte (const CoglColor *color);
189 * cogl_color_get_green_byte:
190 * @color: a #CoglColor
192 * Retrieves the green channel of @color as a byte value
195 * Return value: the green channel of the passed color
200 cogl_color_get_green_byte (const CoglColor *color);
203 * cogl_color_get_blue_byte:
204 * @color: a #CoglColor
206 * Retrieves the blue channel of @color as a byte value
209 * Return value: the blue channel of the passed color
214 cogl_color_get_blue_byte (const CoglColor *color);
217 * cogl_color_get_alpha_byte:
218 * @color: a #CoglColor
220 * Retrieves the alpha channel of @color as a byte value
223 * Return value: the alpha channel of the passed color
228 cogl_color_get_alpha_byte (const CoglColor *color);
231 * cogl_color_get_red_float:
232 * @color: a #CoglColor
234 * Retrieves the red channel of @color as a floating point
235 * value between 0.0 and 1.0
237 * Return value: the red channel of the passed color
242 cogl_color_get_red_float (const CoglColor *color);
245 * cogl_color_get_green_float:
246 * @color: a #CoglColor
248 * Retrieves the green channel of @color as a floating point
249 * value between 0.0 and 1.0
251 * Return value: the green channel of the passed color
256 cogl_color_get_green_float (const CoglColor *color);
259 * cogl_color_get_blue_float:
260 * @color: a #CoglColor
262 * Retrieves the blue channel of @color as a floating point
263 * value between 0.0 and 1.0
265 * Return value: the blue channel of the passed color
270 cogl_color_get_blue_float (const CoglColor *color);
273 * cogl_color_get_alpha_float:
274 * @color: a #CoglColor
276 * Retrieves the alpha channel of @color as a floating point
277 * value between 0.0 and 1.0
279 * Return value: the alpha channel of the passed color
284 cogl_color_get_alpha_float (const CoglColor *color);
287 * cogl_color_get_red:
288 * @color: a #CoglColor
290 * Retrieves the red channel of @color as a fixed point
291 * value between 0 and %1.0.
293 * Return value: the red channel of the passed color
298 cogl_color_get_red (const CoglColor *color);
301 * cogl_color_get_green:
302 * @color: a #CoglColor
304 * Retrieves the green channel of @color as a fixed point
305 * value between 0 and %1.0.
307 * Return value: the green channel of the passed color
312 cogl_color_get_green (const CoglColor *color);
315 * cogl_color_get_blue:
316 * @color: a #CoglColor
318 * Retrieves the blue channel of @color as a fixed point
319 * value between 0 and %1.0.
321 * Return value: the blue channel of the passed color
326 cogl_color_get_blue (const CoglColor *color);
329 * cogl_color_get_alpha:
330 * @color: a #CoglColor
332 * Retrieves the alpha channel of @color as a fixed point
333 * value between 0 and %1.0.
335 * Return value: the alpha channel of the passed color
340 cogl_color_get_alpha (const CoglColor *color);
343 * cogl_color_set_red_byte:
344 * @color: a #CoglColor
345 * @red: a byte value between 0 and 255
347 * Sets the red channel of @color to @red.
352 cogl_color_set_red_byte (CoglColor *color,
356 * cogl_color_set_green_byte:
357 * @color: a #CoglColor
358 * @green: a byte value between 0 and 255
360 * Sets the green channel of @color to @green.
365 cogl_color_set_green_byte (CoglColor *color,
366 unsigned char green);
369 * cogl_color_set_blue_byte:
370 * @color: a #CoglColor
371 * @blue: a byte value between 0 and 255
373 * Sets the blue channel of @color to @blue.
378 cogl_color_set_blue_byte (CoglColor *color,
382 * cogl_color_set_alpha_byte:
383 * @color: a #CoglColor
384 * @alpha: a byte value between 0 and 255
386 * Sets the alpha channel of @color to @alpha.
391 cogl_color_set_alpha_byte (CoglColor *color,
392 unsigned char alpha);
395 * cogl_color_set_red_float:
396 * @color: a #CoglColor
397 * @red: a float value between 0.0f and 1.0f
399 * Sets the red channel of @color to @red.
404 cogl_color_set_red_float (CoglColor *color,
408 * cogl_color_set_green_float:
409 * @color: a #CoglColor
410 * @green: a float value between 0.0f and 1.0f
412 * Sets the green channel of @color to @green.
417 cogl_color_set_green_float (CoglColor *color,
421 * cogl_color_set_blue_float:
422 * @color: a #CoglColor
423 * @blue: a float value between 0.0f and 1.0f
425 * Sets the blue channel of @color to @blue.
430 cogl_color_set_blue_float (CoglColor *color,
434 * cogl_color_set_alpha_float:
435 * @color: a #CoglColor
436 * @alpha: a float value between 0.0f and 1.0f
438 * Sets the alpha channel of @color to @alpha.
443 cogl_color_set_alpha_float (CoglColor *color,
447 * cogl_color_set_red:
448 * @color: a #CoglColor
449 * @red: a float value between 0.0f and 1.0f
451 * Sets the red channel of @color to @red.
456 cogl_color_set_red (CoglColor *color,
460 * cogl_color_set_green:
461 * @color: a #CoglColor
462 * @green: a float value between 0.0f and 1.0f
464 * Sets the green channel of @color to @green.
469 cogl_color_set_green (CoglColor *color,
473 * cogl_color_set_blue:
474 * @color: a #CoglColor
475 * @blue: a float value between 0.0f and 1.0f
477 * Sets the blue channel of @color to @blue.
482 cogl_color_set_blue (CoglColor *color,
486 * cogl_color_set_alpha:
487 * @color: a #CoglColor
488 * @alpha: a float value between 0.0f and 1.0f
490 * Sets the alpha channel of @color to @alpha.
495 cogl_color_set_alpha (CoglColor *color,
499 * cogl_color_premultiply:
500 * @color: the color to premultiply
502 * Converts a non-premultiplied color to a pre-multiplied color. For
503 * example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied
504 * and (0.5, 0, 0, 0.5) when premultiplied.
509 cogl_color_premultiply (CoglColor *color);
512 * cogl_color_unpremultiply:
513 * @color: the color to unpremultiply
515 * Converts a pre-multiplied color to a non-premultiplied color. For
516 * example, semi-transparent red is (0.5, 0, 0, 0.5) when premultiplied
517 * and (1.0, 0, 0, 0.5) when non-premultiplied.
522 cogl_color_unpremultiply (CoglColor *color);
529 * Compares two #CoglColor<!-- -->s and checks if they are the same.
531 * This function can be passed to g_hash_table_new() as the @key_equal_func
532 * parameter, when using #CoglColor<!-- -->s as keys in a #GHashTable.
534 * Return value: %TRUE if the two colors are the same.
539 cogl_color_equal (gconstpointer v1,
544 #endif /* __COGL_COLOR_H__ */